248 lines · plain
1; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --check-globals all --version 52; RUN: opt < %s -passes='bounds-checking<trap;merge>' -S | FileCheck %s --check-prefixes=TR3; RUN: opt < %s -passes='bounds-checking<rt;merge>' -S | FileCheck %s --check-prefixes=RT4 5; RUN: opt < %s -passes=bounds-checking -S | FileCheck %s --check-prefixes=TR-NOMERGE6; RUN: opt < %s -passes='bounds-checking<trap>' -S | FileCheck %s --check-prefixes=TR-NOMERGE7; RUN: opt < %s -passes='bounds-checking<rt>' -S | FileCheck %s --check-prefixes=RT-NOMERGE8; RUN: opt < %s -passes='bounds-checking<rt-abort>' -S | FileCheck %s --check-prefixes=RTABORT-NOMERGE9; RUN: opt < %s -passes='bounds-checking<min-rt>' -S | FileCheck %s --check-prefixes=MINRT-NOMERGE10; RUN: opt < %s -passes='bounds-checking<min-rt-abort>' -S | FileCheck %s --check-prefixes=MINRTABORT-NOMERGE11 12; RUN: opt < %s -passes='bounds-checking<min-rt;handler-preserve-all-regs>' -S | FileCheck %s --check-prefixes=MINRT-PRESERVE-NOMERGE13; RUN: opt < %s -passes='bounds-checking<min-rt-abort;handler-preserve-all-regs>' -S | FileCheck %s --check-prefixes=MINRTABORT-NOMERGE14;15; RUN: opt < %s -passes='bounds-checking<trap;guard=3>' -S | FileCheck %s --check-prefixes=TR-GUARD-COMMON,TR-GUARD-THREE16; RUN: opt < %s -passes='bounds-checking<trap;guard=13>' -S | FileCheck %s --check-prefixes=TR-GUARD-COMMON,TR-GUARD-THIRTEEN17; RUN: opt < %s -passes='bounds-checking<rt;guard=-5>' -S | FileCheck %s --check-prefixes=RT-GUARD18target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128"19 20define void @f1(i64 %x) nounwind {21; TR-LABEL: define void @f1(22; TR-SAME: i64 [[X:%.*]]) #[[ATTR0:[0-9]+]] {23; TR-NEXT: [[TMP1:%.*]] = mul i64 16, [[X]]24; TR-NEXT: [[TMP2:%.*]] = alloca i128, i64 [[X]], align 825; TR-NEXT: [[TMP3:%.*]] = sub i64 [[TMP1]], 0, !nosanitize [[META0:![0-9]+]]26; TR-NEXT: [[TMP4:%.*]] = icmp ult i64 [[TMP3]], 16, !nosanitize [[META0]]27; TR-NEXT: [[TMP5:%.*]] = or i1 false, [[TMP4]], !nosanitize [[META0]]28; TR-NEXT: [[TMP6:%.*]] = or i1 false, [[TMP5]], !nosanitize [[META0]]29; TR-NEXT: br i1 [[TMP6]], label %[[TRAP:.*]], label %[[BB7:.*]]30; TR: [[BB7]]:31; TR-NEXT: [[TMP8:%.*]] = load i128, ptr [[TMP2]], align 432; TR-NEXT: ret void33; TR: [[TRAP]]:34; TR-NEXT: call void @llvm.trap() #[[ATTR2:[0-9]+]], !nosanitize [[META0]]35; TR-NEXT: unreachable, !nosanitize [[META0]]36;37; RT-LABEL: define void @f1(38; RT-SAME: i64 [[X:%.*]]) #[[ATTR0:[0-9]+]] {39; RT-NEXT: [[TMP1:%.*]] = mul i64 16, [[X]]40; RT-NEXT: [[TMP2:%.*]] = alloca i128, i64 [[X]], align 841; RT-NEXT: [[TMP3:%.*]] = sub i64 [[TMP1]], 0, !nosanitize [[META0:![0-9]+]]42; RT-NEXT: [[TMP4:%.*]] = icmp ult i64 [[TMP3]], 16, !nosanitize [[META0]]43; RT-NEXT: [[TMP5:%.*]] = or i1 false, [[TMP4]], !nosanitize [[META0]]44; RT-NEXT: [[TMP6:%.*]] = or i1 false, [[TMP5]], !nosanitize [[META0]]45; RT-NEXT: br i1 [[TMP6]], label %[[TRAP:.*]], label %[[BB7:.*]]46; RT: [[BB7]]:47; RT-NEXT: [[TMP8:%.*]] = load i128, ptr [[TMP2]], align 448; RT-NEXT: ret void49; RT: [[TRAP]]:50; RT-NEXT: call void @__ubsan_handle_local_out_of_bounds() #[[ATTR0]], !nosanitize [[META0]]51; RT-NEXT: br label %[[BB7]], !nosanitize [[META0]]52;53; TR-NOMERGE-LABEL: define void @f1(54; TR-NOMERGE-SAME: i64 [[X:%.*]]) #[[ATTR0:[0-9]+]] {55; TR-NOMERGE-NEXT: [[TMP1:%.*]] = mul i64 16, [[X]]56; TR-NOMERGE-NEXT: [[TMP2:%.*]] = alloca i128, i64 [[X]], align 857; TR-NOMERGE-NEXT: [[TMP3:%.*]] = sub i64 [[TMP1]], 0, !nosanitize [[META0:![0-9]+]]58; TR-NOMERGE-NEXT: [[TMP4:%.*]] = icmp ult i64 [[TMP3]], 16, !nosanitize [[META0]]59; TR-NOMERGE-NEXT: [[TMP5:%.*]] = or i1 false, [[TMP4]], !nosanitize [[META0]]60; TR-NOMERGE-NEXT: [[TMP6:%.*]] = or i1 false, [[TMP5]], !nosanitize [[META0]]61; TR-NOMERGE-NEXT: br i1 [[TMP6]], label %[[TRAP:.*]], label %[[BB7:.*]]62; TR-NOMERGE: [[BB7]]:63; TR-NOMERGE-NEXT: [[TMP8:%.*]] = load i128, ptr [[TMP2]], align 464; TR-NOMERGE-NEXT: ret void65; TR-NOMERGE: [[TRAP]]:66; TR-NOMERGE-NEXT: call void @llvm.ubsantrap(i8 3) #[[ATTR2:[0-9]+]], !nosanitize [[META0]]67; TR-NOMERGE-NEXT: unreachable, !nosanitize [[META0]]68;69; RT-NOMERGE-LABEL: define void @f1(70; RT-NOMERGE-SAME: i64 [[X:%.*]]) #[[ATTR0:[0-9]+]] {71; RT-NOMERGE-NEXT: [[TMP1:%.*]] = mul i64 16, [[X]]72; RT-NOMERGE-NEXT: [[TMP2:%.*]] = alloca i128, i64 [[X]], align 873; RT-NOMERGE-NEXT: [[TMP3:%.*]] = sub i64 [[TMP1]], 0, !nosanitize [[META0:![0-9]+]]74; RT-NOMERGE-NEXT: [[TMP4:%.*]] = icmp ult i64 [[TMP3]], 16, !nosanitize [[META0]]75; RT-NOMERGE-NEXT: [[TMP5:%.*]] = or i1 false, [[TMP4]], !nosanitize [[META0]]76; RT-NOMERGE-NEXT: [[TMP6:%.*]] = or i1 false, [[TMP5]], !nosanitize [[META0]]77; RT-NOMERGE-NEXT: br i1 [[TMP6]], label %[[TRAP:.*]], label %[[BB7:.*]]78; RT-NOMERGE: [[BB7]]:79; RT-NOMERGE-NEXT: [[TMP8:%.*]] = load i128, ptr [[TMP2]], align 480; RT-NOMERGE-NEXT: ret void81; RT-NOMERGE: [[TRAP]]:82; RT-NOMERGE-NEXT: call void @__ubsan_handle_local_out_of_bounds() #[[ATTR1:[0-9]+]], !nosanitize [[META0]]83; RT-NOMERGE-NEXT: br label %[[BB7]], !nosanitize [[META0]]84;85; RTABORT-NOMERGE-LABEL: define void @f1(86; RTABORT-NOMERGE-SAME: i64 [[X:%.*]]) #[[ATTR0:[0-9]+]] {87; RTABORT-NOMERGE-NEXT: [[TMP1:%.*]] = mul i64 16, [[X]]88; RTABORT-NOMERGE-NEXT: [[TMP2:%.*]] = alloca i128, i64 [[X]], align 889; RTABORT-NOMERGE-NEXT: [[TMP3:%.*]] = sub i64 [[TMP1]], 0, !nosanitize [[META0:![0-9]+]]90; RTABORT-NOMERGE-NEXT: [[TMP4:%.*]] = icmp ult i64 [[TMP3]], 16, !nosanitize [[META0]]91; RTABORT-NOMERGE-NEXT: [[TMP5:%.*]] = or i1 false, [[TMP4]], !nosanitize [[META0]]92; RTABORT-NOMERGE-NEXT: [[TMP6:%.*]] = or i1 false, [[TMP5]], !nosanitize [[META0]]93; RTABORT-NOMERGE-NEXT: br i1 [[TMP6]], label %[[TRAP:.*]], label %[[BB7:.*]]94; RTABORT-NOMERGE: [[BB7]]:95; RTABORT-NOMERGE-NEXT: [[TMP8:%.*]] = load i128, ptr [[TMP2]], align 496; RTABORT-NOMERGE-NEXT: ret void97; RTABORT-NOMERGE: [[TRAP]]:98; RTABORT-NOMERGE-NEXT: call void @__ubsan_handle_local_out_of_bounds_abort() #[[ATTR2:[0-9]+]], !nosanitize [[META0]]99; RTABORT-NOMERGE-NEXT: unreachable, !nosanitize [[META0]]100;101; MINRT-PRESERVE-NOMERGE-LABEL: define void @f1(102; MINRT-PRESERVE-NOMERGE-SAME: i64 [[X:%.*]]) #[[ATTR0:[0-9]+]] {103; MINRT-PRESERVE-NOMERGE-NEXT: [[TMP1:%.*]] = mul i64 16, [[X]]104; MINRT-PRESERVE-NOMERGE-NEXT: [[TMP2:%.*]] = alloca i128, i64 [[X]], align 8105; MINRT-PRESERVE-NOMERGE-NEXT: [[TMP3:%.*]] = sub i64 [[TMP1]], 0, !nosanitize [[META0:![0-9]+]]106; MINRT-PRESERVE-NOMERGE-NEXT: [[TMP4:%.*]] = icmp ult i64 [[TMP3]], 16, !nosanitize [[META0]]107; MINRT-PRESERVE-NOMERGE-NEXT: [[TMP5:%.*]] = or i1 false, [[TMP4]], !nosanitize [[META0]]108; MINRT-PRESERVE-NOMERGE-NEXT: [[TMP6:%.*]] = or i1 false, [[TMP5]], !nosanitize [[META0]]109; MINRT-PRESERVE-NOMERGE-NEXT: br i1 [[TMP6]], label %[[TRAP:.*]], label %[[BB7:.*]]110; MINRT-PRESERVE-NOMERGE: [[BB7]]:111; MINRT-PRESERVE-NOMERGE-NEXT: [[TMP8:%.*]] = load i128, ptr [[TMP2]], align 4112; MINRT-PRESERVE-NOMERGE-NEXT: ret void113; MINRT-PRESERVE-NOMERGE: [[TRAP]]:114; MINRT-PRESERVE-NOMERGE-NEXT: call preserve_allcc void @__ubsan_handle_local_out_of_bounds_minimal_preserve() #[[ATTR1:[0-9]+]], !nosanitize [[META0]]115; MINRT-PRESERVE-NOMERGE-NEXT: br label %[[BB7]], !nosanitize [[META0]]116;117; MINRT-NOMERGE-LABEL: define void @f1(118; MINRT-NOMERGE-SAME: i64 [[X:%.*]]) #[[ATTR0:[0-9]+]] {119; MINRT-NOMERGE-NEXT: [[TMP1:%.*]] = mul i64 16, [[X]]120; MINRT-NOMERGE-NEXT: [[TMP2:%.*]] = alloca i128, i64 [[X]], align 8121; MINRT-NOMERGE-NEXT: [[TMP3:%.*]] = sub i64 [[TMP1]], 0, !nosanitize [[META0:![0-9]+]]122; MINRT-NOMERGE-NEXT: [[TMP4:%.*]] = icmp ult i64 [[TMP3]], 16, !nosanitize [[META0]]123; MINRT-NOMERGE-NEXT: [[TMP5:%.*]] = or i1 false, [[TMP4]], !nosanitize [[META0]]124; MINRT-NOMERGE-NEXT: [[TMP6:%.*]] = or i1 false, [[TMP5]], !nosanitize [[META0]]125; MINRT-NOMERGE-NEXT: br i1 [[TMP6]], label %[[TRAP:.*]], label %[[BB7:.*]]126; MINRT-NOMERGE: [[BB7]]:127; MINRT-NOMERGE-NEXT: [[TMP8:%.*]] = load i128, ptr [[TMP2]], align 4128; MINRT-NOMERGE-NEXT: ret void129; MINRT-NOMERGE: [[TRAP]]:130; MINRT-NOMERGE-NEXT: call void @__ubsan_handle_local_out_of_bounds_minimal() #[[ATTR1:[0-9]+]], !nosanitize [[META0]]131; MINRT-NOMERGE-NEXT: br label %[[BB7]], !nosanitize [[META0]]132;133; MINRTABORT-NOMERGE-LABEL: define void @f1(134; MINRTABORT-NOMERGE-SAME: i64 [[X:%.*]]) #[[ATTR0:[0-9]+]] {135; MINRTABORT-NOMERGE-NEXT: [[TMP1:%.*]] = mul i64 16, [[X]]136; MINRTABORT-NOMERGE-NEXT: [[TMP2:%.*]] = alloca i128, i64 [[X]], align 8137; MINRTABORT-NOMERGE-NEXT: [[TMP3:%.*]] = sub i64 [[TMP1]], 0, !nosanitize [[META0:![0-9]+]]138; MINRTABORT-NOMERGE-NEXT: [[TMP4:%.*]] = icmp ult i64 [[TMP3]], 16, !nosanitize [[META0]]139; MINRTABORT-NOMERGE-NEXT: [[TMP5:%.*]] = or i1 false, [[TMP4]], !nosanitize [[META0]]140; MINRTABORT-NOMERGE-NEXT: [[TMP6:%.*]] = or i1 false, [[TMP5]], !nosanitize [[META0]]141; MINRTABORT-NOMERGE-NEXT: br i1 [[TMP6]], label %[[TRAP:.*]], label %[[BB7:.*]]142; MINRTABORT-NOMERGE: [[BB7]]:143; MINRTABORT-NOMERGE-NEXT: [[TMP8:%.*]] = load i128, ptr [[TMP2]], align 4144; MINRTABORT-NOMERGE-NEXT: ret void145; MINRTABORT-NOMERGE: [[TRAP]]:146; MINRTABORT-NOMERGE-NEXT: call void @__ubsan_handle_local_out_of_bounds_minimal_abort() #[[ATTR2:[0-9]+]], !nosanitize [[META0]]147; MINRTABORT-NOMERGE-NEXT: unreachable, !nosanitize [[META0]]148;149; TR-GUARD-COMMON-LABEL: define void @f1(150; TR-GUARD-COMMON-SAME: i64 [[X:%.*]]) #[[ATTR0:[0-9]+]] {151; TR-GUARD-COMMON-NEXT: [[TMP1:%.*]] = mul i64 16, [[X]]152; TR-GUARD-COMMON-NEXT: [[TMP2:%.*]] = alloca i128, i64 [[X]], align 8153; TR-GUARD-COMMON-NEXT: [[TMP3:%.*]] = sub i64 [[TMP1]], 0, !nosanitize [[META0:![0-9]+]]154; TR-GUARD-COMMON-NEXT: [[TMP4:%.*]] = icmp ult i64 [[TMP3]], 16, !nosanitize [[META0]]155; TR-GUARD-COMMON-NEXT: [[TMP5:%.*]] = or i1 false, [[TMP4]], !nosanitize [[META0]]156; TR-GUARD-COMMON-NEXT: [[TMP6:%.*]] = or i1 false, [[TMP5]], !nosanitize [[META0]]157;158; TR-GUARD-THREE: [[TMP7:%.*]] = call i1 @llvm.allow.ubsan.check(i8 3), !nosanitize [[META0]]159; TR-GUARD-THIRTEEN: [[TMP7:%.*]] = call i1 @llvm.allow.ubsan.check(i8 13), !nosanitize [[META0]]160;161; TR-GUARD-COMMON: [[TMP8:%.*]] = and i1 [[TMP6]], [[TMP7]], !nosanitize [[META0]]162; TR-GUARD-COMMON-NEXT: br i1 [[TMP8]], label %[[TRAP:.*]], label %[[BB9:.*]]163; TR-GUARD-COMMON: [[BB9]]:164; TR-GUARD-COMMON-NEXT: [[TMP10:%.*]] = load i128, ptr [[TMP2]], align 4165; TR-GUARD-COMMON-NEXT: ret void166; TR-GUARD-COMMON: [[TRAP]]:167;168; TR-GUARD-THREE: call void @llvm.ubsantrap(i8 3) #[[ATTR3:[0-9]+]], !nosanitize [[META0]]169; TR-GUARD-THIRTEEN: call void @llvm.ubsantrap(i8 13) #[[ATTR3:[0-9]+]], !nosanitize [[META0]]170;171; TR-GUARD-COMMON: unreachable, !nosanitize [[META0]]172;173; RT-GUARD-LABEL: define void @f1(174; RT-GUARD-SAME: i64 [[X:%.*]]) #[[ATTR0:[0-9]+]] {175; RT-GUARD-NEXT: [[TMP1:%.*]] = mul i64 16, [[X]]176; RT-GUARD-NEXT: [[TMP2:%.*]] = alloca i128, i64 [[X]], align 8177; RT-GUARD-NEXT: [[TMP3:%.*]] = sub i64 [[TMP1]], 0, !nosanitize [[META0:![0-9]+]]178; RT-GUARD-NEXT: [[TMP4:%.*]] = icmp ult i64 [[TMP3]], 16, !nosanitize [[META0]]179; RT-GUARD-NEXT: [[TMP5:%.*]] = or i1 false, [[TMP4]], !nosanitize [[META0]]180; RT-GUARD-NEXT: [[TMP6:%.*]] = or i1 false, [[TMP5]], !nosanitize [[META0]]181; RT-GUARD-NEXT: [[TMP7:%.*]] = call i1 @llvm.allow.ubsan.check(i8 -5), !nosanitize [[META0]]182; RT-GUARD-NEXT: [[TMP8:%.*]] = and i1 [[TMP6]], [[TMP7]], !nosanitize [[META0]]183; RT-GUARD-NEXT: br i1 [[TMP8]], label %[[TRAP:.*]], label %[[BB9:.*]]184; RT-GUARD: [[BB9]]:185; RT-GUARD-NEXT: [[TMP10:%.*]] = load i128, ptr [[TMP2]], align 4186; RT-GUARD-NEXT: ret void187; RT-GUARD: [[TRAP]]:188; RT-GUARD-NEXT: call void @__ubsan_handle_local_out_of_bounds() #[[ATTR2:[0-9]+]], !nosanitize [[META0]]189; RT-GUARD-NEXT: br label %[[BB9]], !nosanitize [[META0]]190;191 %1 = alloca i128, i64 %x192 %3 = load i128, ptr %1, align 4193 ret void194}195 196;.197; TR: attributes #[[ATTR0]] = { nounwind }198; TR: attributes #[[ATTR1:[0-9]+]] = { cold noreturn nounwind memory(inaccessiblemem: write) }199; TR: attributes #[[ATTR2]] = { noreturn nounwind }200;.201; RT: attributes #[[ATTR0]] = { nounwind }202;.203; TR-NOMERGE: attributes #[[ATTR0]] = { nounwind }204; TR-NOMERGE: attributes #[[ATTR1:[0-9]+]] = { cold noreturn nounwind memory(inaccessiblemem: write) }205; TR-NOMERGE: attributes #[[ATTR2]] = { nomerge noreturn nounwind }206;.207; RT-NOMERGE: attributes #[[ATTR0]] = { nounwind }208; RT-NOMERGE: attributes #[[ATTR1]] = { nomerge nounwind }209;.210; RTABORT-NOMERGE: attributes #[[ATTR0]] = { nounwind }211; RTABORT-NOMERGE: attributes #[[ATTR1:[0-9]+]] = { noreturn nounwind }212; RTABORT-NOMERGE: attributes #[[ATTR2]] = { nomerge noreturn nounwind }213;.214; MINRT-NOMERGE: attributes #[[ATTR0]] = { nounwind }215; MINRT-NOMERGE: attributes #[[ATTR1]] = { nomerge nounwind }216;.217; MINRTABORT-NOMERGE: attributes #[[ATTR0]] = { nounwind }218; MINRTABORT-NOMERGE: attributes #[[ATTR1:[0-9]+]] = { noreturn nounwind }219; MINRTABORT-NOMERGE: attributes #[[ATTR2]] = { nomerge noreturn nounwind }220;.221; TR-GUARD: attributes #[[ATTR0]] = { nounwind }222; TR-GUARD: attributes #[[ATTR1:[0-9]+]] = { nocallback nofree nosync nounwind willreturn memory(inaccessiblemem: write) }223; TR-GUARD: attributes #[[ATTR2:[0-9]+]] = { cold noreturn nounwind memory(inaccessiblemem: write) }224; TR-GUARD: attributes #[[ATTR3]] = { nomerge noreturn nounwind }225;.226; RT-GUARD: attributes #[[ATTR0]] = { nounwind }227; RT-GUARD: attributes #[[ATTR1:[0-9]+]] = { nocallback nofree nosync nounwind willreturn memory(inaccessiblemem: readwrite) }228; RT-GUARD: attributes #[[ATTR2]] = { nomerge nounwind }229;.230; TR: [[META0]] = !{}231;.232; RT: [[META0]] = !{}233;.234; TR-NOMERGE: [[META0]] = !{}235;.236; RT-NOMERGE: [[META0]] = !{}237;.238; RTABORT-NOMERGE: [[META0]] = !{}239;.240; MINRT-NOMERGE: [[META0]] = !{}241;.242; MINRTABORT-NOMERGE: [[META0]] = !{}243;.244; TR-GUARD: [[META0]] = !{}245;.246; RT-GUARD: [[META0]] = !{}247;.248