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
7 declare void @unknown()
9 declare void @bar(i32*)
12 ; CHECK-LABEL: define {{[^@]+}}@foo() {
13 ; CHECK-NEXT: [[X:%.*]] = alloca i32, align 4
14 ; CHECK-NEXT: call void @unknown()
15 ; CHECK-NEXT: call void @bar(i32* noundef nonnull align 4 dereferenceable(4) [[X]])
16 ; CHECK-NEXT: ret void
20 call void @bar(i32* %x)
24 define internal i8* @returned_dead() {
25 ; CHECK-LABEL: define {{[^@]+}}@returned_dead() {
26 ; CHECK-NEXT: call void @unknown()
27 ; CHECK-NEXT: ret i8* undef
33 define void @caller1() {
34 ; CHECK-LABEL: define {{[^@]+}}@caller1() {
35 ; CHECK-NEXT: [[TMP1:%.*]] = call i8* @returned_dead()
36 ; CHECK-NEXT: ret void
38 call i8* @returned_dead()
42 define internal void @argument_dead_callback_callee(i8* %c) {
43 ; CHECK-LABEL: define {{[^@]+}}@argument_dead_callback_callee
44 ; CHECK-SAME: (i8* noalias nocapture nofree readnone align 536870912 [[C:%.*]]) {
45 ; CHECK-NEXT: call void @unknown()
46 ; CHECK-NEXT: ret void
52 define void @callback_caller() {
53 ; IS__TUNIT____-LABEL: define {{[^@]+}}@callback_caller() {
54 ; IS__TUNIT____-NEXT: call void @callback_broker(void (i8*)* noundef @argument_dead_callback_callee, i8* noalias nocapture nofree readnone align 536870912 undef)
55 ; IS__TUNIT____-NEXT: ret void
57 ; IS__CGSCC____-LABEL: define {{[^@]+}}@callback_caller() {
58 ; IS__CGSCC____-NEXT: call void @callback_broker(void (i8*)* noundef @argument_dead_callback_callee, i8* noalias nocapture nofree noundef readnone align 536870912 null)
59 ; IS__CGSCC____-NEXT: ret void
61 call void @callback_broker(void (i8*)* @argument_dead_callback_callee, i8* null)
65 ; Drop the noundef if when we replace the call argument with `undef`. We use a
66 ; varargs function as we cannot (yet) rewrite their signature. If we ever can,
67 ; try to come up with a different scheme to verify the `noundef` is dropped if
68 ; signature rewriting is not happening.
69 define internal void @callee_with_dead_noundef_arg(i1 noundef %create, ...) {
70 ; CHECK-LABEL: define {{[^@]+}}@callee_with_dead_noundef_arg
71 ; CHECK-SAME: (i1 [[CREATE:%.*]], ...) {
72 ; CHECK-NEXT: call void @unknown()
73 ; CHECK-NEXT: ret void
79 define void @caller_with_unused_arg(i1 %c) {
80 ; CHECK-LABEL: define {{[^@]+}}@caller_with_unused_arg
81 ; CHECK-SAME: (i1 [[C:%.*]]) {
82 ; CHECK-NEXT: call void (i1, ...) @callee_with_dead_noundef_arg(i1 undef)
83 ; CHECK-NEXT: ret void
85 call void (i1, ...) @callee_with_dead_noundef_arg(i1 %c)
89 define internal void @callee_with_dead_arg(i1 %create, ...) {
91 ; CHECK-LABEL: define {{[^@]+}}@callee_with_dead_arg
92 ; CHECK-SAME: (i1 [[CREATE:%.*]], ...) {
94 ; CHECK-NEXT: br label [[IF_THEN3:%.*]]
96 ; CHECK-NEXT: unreachable
98 ; CHECK-NEXT: call void @unknown()
99 ; CHECK-NEXT: ret void
102 br i1 %create, label %if.then3, label %if.then
104 if.then: ; preds = %entry
107 if.then3: ; preds = %entry
112 ; Drop the noundef if when we replace the call argument with `undef`. We use a
113 ; varargs function as we cannot (yet) rewrite their signature. If we ever can,
114 ; try to come up with a different scheme to verify the `noundef` is dropped if
115 ; signature rewriting is not happening.
116 define void @caller_with_noundef_arg() {
118 ; CHECK-LABEL: define {{[^@]+}}@caller_with_noundef_arg() {
119 ; CHECK-NEXT: call void (i1, ...) @callee_with_dead_arg(i1 undef)
120 ; CHECK-NEXT: ret void
122 call void (i1, ...) @callee_with_dead_arg(i1 noundef true)
126 declare !callback !0 void @callback_broker(void (i8*)*, i8*)
127 !1 = !{i64 0, i64 1, i1 false}
130 ; CHECK: [[META0:![0-9]+]] = !{!1}
131 ; CHECK: [[META1:![0-9]+]] = !{i64 0, i64 1, i1 false}