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
5 declare void @unknown()
10 ; CHECK-LABEL: define {{[^@]+}}@foo() {
11 ; CHECK-NEXT: [[X:%.*]] = alloca i32, align 4
12 ; CHECK-NEXT: call void @unknown()
13 ; CHECK-NEXT: call void @bar(ptr noundef nonnull align 4 dereferenceable(4) [[X]])
14 ; CHECK-NEXT: ret void
18 call void @bar(ptr %x)
22 define internal ptr @returned_dead() {
23 ; CHECK-LABEL: define {{[^@]+}}@returned_dead() {
24 ; CHECK-NEXT: call void @unknown()
25 ; CHECK-NEXT: ret ptr undef
31 define void @caller1() {
32 ; CHECK-LABEL: define {{[^@]+}}@caller1() {
33 ; CHECK-NEXT: [[TMP1:%.*]] = call ptr @returned_dead()
34 ; CHECK-NEXT: ret void
36 call ptr @returned_dead()
40 define internal void @argument_dead_callback_callee(ptr %c) {
41 ; CHECK-LABEL: define {{[^@]+}}@argument_dead_callback_callee
42 ; CHECK-SAME: (ptr noalias nocapture nofree readnone align 4294967296 [[C:%.*]]) {
43 ; CHECK-NEXT: call void @unknown()
44 ; CHECK-NEXT: ret void
50 define void @callback_caller() {
51 ; TUNIT-LABEL: define {{[^@]+}}@callback_caller() {
52 ; TUNIT-NEXT: call void @callback_broker(ptr noundef nonnull @argument_dead_callback_callee, ptr nofree readnone align 4294967296 undef)
53 ; TUNIT-NEXT: ret void
55 ; CGSCC-LABEL: define {{[^@]+}}@callback_caller() {
56 ; CGSCC-NEXT: call void @callback_broker(ptr noundef nonnull @argument_dead_callback_callee, ptr nofree noundef readnone align 4294967296 null)
57 ; CGSCC-NEXT: ret void
59 call void @callback_broker(ptr @argument_dead_callback_callee, ptr null)
63 ; Drop the noundef if when we replace the call argument with `undef`. We use a
64 ; varargs function as we cannot (yet) rewrite their signature. If we ever can,
65 ; try to come up with a different scheme to verify the `noundef` is dropped if
66 ; signature rewriting is not happening.
67 define internal void @callee_with_dead_noundef_arg(i1 noundef %create, ...) {
68 ; TUNIT-LABEL: define {{[^@]+}}@callee_with_dead_noundef_arg
69 ; TUNIT-SAME: (i1 [[CREATE:%.*]], ...) {
70 ; TUNIT-NEXT: call void @unknown()
71 ; TUNIT-NEXT: ret void
73 ; CGSCC-LABEL: define {{[^@]+}}@callee_with_dead_noundef_arg
74 ; CGSCC-SAME: (i1 noundef [[CREATE:%.*]], ...) {
75 ; CGSCC-NEXT: call void @unknown()
76 ; CGSCC-NEXT: ret void
82 define void @caller_with_unused_arg(i1 %c) {
83 ; TUNIT-LABEL: define {{[^@]+}}@caller_with_unused_arg
84 ; TUNIT-SAME: (i1 noundef [[C:%.*]]) {
85 ; TUNIT-NEXT: call void (i1, ...) @callee_with_dead_noundef_arg(i1 undef)
86 ; TUNIT-NEXT: ret void
88 ; CGSCC-LABEL: define {{[^@]+}}@caller_with_unused_arg
89 ; CGSCC-SAME: (i1 noundef [[C:%.*]]) {
90 ; CGSCC-NEXT: call void (i1, ...) @callee_with_dead_noundef_arg(i1 noundef [[C]])
91 ; CGSCC-NEXT: ret void
93 call void (i1, ...) @callee_with_dead_noundef_arg(i1 %c)
97 define internal void @callee_with_dead_arg(i1 %create, ...) {
99 ; TUNIT-LABEL: define {{[^@]+}}@callee_with_dead_arg
100 ; TUNIT-SAME: (i1 [[CREATE:%.*]], ...) {
102 ; TUNIT-NEXT: br label [[IF_THEN3:%.*]]
104 ; TUNIT-NEXT: unreachable
106 ; TUNIT-NEXT: call void @unknown()
107 ; TUNIT-NEXT: ret void
109 ; CGSCC-LABEL: define {{[^@]+}}@callee_with_dead_arg
110 ; CGSCC-SAME: (i1 noundef [[CREATE:%.*]], ...) {
112 ; CGSCC-NEXT: br label [[IF_THEN3:%.*]]
114 ; CGSCC-NEXT: unreachable
116 ; CGSCC-NEXT: call void @unknown()
117 ; CGSCC-NEXT: ret void
120 br i1 %create, label %if.then3, label %if.then
122 if.then: ; preds = %entry
125 if.then3: ; preds = %entry
130 ; Drop the noundef if when we replace the call argument with `undef`. We use a
131 ; varargs function as we cannot (yet) rewrite their signature. If we ever can,
132 ; try to come up with a different scheme to verify the `noundef` is dropped if
133 ; signature rewriting is not happening.
134 define void @caller_with_noundef_arg() {
136 ; TUNIT-LABEL: define {{[^@]+}}@caller_with_noundef_arg() {
137 ; TUNIT-NEXT: call void (i1, ...) @callee_with_dead_arg(i1 undef)
138 ; TUNIT-NEXT: ret void
140 ; CGSCC-LABEL: define {{[^@]+}}@caller_with_noundef_arg() {
141 ; CGSCC-NEXT: call void (i1, ...) @callee_with_dead_arg(i1 noundef true)
142 ; CGSCC-NEXT: ret void
144 call void (i1, ...) @callee_with_dead_arg(i1 noundef true)
148 declare !callback !0 void @callback_broker(ptr, ptr)
149 !1 = !{i64 0, i64 1, i1 false}
152 ; TUNIT: [[META0:![0-9]+]] = !{[[META1:![0-9]+]]}
153 ; TUNIT: [[META1]] = !{i64 0, i64 1, i1 false}
155 ; CGSCC: [[META0:![0-9]+]] = !{[[META1:![0-9]+]]}
156 ; CGSCC: [[META1]] = !{i64 0, i64 1, i1 false}