xref: /llvm-project/llvm/test/Transforms/ArgumentPromotion/load-after-non-willreturn-call.ll (revision bcbc6151640f53e9d78392c66de9760c664d8b1d)
1; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --function-signature --scrub-attributes
2; RUN: opt -S -passes=argpromotion < %s | FileCheck %s
3
4declare void @may_not_return()
5
6; The argument cannot be promoted, as we do not know whether the load can be
7; speculatively executed.
8
9define internal i32 @callee(ptr %p) {
10; CHECK-LABEL: define {{[^@]+}}@callee
11; CHECK-SAME: (ptr [[P:%.*]]) {
12; CHECK-NEXT:    call void @may_not_return()
13; CHECK-NEXT:    [[X:%.*]] = load i32, ptr [[P]], align 4
14; CHECK-NEXT:    ret i32 [[X]]
15;
16  call void @may_not_return() readnone
17  %x = load i32, ptr %p
18  ret i32 %x
19}
20
21define void @caller(ptr %p) {
22; CHECK-LABEL: define {{[^@]+}}@caller
23; CHECK-SAME: (ptr [[P:%.*]]) {
24; CHECK-NEXT:    [[TMP1:%.*]] = call i32 @callee(ptr [[P]])
25; CHECK-NEXT:    ret void
26;
27  call i32 @callee(ptr %p)
28  ret void
29}
30