xref: /llvm-project/llvm/test/Transforms/Attributor/ArgumentPromotion/control-flow2.ll (revision ae6ad31763eb01f2a8ae075c6fe4f6787d18da79)
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
4
5target datalayout = "E-p:64:64:64-a0:0:8-f32:32:32-f64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-v64:64:64-v128:128:128"
6
7define internal i32 @callee(i1 %C, ptr %P) {
8; CGSCC: Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(none)
9; CGSCC-LABEL: define {{[^@]+}}@callee
10; CGSCC-SAME: (i32 [[TMP0:%.*]]) #[[ATTR0:[0-9]+]] {
11; CGSCC-NEXT:    [[P_PRIV:%.*]] = alloca i32, align 4
12; CGSCC-NEXT:    store i32 [[TMP0]], ptr [[P_PRIV]], align 4
13; CGSCC-NEXT:    br label [[F:%.*]]
14; CGSCC:       T:
15; CGSCC-NEXT:    unreachable
16; CGSCC:       F:
17; CGSCC-NEXT:    [[X:%.*]] = load i32, ptr [[P_PRIV]], align 4
18; CGSCC-NEXT:    ret i32 [[X]]
19;
20  br i1 %C, label %T, label %F
21
22T:              ; preds = %0
23  ret i32 17
24
25F:              ; preds = %0
26  %X = load i32, ptr %P               ; <i32> [#uses=1]
27  ret i32 %X
28}
29
30define i32 @foo() {
31; TUNIT: Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(none)
32; TUNIT-LABEL: define {{[^@]+}}@foo
33; TUNIT-SAME: () #[[ATTR0:[0-9]+]] {
34; TUNIT-NEXT:    [[A:%.*]] = alloca i32, align 4
35; TUNIT-NEXT:    ret i32 17
36;
37; CGSCC: Function Attrs: mustprogress nofree nosync nounwind willreturn memory(none)
38; CGSCC-LABEL: define {{[^@]+}}@foo
39; CGSCC-SAME: () #[[ATTR1:[0-9]+]] {
40; CGSCC-NEXT:    [[X:%.*]] = call i32 @callee(i32 noundef 17) #[[ATTR2:[0-9]+]]
41; CGSCC-NEXT:    ret i32 [[X]]
42;
43  %A = alloca i32         ; <ptr> [#uses=2]
44  store i32 17, ptr %A
45  %X = call i32 @callee( i1 false, ptr %A )              ; <i32> [#uses=1]
46  ret i32 %X
47}
48
49;.
50; TUNIT: attributes #[[ATTR0]] = { mustprogress nofree norecurse nosync nounwind willreturn memory(none) }
51;.
52; CGSCC: attributes #[[ATTR0]] = { mustprogress nofree norecurse nosync nounwind willreturn memory(none) }
53; CGSCC: attributes #[[ATTR1]] = { mustprogress nofree nosync nounwind willreturn memory(none) }
54; CGSCC: attributes #[[ATTR2]] = { nofree nosync willreturn }
55;.
56;; NOTE: These prefixes are unused and the list is autogenerated. Do not add tests below this line:
57; CHECK: {{.*}}
58