xref: /llvm-project/llvm/test/Transforms/Attributor/ArgumentPromotion/control-flow2.ll (revision ae6ad31763eb01f2a8ae075c6fe4f6787d18da79)
19c2074dcSJohannes Doerfert; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --function-signature --check-attributes --check-globals
223dafbb1SJohannes Doerfert; RUN: opt -aa-pipeline=basic-aa -passes=attributor -attributor-manifest-internal  -attributor-annotate-decl-cs  -S < %s | FileCheck %s --check-prefixes=CHECK,TUNIT
3846709b2SNikita Popov; RUN: opt -aa-pipeline=basic-aa -passes=attributor-cgscc -attributor-manifest-internal  -attributor-annotate-decl-cs -S < %s | FileCheck %s --check-prefixes=CHECK,CGSCC
46cc2b1d7SJohannes Doerfert
56cc2b1d7SJohannes Doerferttarget 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"
66cc2b1d7SJohannes Doerfert
74f4787e3SNikita Popovdefine internal i32 @callee(i1 %C, ptr %P) {
8*ae6ad317SJohannes Doerfert; CGSCC: Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(none)
9846709b2SNikita Popov; CGSCC-LABEL: define {{[^@]+}}@callee
10846709b2SNikita Popov; CGSCC-SAME: (i32 [[TMP0:%.*]]) #[[ATTR0:[0-9]+]] {
11846709b2SNikita Popov; CGSCC-NEXT:    [[P_PRIV:%.*]] = alloca i32, align 4
124f4787e3SNikita Popov; CGSCC-NEXT:    store i32 [[TMP0]], ptr [[P_PRIV]], align 4
13846709b2SNikita Popov; CGSCC-NEXT:    br label [[F:%.*]]
14846709b2SNikita Popov; CGSCC:       T:
15846709b2SNikita Popov; CGSCC-NEXT:    unreachable
16846709b2SNikita Popov; CGSCC:       F:
174f4787e3SNikita Popov; CGSCC-NEXT:    [[X:%.*]] = load i32, ptr [[P_PRIV]], align 4
18846709b2SNikita Popov; CGSCC-NEXT:    ret i32 [[X]]
196cc2b1d7SJohannes Doerfert;
206cc2b1d7SJohannes Doerfert  br i1 %C, label %T, label %F
216cc2b1d7SJohannes Doerfert
226cc2b1d7SJohannes DoerfertT:              ; preds = %0
236cc2b1d7SJohannes Doerfert  ret i32 17
246cc2b1d7SJohannes Doerfert
256cc2b1d7SJohannes DoerfertF:              ; preds = %0
264f4787e3SNikita Popov  %X = load i32, ptr %P               ; <i32> [#uses=1]
276cc2b1d7SJohannes Doerfert  ret i32 %X
286cc2b1d7SJohannes Doerfert}
296cc2b1d7SJohannes Doerfert
306cc2b1d7SJohannes Doerfertdefine i32 @foo() {
31dbbe9b37SJohannes Doerfert; TUNIT: Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(none)
32846709b2SNikita Popov; TUNIT-LABEL: define {{[^@]+}}@foo
33846709b2SNikita Popov; TUNIT-SAME: () #[[ATTR0:[0-9]+]] {
34846709b2SNikita Popov; TUNIT-NEXT:    [[A:%.*]] = alloca i32, align 4
35846709b2SNikita Popov; TUNIT-NEXT:    ret i32 17
36e87f10a7SJohannes Doerfert;
37dbbe9b37SJohannes Doerfert; CGSCC: Function Attrs: mustprogress nofree nosync nounwind willreturn memory(none)
38846709b2SNikita Popov; CGSCC-LABEL: define {{[^@]+}}@foo
39846709b2SNikita Popov; CGSCC-SAME: () #[[ATTR1:[0-9]+]] {
40b672c602SJohannes Doerfert; CGSCC-NEXT:    [[X:%.*]] = call i32 @callee(i32 noundef 17) #[[ATTR2:[0-9]+]]
41846709b2SNikita Popov; CGSCC-NEXT:    ret i32 [[X]]
426cc2b1d7SJohannes Doerfert;
434f4787e3SNikita Popov  %A = alloca i32         ; <ptr> [#uses=2]
444f4787e3SNikita Popov  store i32 17, ptr %A
454f4787e3SNikita Popov  %X = call i32 @callee( i1 false, ptr %A )              ; <i32> [#uses=1]
466cc2b1d7SJohannes Doerfert  ret i32 %X
476cc2b1d7SJohannes Doerfert}
486cc2b1d7SJohannes Doerfert
499c2074dcSJohannes Doerfert;.
50dbbe9b37SJohannes Doerfert; TUNIT: attributes #[[ATTR0]] = { mustprogress nofree norecurse nosync nounwind willreturn memory(none) }
51e87f10a7SJohannes Doerfert;.
52*ae6ad317SJohannes Doerfert; CGSCC: attributes #[[ATTR0]] = { mustprogress nofree norecurse nosync nounwind willreturn memory(none) }
53dbbe9b37SJohannes Doerfert; CGSCC: attributes #[[ATTR1]] = { mustprogress nofree nosync nounwind willreturn memory(none) }
54*ae6ad317SJohannes Doerfert; CGSCC: attributes #[[ATTR2]] = { nofree nosync willreturn }
559c2074dcSJohannes Doerfert;.
5623333bb6SJohannes Doerfert;; NOTE: These prefixes are unused and the list is autogenerated. Do not add tests below this line:
5723333bb6SJohannes Doerfert; CHECK: {{.*}}
58