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=2 -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
7target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
8target triple = "x86_64-unknown-linux-gnu"
9
10define i64 @fn2() {
11;
12; IS__TUNIT____: Function Attrs: nofree nosync nounwind readnone willreturn
13; IS__TUNIT____-LABEL: define {{[^@]+}}@fn2
14; IS__TUNIT____-SAME: () #[[ATTR0:[0-9]+]] {
15; IS__TUNIT____-NEXT:  entry:
16; IS__TUNIT____-NEXT:    ret i64 poison
17;
18; IS__CGSCC____: Function Attrs: nofree norecurse nosync nounwind readnone willreturn
19; IS__CGSCC____-LABEL: define {{[^@]+}}@fn2
20; IS__CGSCC____-SAME: () #[[ATTR0:[0-9]+]] {
21; IS__CGSCC____-NEXT:  entry:
22; IS__CGSCC____-NEXT:    [[CONV:%.*]] = sext i32 undef to i64
23; IS__CGSCC____-NEXT:    [[DIV:%.*]] = sdiv i64 8, 0
24; IS__CGSCC____-NEXT:    ret i64 poison
25;
26entry:
27  %conv = sext i32 undef to i64
28  %div = sdiv i64 8, %conv
29  %call2 = call i64 @fn1(i64 %div)
30  ret i64 %call2
31}
32
33define i64 @fn2b(i32 %arg) {
34;
35; IS__TUNIT_OPM: Function Attrs: nofree nosync nounwind readnone willreturn
36; IS__TUNIT_OPM-LABEL: define {{[^@]+}}@fn2b
37; IS__TUNIT_OPM-SAME: (i32 [[ARG:%.*]]) #[[ATTR0]] {
38; IS__TUNIT_OPM-NEXT:  entry:
39; IS__TUNIT_OPM-NEXT:    [[CONV:%.*]] = sext i32 [[ARG]] to i64
40; IS__TUNIT_OPM-NEXT:    [[DIV:%.*]] = sdiv i64 8, [[CONV]]
41; IS__TUNIT_OPM-NEXT:    [[CALL2:%.*]] = call i64 @fn1(i64 [[DIV]]) #[[ATTR0]]
42; IS__TUNIT_OPM-NEXT:    ret i64 [[CALL2]]
43;
44; IS__TUNIT_NPM: Function Attrs: nofree nosync nounwind readnone willreturn
45; IS__TUNIT_NPM-LABEL: define {{[^@]+}}@fn2b
46; IS__TUNIT_NPM-SAME: (i32 [[ARG:%.*]]) #[[ATTR0]] {
47; IS__TUNIT_NPM-NEXT:  entry:
48; IS__TUNIT_NPM-NEXT:    [[CONV:%.*]] = sext i32 [[ARG]] to i64
49; IS__TUNIT_NPM-NEXT:    [[DIV:%.*]] = sdiv i64 8, [[CONV]]
50; IS__TUNIT_NPM-NEXT:    ret i64 [[DIV]]
51;
52; IS__CGSCC_OPM: Function Attrs: nofree norecurse nosync nounwind readnone willreturn
53; IS__CGSCC_OPM-LABEL: define {{[^@]+}}@fn2b
54; IS__CGSCC_OPM-SAME: (i32 [[ARG:%.*]]) #[[ATTR0]] {
55; IS__CGSCC_OPM-NEXT:  entry:
56; IS__CGSCC_OPM-NEXT:    [[CONV:%.*]] = sext i32 [[ARG]] to i64
57; IS__CGSCC_OPM-NEXT:    [[DIV:%.*]] = sdiv i64 8, [[CONV]]
58; IS__CGSCC_OPM-NEXT:    [[CALL2:%.*]] = call i64 @fn1(i64 [[DIV]]) #[[ATTR1:[0-9]+]]
59; IS__CGSCC_OPM-NEXT:    ret i64 [[CALL2]]
60;
61; IS__CGSCC_NPM: Function Attrs: nofree norecurse nosync nounwind readnone willreturn
62; IS__CGSCC_NPM-LABEL: define {{[^@]+}}@fn2b
63; IS__CGSCC_NPM-SAME: (i32 [[ARG:%.*]]) #[[ATTR0]] {
64; IS__CGSCC_NPM-NEXT:  entry:
65; IS__CGSCC_NPM-NEXT:    [[CONV:%.*]] = sext i32 [[ARG]] to i64
66; IS__CGSCC_NPM-NEXT:    [[DIV:%.*]] = sdiv i64 8, [[CONV]]
67; IS__CGSCC_NPM-NEXT:    ret i64 [[DIV]]
68;
69entry:
70  %conv = sext i32 %arg to i64
71  %div = sdiv i64 8, %conv
72  %call2 = call i64 @fn1(i64 %div)
73  ret i64 %call2
74}
75
76define i64 @fn2c() {
77; IS__TUNIT____: Function Attrs: nofree nosync nounwind readnone willreturn
78; IS__TUNIT____-LABEL: define {{[^@]+}}@fn2c
79; IS__TUNIT____-SAME: () #[[ATTR0]] {
80; IS__TUNIT____-NEXT:  entry:
81; IS__TUNIT____-NEXT:    ret i64 42
82;
83; IS__CGSCC_OPM: Function Attrs: nofree norecurse nosync nounwind readnone willreturn
84; IS__CGSCC_OPM-LABEL: define {{[^@]+}}@fn2c
85; IS__CGSCC_OPM-SAME: () #[[ATTR0]] {
86; IS__CGSCC_OPM-NEXT:  entry:
87; IS__CGSCC_OPM-NEXT:    ret i64 42
88;
89; IS__CGSCC_NPM: Function Attrs: nofree norecurse nosync nounwind readnone willreturn
90; IS__CGSCC_NPM-LABEL: define {{[^@]+}}@fn2c
91; IS__CGSCC_NPM-SAME: () #[[ATTR0]] {
92; IS__CGSCC_NPM-NEXT:  entry:
93; IS__CGSCC_NPM-NEXT:    [[CONV:%.*]] = sext i32 undef to i64
94; IS__CGSCC_NPM-NEXT:    ret i64 42
95;
96entry:
97  %conv = sext i32 undef to i64
98  %add = add i64 42, %conv
99  %call2 = call i64 @fn1(i64 %add)
100  ret i64 %call2
101}
102
103define internal i64 @fn1(i64 %p1) {
104; IS__TUNIT_OPM: Function Attrs: nofree nosync nounwind readnone willreturn
105; IS__TUNIT_OPM-LABEL: define {{[^@]+}}@fn1
106; IS__TUNIT_OPM-SAME: (i64 returned [[P1:%.*]]) #[[ATTR0]] {
107; IS__TUNIT_OPM-NEXT:  entry:
108; IS__TUNIT_OPM-NEXT:    ret i64 [[P1]]
109;
110; IS__CGSCC_OPM: Function Attrs: nofree norecurse nosync nounwind readnone willreturn
111; IS__CGSCC_OPM-LABEL: define {{[^@]+}}@fn1
112; IS__CGSCC_OPM-SAME: (i64 returned [[P1:%.*]]) #[[ATTR0]] {
113; IS__CGSCC_OPM-NEXT:  entry:
114; IS__CGSCC_OPM-NEXT:    ret i64 [[P1]]
115;
116; IS__CGSCC_NPM: Function Attrs: nofree norecurse nosync nounwind readnone willreturn
117; IS__CGSCC_NPM-LABEL: define {{[^@]+}}@fn1
118; IS__CGSCC_NPM-SAME: (i64 [[P1:%.*]]) #[[ATTR0]] {
119; IS__CGSCC_NPM-NEXT:  entry:
120; IS__CGSCC_NPM-NEXT:    ret i64 undef
121;
122entry:
123  %tobool = icmp ne i64 %p1, 0
124  %cond = select i1 %tobool, i64 %p1, i64 %p1
125  ret i64 %cond
126}
127;.
128; IS__TUNIT____: attributes #[[ATTR0]] = { nofree nosync nounwind readnone willreturn }
129;.
130; IS__CGSCC_OPM: attributes #[[ATTR0]] = { nofree norecurse nosync nounwind readnone willreturn }
131; IS__CGSCC_OPM: attributes #[[ATTR1]] = { readnone willreturn }
132;.
133; IS__CGSCC_NPM: attributes #[[ATTR0]] = { nofree norecurse nosync nounwind readnone willreturn }
134;.
135