brintos

brintos / llvm-project-archived public Read only

0
0
Text · 11.4 KiB · df3a93f Raw
332 lines · plain
1; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --function-signature --check-attributes --check-globals2; RUN: opt -aa-pipeline=basic-aa -passes=attributor -attributor-manifest-internal  -attributor-annotate-decl-cs -S < %s | FileCheck %s --check-prefixes=CHECK,TUNIT3; RUN: opt -aa-pipeline=basic-aa -passes=attributor-cgscc -attributor-manifest-internal  -attributor-annotate-decl-cs -S < %s | FileCheck %s --check-prefixes=CHECK,CGSCC4 5define i32 @leaf() {6; CHECK: Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(none)7; CHECK-LABEL: define {{[^@]+}}@leaf8; CHECK-SAME: () #[[ATTR0:[0-9]+]] {9; CHECK-NEXT:    ret i32 110;11  ret i32 112}13 14define i32 @self_rec() {15; CHECK: Function Attrs: mustprogress nofree nosync nounwind willreturn memory(none)16; CHECK-LABEL: define {{[^@]+}}@self_rec17; CHECK-SAME: () #[[ATTR1:[0-9]+]] {18; CHECK-NEXT:    ret i32 419;20  %a = call i32 @self_rec()21  ret i32 422}23 24define i32 @indirect_rec() {25; TUNIT: Function Attrs: mustprogress nofree nosync nounwind willreturn memory(none)26; TUNIT-LABEL: define {{[^@]+}}@indirect_rec27; TUNIT-SAME: () #[[ATTR1]] {28; TUNIT-NEXT:    ret i32 undef29;30; CGSCC: Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(none)31; CGSCC-LABEL: define {{[^@]+}}@indirect_rec32; CGSCC-SAME: () #[[ATTR0]] {33; CGSCC-NEXT:    ret i32 undef34;35  %a = call i32 @indirect_rec2()36  ret i32 %a37}38define i32 @indirect_rec2() {39; TUNIT: Function Attrs: mustprogress nofree nosync nounwind willreturn memory(none)40; TUNIT-LABEL: define {{[^@]+}}@indirect_rec241; TUNIT-SAME: () #[[ATTR1]] {42; TUNIT-NEXT:    ret i32 undef43;44; CGSCC: Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(none)45; CGSCC-LABEL: define {{[^@]+}}@indirect_rec246; CGSCC-SAME: () #[[ATTR0]] {47; CGSCC-NEXT:    ret i32 undef48;49  %a = call i32 @indirect_rec()50  ret i32 %a51}52 53define i32 @extern() {54; CHECK: Function Attrs: nosync memory(none)55; CHECK-LABEL: define {{[^@]+}}@extern56; CHECK-SAME: () #[[ATTR2:[0-9]+]] {57; CHECK-NEXT:    [[A:%.*]] = call i32 @k() #[[ATTR9:[0-9]+]]58; CHECK-NEXT:    ret i32 [[A]]59;60  %a = call i32 @k()61  ret i32 %a62}63 64; CHECK: Function Attrs65declare i32 @k() readnone66 67define void @intrinsic(ptr %dest, ptr %src, i32 %len) {68; CHECK: Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: readwrite)69; CHECK-LABEL: define {{[^@]+}}@intrinsic70; CHECK-SAME: (ptr nofree writeonly captures(none) [[DEST:%.*]], ptr nofree readonly captures(none) [[SRC:%.*]], i32 [[LEN:%.*]]) #[[ATTR4:[0-9]+]] {71; CHECK-NEXT:    call void @llvm.memcpy.p0.p0.i32(ptr nofree writeonly captures(none) [[DEST]], ptr nofree readonly captures(none) [[SRC]], i32 [[LEN]], i1 noundef false) #[[ATTR10:[0-9]+]]72; CHECK-NEXT:    ret void73;74  call void @llvm.memcpy.p0.p0.i32(ptr %dest, ptr %src, i32 %len, i1 false)75  ret void76}77 78; CHECK: Function Attrs79declare void @llvm.memcpy.p0.p0.i32(ptr, ptr, i32, i1)80 81define internal i32 @called_by_norecurse() {82; CHECK: Function Attrs: norecurse nosync memory(none)83; CHECK-LABEL: define {{[^@]+}}@called_by_norecurse84; CHECK-SAME: () #[[ATTR6:[0-9]+]] {85; CHECK-NEXT:    [[A:%.*]] = call i32 @k() #[[ATTR9]]86; CHECK-NEXT:    ret i32 undef87;88  %a = call i32 @k()89  ret i32 %a90}91define void @m() norecurse {92; TUNIT: Function Attrs: norecurse nosync memory(none)93; TUNIT-LABEL: define {{[^@]+}}@m94; TUNIT-SAME: () #[[ATTR6]] {95; TUNIT-NEXT:    [[A:%.*]] = call i32 @called_by_norecurse() #[[ATTR2]]96; TUNIT-NEXT:    ret void97;98; CGSCC: Function Attrs: norecurse nosync memory(none)99; CGSCC-LABEL: define {{[^@]+}}@m100; CGSCC-SAME: () #[[ATTR6]] {101; CGSCC-NEXT:    [[A:%.*]] = call i32 @called_by_norecurse() #[[ATTR9]]102; CGSCC-NEXT:    ret void103;104  %a = call i32 @called_by_norecurse()105  ret void106}107 108define internal i32 @called_by_norecurse_indirectly() {109; TUNIT: Function Attrs: norecurse nosync memory(none)110; TUNIT-LABEL: define {{[^@]+}}@called_by_norecurse_indirectly111; TUNIT-SAME: () #[[ATTR6]] {112; TUNIT-NEXT:    [[A:%.*]] = call i32 @k() #[[ATTR9]]113; TUNIT-NEXT:    ret i32 [[A]]114;115; CGSCC: Function Attrs: nosync memory(none)116; CGSCC-LABEL: define {{[^@]+}}@called_by_norecurse_indirectly117; CGSCC-SAME: () #[[ATTR2]] {118; CGSCC-NEXT:    [[A:%.*]] = call i32 @k() #[[ATTR9]]119; CGSCC-NEXT:    ret i32 [[A]]120;121  %a = call i32 @k()122  ret i32 %a123}124define internal i32 @o() {125; TUNIT: Function Attrs: norecurse nosync memory(none)126; TUNIT-LABEL: define {{[^@]+}}@o127; TUNIT-SAME: () #[[ATTR6]] {128; TUNIT-NEXT:    [[A:%.*]] = call i32 @called_by_norecurse_indirectly() #[[ATTR2]]129; TUNIT-NEXT:    ret i32 [[A]]130;131; CGSCC: Function Attrs: norecurse nosync memory(none)132; CGSCC-LABEL: define {{[^@]+}}@o133; CGSCC-SAME: () #[[ATTR6]] {134; CGSCC-NEXT:    [[A:%.*]] = call i32 @called_by_norecurse_indirectly() #[[ATTR9]]135; CGSCC-NEXT:    ret i32 [[A]]136;137  %a = call i32 @called_by_norecurse_indirectly()138  ret i32 %a139}140define i32 @p() norecurse {141; TUNIT: Function Attrs: norecurse nosync memory(none)142; TUNIT-LABEL: define {{[^@]+}}@p143; TUNIT-SAME: () #[[ATTR6]] {144; TUNIT-NEXT:    [[A:%.*]] = call i32 @o() #[[ATTR2]]145; TUNIT-NEXT:    ret i32 [[A]]146;147; CGSCC: Function Attrs: norecurse nosync memory(none)148; CGSCC-LABEL: define {{[^@]+}}@p149; CGSCC-SAME: () #[[ATTR6]] {150; CGSCC-NEXT:    [[A:%.*]] = call i32 @o() #[[ATTR9]]151; CGSCC-NEXT:    ret i32 [[A]]152;153  %a = call i32 @o()154  ret i32 %a155}156 157define void @f(i32 %x)  {158; TUNIT: Function Attrs: mustprogress nofree nosync nounwind willreturn memory(none)159; TUNIT-LABEL: define {{[^@]+}}@f160; TUNIT-SAME: (i32 [[X:%.*]]) #[[ATTR1]] {161; TUNIT-NEXT:  entry:162; TUNIT-NEXT:    [[X_ADDR:%.*]] = alloca i32, align 4163; TUNIT-NEXT:    store i32 [[X]], ptr [[X_ADDR]], align 4164; TUNIT-NEXT:    [[TOBOOL:%.*]] = icmp ne i32 [[X]], 0165; TUNIT-NEXT:    br i1 [[TOBOOL]], label [[IF_THEN:%.*]], label [[IF_END:%.*]]166; TUNIT:       if.then:167; TUNIT-NEXT:    br label [[IF_END]]168; TUNIT:       if.end:169; TUNIT-NEXT:    ret void170;171; CGSCC: Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(none)172; CGSCC-LABEL: define {{[^@]+}}@f173; CGSCC-SAME: (i32 [[X:%.*]]) #[[ATTR0]] {174; CGSCC-NEXT:  entry:175; CGSCC-NEXT:    [[X_ADDR:%.*]] = alloca i32, align 4176; CGSCC-NEXT:    [[TOBOOL:%.*]] = icmp ne i32 [[X]], 0177; CGSCC-NEXT:    br i1 [[TOBOOL]], label [[IF_THEN:%.*]], label [[IF_END:%.*]]178; CGSCC:       if.then:179; CGSCC-NEXT:    br label [[IF_END]]180; CGSCC:       if.end:181; CGSCC-NEXT:    ret void182;183entry:184  %x.addr = alloca i32, align 4185  store i32 %x, ptr %x.addr, align 4186  %0 = load i32, ptr %x.addr, align 4187  %tobool = icmp ne i32 %0, 0188  br i1 %tobool, label %if.then, label %if.end189 190if.then:191  call void @g() norecurse192  br label %if.end193 194if.end:195  ret void196}197 198define void @g() norecurse {199; CHECK: Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(none)200; CHECK-LABEL: define {{[^@]+}}@g201; CHECK-SAME: () #[[ATTR0]] {202; CHECK-NEXT:  entry:203; CHECK-NEXT:    ret void204;205entry:206  call void @f(i32 0)207  ret void208}209 210define linkonce_odr i32 @leaf_redefinable() {211; CHECK-LABEL: define {{[^@]+}}@leaf_redefinable() {212; CHECK-NEXT:    ret i32 1213;214  ret i32 1215}216 217; Call through a function pointer218define i32 @eval_func1(ptr , i32) local_unnamed_addr {219; CHECK-LABEL: define {{[^@]+}}@eval_func1220; CHECK-SAME: (ptr nofree noundef nonnull captures(none) [[TMP0:%.*]], i32 [[TMP1:%.*]]) local_unnamed_addr {221; CHECK-NEXT:    [[TMP3:%.*]] = tail call i32 [[TMP0]](i32 [[TMP1]])222; CHECK-NEXT:    ret i32 [[TMP3]]223;224  %3 = tail call i32 %0(i32 %1) #2225  ret i32 %3226}227 228define i32 @eval_func2(ptr , i32) local_unnamed_addr null_pointer_is_valid{229; CHECK: Function Attrs: null_pointer_is_valid230; CHECK-LABEL: define {{[^@]+}}@eval_func2231; CHECK-SAME: (ptr nofree noundef captures(none) [[TMP0:%.*]], i32 [[TMP1:%.*]]) local_unnamed_addr #[[ATTR7:[0-9]+]] {232; CHECK-NEXT:    [[TMP3:%.*]] = tail call i32 [[TMP0]](i32 [[TMP1]])233; CHECK-NEXT:    ret i32 [[TMP3]]234;235  %3 = tail call i32 %0(i32 %1) #2236  ret i32 %3237}238 239; Call an unknown function in a dead block.240declare void @unknown()241define i32 @call_unknown_in_dead_block() local_unnamed_addr {242; CHECK: Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(none)243; CHECK-LABEL: define {{[^@]+}}@call_unknown_in_dead_block244; CHECK-SAME: () local_unnamed_addr #[[ATTR0]] {245; CHECK-NEXT:    ret i32 0246; CHECK:       Dead:247; CHECK-NEXT:    unreachable248;249  ret i32 0250Dead:251  tail call void @unknown()252  ret i32 1253}254 255define i1 @test_rec_neg(i1 %c) norecurse {256; TUNIT: Function Attrs: norecurse257; TUNIT-LABEL: define {{[^@]+}}@test_rec_neg258; TUNIT-SAME: (i1 [[C:%.*]]) #[[ATTR8:[0-9]+]] {259; TUNIT-NEXT:    [[RC1:%.*]] = call i1 @rec(i1 noundef true)260; TUNIT-NEXT:    br i1 [[RC1]], label [[T:%.*]], label [[F:%.*]]261; TUNIT:       t:262; TUNIT-NEXT:    [[RC2:%.*]] = call i1 @rec(i1 noundef [[C]])263; TUNIT-NEXT:    ret i1 [[RC2]]264; TUNIT:       f:265; TUNIT-NEXT:    ret i1 [[RC1]]266;267; CGSCC: Function Attrs: norecurse268; CGSCC-LABEL: define {{[^@]+}}@test_rec_neg269; CGSCC-SAME: (i1 [[C:%.*]]) #[[ATTR8:[0-9]+]] {270; CGSCC-NEXT:    [[RC1:%.*]] = call noundef i1 @rec(i1 noundef true)271; CGSCC-NEXT:    br i1 [[RC1]], label [[T:%.*]], label [[F:%.*]]272; CGSCC:       t:273; CGSCC-NEXT:    [[RC2:%.*]] = call noundef i1 @rec(i1 noundef [[C]])274; CGSCC-NEXT:    ret i1 [[RC2]]275; CGSCC:       f:276; CGSCC-NEXT:    ret i1 [[RC1]]277;278  %rc1 = call i1 @rec(i1 true)279  br i1 %rc1, label %t, label %f280t:281  %rc2 = call i1 @rec(i1 %c)282  ret i1 %rc2283f:284  ret i1 %rc1285}286 287define internal i1 @rec(i1 %c1) {288; CHECK-LABEL: define {{[^@]+}}@rec289; CHECK-SAME: (i1 noundef [[C1:%.*]]) {290; CHECK-NEXT:    br i1 [[C1]], label [[T:%.*]], label [[F:%.*]]291; CHECK:       t:292; CHECK-NEXT:    ret i1 true293; CHECK:       f:294; CHECK-NEXT:    [[R:%.*]] = call i1 @rec(i1 noundef true)295; CHECK-NEXT:    call void @unknown()296; CHECK-NEXT:    ret i1 false297;298  br i1 %c1, label %t, label %f299t:300  ret i1 true301f:302  %r = call i1 @rec(i1 true)303  call void @unknown()304  ret i1 false305}306 307;.308; TUNIT: attributes #[[ATTR0]] = { mustprogress nofree norecurse nosync nounwind willreturn memory(none) }309; TUNIT: attributes #[[ATTR1]] = { mustprogress nofree nosync nounwind willreturn memory(none) }310; TUNIT: attributes #[[ATTR2]] = { nosync memory(none) }311; TUNIT: attributes #[[ATTR3:[0-9]+]] = { memory(none) }312; TUNIT: attributes #[[ATTR4]] = { mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: readwrite) }313; TUNIT: attributes #[[ATTR5:[0-9]+]] = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }314; TUNIT: attributes #[[ATTR6]] = { norecurse nosync memory(none) }315; TUNIT: attributes #[[ATTR7]] = { null_pointer_is_valid }316; TUNIT: attributes #[[ATTR8]] = { norecurse }317; TUNIT: attributes #[[ATTR9]] = { nosync }318; TUNIT: attributes #[[ATTR10]] = { nofree willreturn }319;.320; CGSCC: attributes #[[ATTR0]] = { mustprogress nofree norecurse nosync nounwind willreturn memory(none) }321; CGSCC: attributes #[[ATTR1]] = { mustprogress nofree nosync nounwind willreturn memory(none) }322; CGSCC: attributes #[[ATTR2]] = { nosync memory(none) }323; CGSCC: attributes #[[ATTR3:[0-9]+]] = { memory(none) }324; CGSCC: attributes #[[ATTR4]] = { mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: readwrite) }325; CGSCC: attributes #[[ATTR5:[0-9]+]] = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }326; CGSCC: attributes #[[ATTR6]] = { norecurse nosync memory(none) }327; CGSCC: attributes #[[ATTR7]] = { null_pointer_is_valid }328; CGSCC: attributes #[[ATTR8]] = { norecurse }329; CGSCC: attributes #[[ATTR9]] = { nosync }330; CGSCC: attributes #[[ATTR10]] = { nofree willreturn }331;.332