1; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --function-signature --check-attributes
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
6
7declare void @unknown()
8
9declare void @bar(i32*)
10
11define void @foo() {
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
17;
18  %x = alloca i32
19  call void @unknown()
20  call void @bar(i32* %x)
21  ret void
22}
23
24define internal i8* @returned_dead() {
25; CHECK-LABEL: define {{[^@]+}}@returned_dead() {
26; CHECK-NEXT:    call void @unknown()
27; CHECK-NEXT:    ret i8* undef
28;
29  call void @unknown()
30  ret i8* null
31}
32
33define void @caller1() {
34; CHECK-LABEL: define {{[^@]+}}@caller1() {
35; CHECK-NEXT:    [[TMP1:%.*]] = call i8* @returned_dead()
36; CHECK-NEXT:    ret void
37;
38  call i8* @returned_dead()
39  ret void
40}
41
42define 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
47;
48  call void @unknown()
49  ret void
50}
51
52define 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
56;
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
60;
61  call void @callback_broker(void (i8*)* @argument_dead_callback_callee, i8* null)
62  ret void
63}
64
65declare !callback !0 void @callback_broker(void (i8*)*, i8*)
66!1 = !{i64 0, i64 1, i1 false}
67!0 = !{!1}
68