[llvm] 2dc45bf - [ArgPromotion] Add test for non-willreturn load hoisting (NFC)

Nikita Popov via llvm-commits llvm-commits at lists.llvm.org
Fri Jan 28 07:08:51 PST 2022


Author: Nikita Popov
Date: 2022-01-28T16:08:42+01:00
New Revision: 2dc45bf4de9c8af87c019ae958a842f3c9f118fb

URL: https://github.com/llvm/llvm-project/commit/2dc45bf4de9c8af87c019ae958a842f3c9f118fb
DIFF: https://github.com/llvm/llvm-project/commit/2dc45bf4de9c8af87c019ae958a842f3c9f118fb.diff

LOG: [ArgPromotion] Add test for non-willreturn load hoisting (NFC)

In this case, we have no guarantee that the load is unconditionally
executed, so the argument promotion is not legal.

Added: 
    llvm/test/Transforms/ArgumentPromotion/load-after-non-willreturn-call.ll

Modified: 
    

Removed: 
    


################################################################################
diff  --git a/llvm/test/Transforms/ArgumentPromotion/load-after-non-willreturn-call.ll b/llvm/test/Transforms/ArgumentPromotion/load-after-non-willreturn-call.ll
new file mode 100644
index 0000000000000..04a0cbcb27746
--- /dev/null
+++ b/llvm/test/Transforms/ArgumentPromotion/load-after-non-willreturn-call.ll
@@ -0,0 +1,26 @@
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --function-signature --scrub-attributes
+; RUN: opt -S -argpromotion < %s | FileCheck %s
+
+declare void @may_not_return()
+
+define internal i32 @callee(i32* %p) {
+; CHECK-LABEL: define {{[^@]+}}@callee
+; CHECK-SAME: (i32 [[P_VAL:%.*]]) {
+; CHECK-NEXT:    call void @may_not_return()
+; CHECK-NEXT:    ret i32 [[P_VAL]]
+;
+  call void @may_not_return() readnone
+  %x = load i32, i32* %p
+  ret i32 %x
+}
+
+define void @caller(i32* %p) {
+; CHECK-LABEL: define {{[^@]+}}@caller
+; CHECK-SAME: (i32* [[P:%.*]]) {
+; CHECK-NEXT:    [[P_VAL:%.*]] = load i32, i32* [[P]], align 4
+; CHECK-NEXT:    [[TMP1:%.*]] = call i32 @callee(i32 [[P_VAL]])
+; CHECK-NEXT:    ret void
+;
+  call i32 @callee(i32* %p)
+  ret void
+}


        


More information about the llvm-commits mailing list