; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --function-signature --check-attributes ; RUN: opt -attributor -enable-new-pm=0 -attributor-manifest-internal -attributor-max-iterations-verify -attributor-annotate-decl-cs -attributor-max-iterations=10 -S < %s | FileCheck %s --check-prefixes=CHECK,NOT_CGSCC_NPM,NOT_CGSCC_OPM,NOT_TUNIT_NPM,IS__TUNIT____,IS________OPM,IS__TUNIT_OPM ; RUN: opt -aa-pipeline=basic-aa -passes=attributor -attributor-manifest-internal -attributor-max-iterations-verify -attributor-annotate-decl-cs -attributor-max-iterations=10 -S < %s | FileCheck %s --check-prefixes=CHECK,NOT_CGSCC_OPM,NOT_CGSCC_NPM,NOT_TUNIT_OPM,IS__TUNIT____,IS________NPM,IS__TUNIT_NPM ; RUN: opt -attributor-cgscc -enable-new-pm=0 -attributor-manifest-internal -attributor-annotate-decl-cs -S < %s | FileCheck %s --check-prefixes=CHECK,NOT_TUNIT_NPM,NOT_TUNIT_OPM,NOT_CGSCC_NPM,IS__CGSCC____,IS________OPM,IS__CGSCC_OPM ; RUN: opt -aa-pipeline=basic-aa -passes=attributor-cgscc -attributor-manifest-internal -attributor-annotate-decl-cs -S < %s | FileCheck %s --check-prefixes=CHECK,NOT_TUNIT_NPM,NOT_TUNIT_OPM,NOT_CGSCC_OPM,IS__CGSCC____,IS________NPM,IS__CGSCC_NPM target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128" ; Test cases specifically designed for "align" attribute. ; We use FIXME's to indicate problems and missing attributes. ; TEST 1 define i32* @test1(i32* align 8 %0) #0 { ; IS__TUNIT____: Function Attrs: nofree noinline nosync nounwind readnone uwtable willreturn ; IS__TUNIT____-LABEL: define {{[^@]+}}@test1 ; IS__TUNIT____-SAME: (i32* nofree readnone returned align 8 "no-capture-maybe-returned" [[TMP0:%.*]]) [[ATTR0:#.*]] { ; IS__TUNIT____-NEXT: ret i32* [[TMP0]] ; ; IS__CGSCC____: Function Attrs: nofree noinline norecurse nosync nounwind readnone uwtable willreturn ; IS__CGSCC____-LABEL: define {{[^@]+}}@test1 ; IS__CGSCC____-SAME: (i32* nofree readnone returned align 8 "no-capture-maybe-returned" [[TMP0:%.*]]) [[ATTR0:#.*]] { ; IS__CGSCC____-NEXT: ret i32* [[TMP0]] ; ret i32* %0 } ; TEST 2 define i32* @test2(i32* %0) #0 { ; IS__TUNIT____: Function Attrs: nofree noinline nosync nounwind readnone uwtable willreturn ; IS__TUNIT____-LABEL: define {{[^@]+}}@test2 ; IS__TUNIT____-SAME: (i32* nofree readnone returned "no-capture-maybe-returned" [[TMP0:%.*]]) [[ATTR0]] { ; IS__TUNIT____-NEXT: ret i32* [[TMP0]] ; ; IS__CGSCC____: Function Attrs: nofree noinline norecurse nosync nounwind readnone uwtable willreturn ; IS__CGSCC____-LABEL: define {{[^@]+}}@test2 ; IS__CGSCC____-SAME: (i32* nofree readnone returned "no-capture-maybe-returned" [[TMP0:%.*]]) [[ATTR0]] { ; IS__CGSCC____-NEXT: ret i32* [[TMP0]] ; ret i32* %0 } ; TEST 3 define i32* @test3(i32* align 8 %0, i32* align 4 %1, i1 %2) #0 { ; IS__TUNIT____: Function Attrs: nofree noinline nosync nounwind readnone uwtable willreturn ; IS__TUNIT____-LABEL: define {{[^@]+}}@test3 ; IS__TUNIT____-SAME: (i32* nofree readnone align 8 "no-capture-maybe-returned" [[TMP0:%.*]], i32* nofree readnone align 4 "no-capture-maybe-returned" [[TMP1:%.*]], i1 [[TMP2:%.*]]) [[ATTR0]] { ; IS__TUNIT____-NEXT: [[RET:%.*]] = select i1 [[TMP2]], i32* [[TMP0]], i32* [[TMP1]] ; IS__TUNIT____-NEXT: ret i32* [[RET]] ; ; IS__CGSCC____: Function Attrs: nofree noinline norecurse nosync nounwind readnone uwtable willreturn ; IS__CGSCC____-LABEL: define {{[^@]+}}@test3 ; IS__CGSCC____-SAME: (i32* nofree readnone align 8 "no-capture-maybe-returned" [[TMP0:%.*]], i32* nofree readnone align 4 "no-capture-maybe-returned" [[TMP1:%.*]], i1 [[TMP2:%.*]]) [[ATTR0]] { ; IS__CGSCC____-NEXT: [[RET:%.*]] = select i1 [[TMP2]], i32* [[TMP0]], i32* [[TMP1]] ; IS__CGSCC____-NEXT: ret i32* [[RET]] ; %ret = select i1 %2, i32* %0, i32* %1 ret i32* %ret } ; TEST 4 define i32* @test4(i32* align 32 %0, i32* align 32 %1, i1 %2) #0 { ; IS__TUNIT____: Function Attrs: nofree noinline nosync nounwind readnone uwtable willreturn ; IS__TUNIT____-LABEL: define {{[^@]+}}@test4 ; IS__TUNIT____-SAME: (i32* nofree readnone align 32 "no-capture-maybe-returned" [[TMP0:%.*]], i32* nofree readnone align 32 "no-capture-maybe-returned" [[TMP1:%.*]], i1 [[TMP2:%.*]]) [[ATTR0]] { ; IS__TUNIT____-NEXT: [[RET:%.*]] = select i1 [[TMP2]], i32* [[TMP0]], i32* [[TMP1]] ; IS__TUNIT____-NEXT: ret i32* [[RET]] ; ; IS__CGSCC____: Function Attrs: nofree noinline norecurse nosync nounwind readnone uwtable willreturn ; IS__CGSCC____-LABEL: define {{[^@]+}}@test4 ; IS__CGSCC____-SAME: (i32* nofree readnone align 32 "no-capture-maybe-returned" [[TMP0:%.*]], i32* nofree readnone align 32 "no-capture-maybe-returned" [[TMP1:%.*]], i1 [[TMP2:%.*]]) [[ATTR0]] { ; IS__CGSCC____-NEXT: [[RET:%.*]] = select i1 [[TMP2]], i32* [[TMP0]], i32* [[TMP1]] ; IS__CGSCC____-NEXT: ret i32* [[RET]] ; %ret = select i1 %2, i32* %0, i32* %1 ret i32* %ret } ; TEST 5 declare i32* @unknown() declare align 8 i32* @align8() define i32* @test5_1() { ; CHECK-LABEL: define {{[^@]+}}@test5_1() { ; CHECK-NEXT: [[RET:%.*]] = tail call align 8 i32* @unknown() ; CHECK-NEXT: ret i32* [[RET]] ; %ret = tail call align 8 i32* @unknown() ret i32* %ret } define i32* @test5_2() { ; CHECK-LABEL: define {{[^@]+}}@test5_2() { ; CHECK-NEXT: [[RET:%.*]] = tail call align 8 i32* @align8() ; CHECK-NEXT: ret i32* [[RET]] ; %ret = tail call i32* @align8() ret i32* %ret } ; TEST 6 ; SCC define i32* @test6_1() #0 { ; NOT_CGSCC_OPM: Function Attrs: nofree noinline noreturn nosync nounwind readnone uwtable ; NOT_CGSCC_OPM-LABEL: define {{[^@]+}}@test6_1 ; NOT_CGSCC_OPM-SAME: () [[ATTR1:#.*]] { ; NOT_CGSCC_OPM-NEXT: [[RET:%.*]] = tail call i32* @test6_2() [[ATTR11:#.*]] ; NOT_CGSCC_OPM-NEXT: unreachable ; ; IS__CGSCC_OPM: Function Attrs: nofree noinline noreturn nosync nounwind readnone uwtable ; IS__CGSCC_OPM-LABEL: define {{[^@]+}}@test6_1 ; IS__CGSCC_OPM-SAME: () [[ATTR1:#.*]] { ; IS__CGSCC_OPM-NEXT: [[RET:%.*]] = tail call i32* @test6_2() [[ATTR12:#.*]] ; IS__CGSCC_OPM-NEXT: unreachable ; %ret = tail call i32* @test6_2() ret i32* %ret } define i32* @test6_2() #0 { ; NOT_CGSCC_OPM: Function Attrs: nofree noinline noreturn nosync nounwind readnone uwtable ; NOT_CGSCC_OPM-LABEL: define {{[^@]+}}@test6_2 ; NOT_CGSCC_OPM-SAME: () [[ATTR1]] { ; NOT_CGSCC_OPM-NEXT: [[RET:%.*]] = tail call i32* @test6_1() [[ATTR11]] ; NOT_CGSCC_OPM-NEXT: unreachable ; ; IS__CGSCC_OPM: Function Attrs: nofree noinline noreturn nosync nounwind readnone uwtable ; IS__CGSCC_OPM-LABEL: define {{[^@]+}}@test6_2 ; IS__CGSCC_OPM-SAME: () [[ATTR1]] { ; IS__CGSCC_OPM-NEXT: [[RET:%.*]] = tail call i32* @test6_1() [[ATTR12]] ; IS__CGSCC_OPM-NEXT: unreachable ; %ret = tail call i32* @test6_1() ret i32* %ret } ; char a1 __attribute__((aligned(8))); ; char a2 __attribute__((aligned(16))); ; ; char* f1(char* a ){ ; return a?a:f2(&a1); ; } ; char* f2(char* a){ ; return a?f1(a):f3(&a2); ; } ; ; char* f3(char* a){ ; return a?&a1: f1(&a2); ; } @a1 = common global i8 0, align 8 @a2 = common global i8 0, align 16 ; Function Attrs: nounwind readnone ssp uwtable define internal i8* @f1(i8* readnone %0) local_unnamed_addr #0 { ; IS__TUNIT____: Function Attrs: nofree noinline nosync nounwind readnone uwtable willreturn ; IS__TUNIT____-LABEL: define {{[^@]+}}@f1 ; IS__TUNIT____-SAME: (i8* noalias nofree noundef nonnull readnone returned align 8 dereferenceable(1) "no-capture-maybe-returned" [[TMP0:%.*]]) local_unnamed_addr [[ATTR0]] { ; IS__TUNIT____-NEXT: br label [[TMP3:%.*]] ; IS__TUNIT____: 2: ; IS__TUNIT____-NEXT: unreachable ; IS__TUNIT____: 3: ; IS__TUNIT____-NEXT: ret i8* [[TMP0]] ; ; IS__CGSCC_OPM: Function Attrs: nofree noinline nosync nounwind readnone uwtable willreturn ; IS__CGSCC_OPM-LABEL: define {{[^@]+}}@f1 ; IS__CGSCC_OPM-SAME: (i8* noalias nofree noundef nonnull readnone returned align 8 dereferenceable(1) "no-capture-maybe-returned" [[TMP0:%.*]]) local_unnamed_addr [[ATTR2:#.*]] { ; IS__CGSCC_OPM-NEXT: br label [[TMP3:%.*]] ; IS__CGSCC_OPM: 2: ; IS__CGSCC_OPM-NEXT: unreachable ; IS__CGSCC_OPM: 3: ; IS__CGSCC_OPM-NEXT: ret i8* undef ; ; IS__CGSCC_NPM: Function Attrs: nofree noinline norecurse nosync nounwind readnone uwtable willreturn ; IS__CGSCC_NPM-LABEL: define {{[^@]+}}@f1 ; IS__CGSCC_NPM-SAME: () local_unnamed_addr [[ATTR0:#.*]] { ; IS__CGSCC_NPM-NEXT: br label [[TMP2:%.*]] ; IS__CGSCC_NPM: 1: ; IS__CGSCC_NPM-NEXT: unreachable ; IS__CGSCC_NPM: 2: ; IS__CGSCC_NPM-NEXT: ret i8* undef ; %2 = icmp eq i8* %0, null br i1 %2, label %3, label %5 ;