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
6 ; This test tries to convince CHECK about promoting the load from %A + 2,
7 ; because there is a load of %A in the entry block
8 define internal i32 @callee(i1 %C, ptr %A) {
10 ; CHECK: Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: read)
11 ; CHECK-LABEL: define {{[^@]+}}@callee
12 ; CHECK-SAME: (ptr nocapture nofree noundef nonnull readonly align 4 dereferenceable(4) [[A:%.*]]) #[[ATTR0:[0-9]+]] {
14 ; CHECK-NEXT: [[A_0:%.*]] = load i32, ptr [[A]], align 4
15 ; CHECK-NEXT: br label [[F:%.*]]
17 ; CHECK-NEXT: unreachable
19 ; CHECK-NEXT: [[A_2:%.*]] = getelementptr i32, ptr [[A]], i32 2
20 ; CHECK-NEXT: [[R:%.*]] = load i32, ptr [[A_2]], align 4
21 ; CHECK-NEXT: ret i32 [[R]]
24 ; Unconditonally load the element at %A
25 %A.0 = load i32, ptr %A
26 br i1 %C, label %T, label %F
32 ; Load the element at offset two from %A. This should not be promoted!
33 %A.2 = getelementptr i32, ptr %A, i32 2
34 %R = load i32, ptr %A.2
38 define i32 @foo(ptr %A) {
39 ; TUNIT: Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: read)
40 ; TUNIT-LABEL: define {{[^@]+}}@foo
41 ; TUNIT-SAME: (ptr nocapture nofree readonly [[A:%.*]]) #[[ATTR0]] {
42 ; TUNIT-NEXT: [[X:%.*]] = call i32 @callee(ptr nocapture nofree noundef readonly align 4 [[A]]) #[[ATTR1:[0-9]+]]
43 ; TUNIT-NEXT: ret i32 [[X]]
45 ; CGSCC: Function Attrs: mustprogress nofree nosync nounwind willreturn memory(argmem: read)
46 ; CGSCC-LABEL: define {{[^@]+}}@foo
47 ; CGSCC-SAME: (ptr nocapture nofree noundef nonnull readonly align 4 dereferenceable(4) [[A:%.*]]) #[[ATTR1:[0-9]+]] {
48 ; CGSCC-NEXT: [[X:%.*]] = call i32 @callee(ptr nocapture nofree noundef nonnull readonly align 4 dereferenceable(4) [[A]]) #[[ATTR2:[0-9]+]]
49 ; CGSCC-NEXT: ret i32 [[X]]
51 %X = call i32 @callee(i1 false, ptr %A) ; <i32> [#uses=1]
56 ; TUNIT: attributes #[[ATTR0]] = { mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: read) }
57 ; TUNIT: attributes #[[ATTR1]] = { nofree nosync nounwind willreturn memory(read) }
59 ; CGSCC: attributes #[[ATTR0]] = { mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: read) }
60 ; CGSCC: attributes #[[ATTR1]] = { mustprogress nofree nosync nounwind willreturn memory(argmem: read) }
61 ; CGSCC: attributes #[[ATTR2]] = { nofree willreturn memory(read) }