xref: /llvm-project/llvm/test/Transforms/Attributor/ArgumentPromotion/chained.ll (revision cd3a4c31bc9694d160de54c6a4daa53e152cb463)
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
5@G1 = constant i32 0
6@G2 = constant ptr @G1
7
8;.
9; CHECK: @G1 = constant i32 0
10; CHECK: @G2 = constant ptr @G1
11;.
12define internal i32 @test(ptr %x) {
13;
14; CHECK: Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(none)
15; CHECK-LABEL: define {{[^@]+}}@test
16; CHECK-SAME: () #[[ATTR0:[0-9]+]] {
17; CHECK-NEXT:  entry:
18; CHECK-NEXT:    [[Z:%.*]] = load i32, ptr @G1, align 4
19; CHECK-NEXT:    ret i32 [[Z]]
20;
21entry:
22  %y = load ptr, ptr %x
23  %z = load i32, ptr %y
24  ret i32 %z
25}
26
27define i32 @caller() {
28; TUNIT: Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(none)
29; TUNIT-LABEL: define {{[^@]+}}@caller
30; TUNIT-SAME: () #[[ATTR0]] {
31; TUNIT-NEXT:  entry:
32; TUNIT-NEXT:    [[X:%.*]] = call i32 @test() #[[ATTR1:[0-9]+]]
33; TUNIT-NEXT:    ret i32 [[X]]
34;
35; CGSCC: Function Attrs: mustprogress nofree nosync nounwind willreturn memory(none)
36; CGSCC-LABEL: define {{[^@]+}}@caller
37; CGSCC-SAME: () #[[ATTR1:[0-9]+]] {
38; CGSCC-NEXT:  entry:
39; CGSCC-NEXT:    [[X:%.*]] = call i32 @test() #[[ATTR2:[0-9]+]]
40; CGSCC-NEXT:    ret i32 [[X]]
41;
42entry:
43  %x = call i32 @test(ptr @G2)
44  ret i32 %x
45}
46
47;.
48; TUNIT: attributes #[[ATTR0]] = { mustprogress nofree norecurse nosync nounwind willreturn memory(none) }
49; TUNIT: attributes #[[ATTR1]] = { nofree nosync nounwind willreturn memory(read) }
50;.
51; CGSCC: attributes #[[ATTR0]] = { mustprogress nofree norecurse nosync nounwind willreturn memory(none) }
52; CGSCC: attributes #[[ATTR1]] = { mustprogress nofree nosync nounwind willreturn memory(none) }
53; CGSCC: attributes #[[ATTR2]] = { nofree nosync willreturn }
54;.
55