1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --function-signature --check-attributes --check-globals
2 ; RUN: opt -attributor -enable-new-pm=0 -attributor-manifest-internal -attributor-max-iterations-verify -attributor-annotate-decl-cs -attributor-max-iterations=1 -S < %s | FileCheck %s --check-prefixes=CHECK,NOT_CGSCC_NPM,NOT_CGSCC_OPM,NOT_TUNIT_NPM,IS__TUNIT____,IS________OPM,IS__TUNIT_OPM
3 ; RUN: opt -aa-pipeline=basic-aa -passes=attributor -attributor-manifest-internal -attributor-max-iterations-verify -attributor-annotate-decl-cs -attributor-max-iterations=1 -S < %s | FileCheck %s --check-prefixes=CHECK,NOT_CGSCC_OPM,NOT_CGSCC_NPM,NOT_TUNIT_OPM,IS__TUNIT____,IS________NPM,IS__TUNIT_NPM
4 ; 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
5 ; 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
8 ; This test tries to convince CHECK about promoting the load from %A + 2,
9 ; because there is a load of %A in the entry block
10 define internal i32 @callee(i1 %C, i32* %A) {
12 ; IS__TUNIT____: Function Attrs: argmemonly nofree nosync nounwind readonly willreturn
13 ; IS__TUNIT____-LABEL: define {{[^@]+}}@callee
14 ; IS__TUNIT____-SAME: (i32* nocapture nofree noundef nonnull readonly align 4 dereferenceable(4) [[A:%.*]]) #[[ATTR0:[0-9]+]] {
15 ; IS__TUNIT____-NEXT: entry:
16 ; IS__TUNIT____-NEXT: [[A_0:%.*]] = load i32, i32* [[A]], align 4
17 ; IS__TUNIT____-NEXT: br label [[F:%.*]]
19 ; IS__TUNIT____-NEXT: unreachable
21 ; IS__TUNIT____-NEXT: [[A_2:%.*]] = getelementptr i32, i32* [[A]], i32 2
22 ; IS__TUNIT____-NEXT: [[R:%.*]] = load i32, i32* [[A_2]], align 4
23 ; IS__TUNIT____-NEXT: ret i32 [[R]]
25 ; IS__CGSCC____: Function Attrs: argmemonly nofree norecurse nosync nounwind readonly willreturn
26 ; IS__CGSCC____-LABEL: define {{[^@]+}}@callee
27 ; IS__CGSCC____-SAME: (i32* nocapture nofree noundef nonnull readonly align 4 dereferenceable(4) [[A:%.*]]) #[[ATTR0:[0-9]+]] {
28 ; IS__CGSCC____-NEXT: entry:
29 ; IS__CGSCC____-NEXT: [[A_0:%.*]] = load i32, i32* [[A]], align 4
30 ; IS__CGSCC____-NEXT: br label [[F:%.*]]
32 ; IS__CGSCC____-NEXT: unreachable
34 ; IS__CGSCC____-NEXT: [[A_2:%.*]] = getelementptr i32, i32* [[A]], i32 2
35 ; IS__CGSCC____-NEXT: [[R:%.*]] = load i32, i32* [[A_2]], align 4
36 ; IS__CGSCC____-NEXT: ret i32 [[R]]
39 ; Unconditonally load the element at %A
40 %A.0 = load i32, i32* %A
41 br i1 %C, label %T, label %F
47 ; Load the element at offset two from %A. This should not be promoted!
48 %A.2 = getelementptr i32, i32* %A, i32 2
49 %R = load i32, i32* %A.2
53 define i32 @foo(i32* %A) {
54 ; IS__TUNIT____: Function Attrs: argmemonly nofree nosync nounwind readonly willreturn
55 ; IS__TUNIT____-LABEL: define {{[^@]+}}@foo
56 ; IS__TUNIT____-SAME: (i32* nocapture nofree readonly [[A:%.*]]) #[[ATTR0]] {
57 ; IS__TUNIT____-NEXT: [[X:%.*]] = call i32 @callee(i32* nocapture nofree readonly align 4 [[A]]) #[[ATTR1:[0-9]+]]
58 ; IS__TUNIT____-NEXT: ret i32 [[X]]
60 ; IS__CGSCC____: Function Attrs: argmemonly nofree norecurse nosync nounwind readonly willreturn
61 ; IS__CGSCC____-LABEL: define {{[^@]+}}@foo
62 ; IS__CGSCC____-SAME: (i32* nocapture nofree noundef nonnull readonly align 4 dereferenceable(4) [[A:%.*]]) #[[ATTR0]] {
63 ; IS__CGSCC____-NEXT: [[X:%.*]] = call i32 @callee(i32* nocapture nofree noundef nonnull readonly align 4 dereferenceable(4) [[A]]) #[[ATTR1:[0-9]+]]
64 ; IS__CGSCC____-NEXT: ret i32 [[X]]
66 %X = call i32 @callee(i1 false, i32* %A) ; <i32> [#uses=1]
71 ; IS__TUNIT____: attributes #[[ATTR0]] = { argmemonly nofree nosync nounwind readonly willreturn }
72 ; IS__TUNIT____: attributes #[[ATTR1]] = { nofree nosync nounwind readonly willreturn }
74 ; IS__CGSCC____: attributes #[[ATTR0]] = { argmemonly nofree norecurse nosync nounwind readonly willreturn }
75 ; IS__CGSCC____: attributes #[[ATTR1]] = { nosync nounwind readonly willreturn }