xref: /llvm-project/llvm/test/Transforms/Attributor/ArgumentPromotion/pr32917.ll (revision 29441e4f5fa5f5c7709f7cf180815ba97f611297)
1; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --function-signature --check-attributes --check-globals
2; RUN: opt -aa-pipeline=basic-aa -passes=attributor -attributor-manifest-internal  -attributor-annotate-decl-cs  -S < %s | FileCheck %s --check-prefixes=CHECK,TUNIT
3; RUN: opt -aa-pipeline=basic-aa -passes=attributor-cgscc -attributor-manifest-internal  -attributor-annotate-decl-cs -S < %s | FileCheck %s --check-prefixes=CHECK,CGSCC
4; PR 32917
5
6@b = common local_unnamed_addr global i32 0, align 4
7@a = common local_unnamed_addr global i32 0, align 4
8
9;.
10; CHECK: @b = common local_unnamed_addr global i32 0, align 4
11; CHECK: @a = common local_unnamed_addr global i32 0, align 4
12;.
13define i32 @fn2() local_unnamed_addr {
14; TUNIT: Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn
15; TUNIT-LABEL: define {{[^@]+}}@fn2
16; TUNIT-SAME: () local_unnamed_addr #[[ATTR0:[0-9]+]] {
17; TUNIT-NEXT:    [[TMP1:%.*]] = load i32, ptr @b, align 4
18; TUNIT-NEXT:    [[TMP2:%.*]] = sext i32 [[TMP1]] to i64
19; TUNIT-NEXT:    [[TMP3:%.*]] = inttoptr i64 [[TMP2]] to ptr
20; TUNIT-NEXT:    call fastcc void @fn1(ptr nofree readonly align 4 captures(none) [[TMP3]]) #[[ATTR1:[0-9]+]]
21; TUNIT-NEXT:    ret i32 undef
22;
23; CGSCC: Function Attrs: mustprogress nofree nosync nounwind willreturn
24; CGSCC-LABEL: define {{[^@]+}}@fn2
25; CGSCC-SAME: () local_unnamed_addr #[[ATTR0:[0-9]+]] {
26; CGSCC-NEXT:    [[TMP1:%.*]] = load i32, ptr @b, align 4
27; CGSCC-NEXT:    [[TMP2:%.*]] = sext i32 [[TMP1]] to i64
28; CGSCC-NEXT:    [[TMP3:%.*]] = inttoptr i64 [[TMP2]] to ptr
29; CGSCC-NEXT:    call fastcc void @fn1(ptr nofree nonnull readonly align 4 captures(none) [[TMP3]]) #[[ATTR2:[0-9]+]]
30; CGSCC-NEXT:    ret i32 undef
31;
32  %1 = load i32, ptr @b, align 4
33  %2 = sext i32 %1 to i64
34  %3 = inttoptr i64 %2 to ptr
35  call fastcc void @fn1(ptr %3)
36  ret i32 undef
37}
38
39define internal fastcc void @fn1(ptr nocapture readonly) unnamed_addr {
40; TUNIT: Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn
41; TUNIT-LABEL: define {{[^@]+}}@fn1
42; TUNIT-SAME: (ptr nofree nonnull readonly align 4 captures(none) [[TMP0:%.*]]) unnamed_addr #[[ATTR0]] {
43; TUNIT-NEXT:    [[TMP2:%.*]] = getelementptr inbounds i32, ptr [[TMP0]], i64 -1
44; TUNIT-NEXT:    [[TMP3:%.*]] = load i32, ptr [[TMP2]], align 4
45; TUNIT-NEXT:    store i32 [[TMP3]], ptr @a, align 4
46; TUNIT-NEXT:    ret void
47;
48; CGSCC: Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn
49; CGSCC-LABEL: define {{[^@]+}}@fn1
50; CGSCC-SAME: (ptr nofree nonnull readonly align 4 captures(none) [[TMP0:%.*]]) unnamed_addr #[[ATTR1:[0-9]+]] {
51; CGSCC-NEXT:    [[TMP2:%.*]] = getelementptr inbounds i32, ptr [[TMP0]], i64 -1
52; CGSCC-NEXT:    [[TMP3:%.*]] = load i32, ptr [[TMP2]], align 4
53; CGSCC-NEXT:    store i32 [[TMP3]], ptr @a, align 4
54; CGSCC-NEXT:    ret void
55;
56  %2 = getelementptr inbounds i32, ptr %0, i64 -1
57  %3 = load i32, ptr %2, align 4
58  store i32 %3, ptr @a, align 4
59  ret void
60}
61;.
62; TUNIT: attributes #[[ATTR0]] = { mustprogress nofree norecurse nosync nounwind willreturn }
63; TUNIT: attributes #[[ATTR1]] = { nofree nosync nounwind willreturn }
64;.
65; CGSCC: attributes #[[ATTR0]] = { mustprogress nofree nosync nounwind willreturn }
66; CGSCC: attributes #[[ATTR1]] = { mustprogress nofree norecurse nosync nounwind willreturn }
67; CGSCC: attributes #[[ATTR2]] = { nofree nounwind willreturn }
68;.
69;; NOTE: These prefixes are unused and the list is autogenerated. Do not add tests below this line:
70; CHECK: {{.*}}
71