[llvm] c7e69e4 - [Tests] Add additional tests for incorrect willreturn handling (NFC)
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Sat Jul 24 08:28:57 PDT 2021
Author: Nikita Popov
Date: 2021-07-24T17:27:29+02:00
New Revision: c7e69e46c86c3f3785441de45db4b7bc6d26e321
URL: https://github.com/llvm/llvm-project/commit/c7e69e46c86c3f3785441de45db4b7bc6d26e321
DIFF: https://github.com/llvm/llvm-project/commit/c7e69e46c86c3f3785441de45db4b7bc6d26e321.diff
LOG: [Tests] Add additional tests for incorrect willreturn handling (NFC)
Highlight a few of the places that don't handle non-willreturn
calls correctly right now.
Added:
Modified:
llvm/test/Transforms/LICM/sinking.ll
llvm/test/Transforms/LoopDeletion/noop-loops-with-subloops.ll
llvm/test/Transforms/SCCP/calltest.ll
Removed:
################################################################################
diff --git a/llvm/test/Transforms/LICM/sinking.ll b/llvm/test/Transforms/LICM/sinking.ll
index a9c0f45627a4e..ee7f6338e6ad6 100644
--- a/llvm/test/Transforms/LICM/sinking.ll
+++ b/llvm/test/Transforms/LICM/sinking.ll
@@ -979,6 +979,28 @@ try.cont:
ret void
}
+; TODO: Should not get sunk.
+define i32 @not_willreturn(i8* %p) {
+; CHECK-LABEL: @not_willreturn(
+; CHECK-NEXT: br label [[LOOP:%.*]]
+; CHECK: loop:
+; CHECK-NEXT: store volatile i8 0, i8* [[P:%.*]], align 1
+; CHECK-NEXT: br i1 true, label [[LOOP]], label [[OUT:%.*]]
+; CHECK: out:
+; CHECK-NEXT: [[X_LE:%.*]] = call i32 @getv() #[[ATTR5:[0-9]+]]
+; CHECK-NEXT: ret i32 [[X_LE]]
+;
+ br label %loop
+
+loop:
+ %x = call i32 @getv() nounwind readnone
+ store volatile i8 0, i8* %p
+ br i1 true, label %loop, label %out
+
+out:
+ ret i32 %x
+}
+
declare void @may_throw()
declare void @may_throw2()
declare i32 @__CxxFrameHandler3(...)
diff --git a/llvm/test/Transforms/LoopDeletion/noop-loops-with-subloops.ll b/llvm/test/Transforms/LoopDeletion/noop-loops-with-subloops.ll
index 715915b110623..9163c9cd401e7 100644
--- a/llvm/test/Transforms/LoopDeletion/noop-loops-with-subloops.ll
+++ b/llvm/test/Transforms/LoopDeletion/noop-loops-with-subloops.ll
@@ -394,6 +394,29 @@ exit:
ret void
}
+; Inner infinite loop hidden behind a call.
+; TODO: Loop should not get deleted.
+define void @not_willreturn() {
+; CHECK-LABEL: @not_willreturn(
+; CHECK-NEXT: entry:
+; CHECK-NEXT: br label [[EXIT:%.*]]
+; CHECK: exit:
+; CHECK-NEXT: ret void
+;
+entry:
+ br label %loop
+
+loop:
+ %iv = phi i32 [ 0, %entry ], [ %iv.next, %loop ]
+ call void @sideeffect() nounwind readonly
+ %iv.next = add nuw i32 %iv, 1
+ %c = icmp ult i32 %iv, 100
+ br i1 %c, label %loop, label %exit
+
+exit:
+ ret void
+}
+
!1 = !{!"llvm.loop.mustprogress"}
!2 = distinct !{!2, !1}
!3 = distinct !{!3, !1}
diff --git a/llvm/test/Transforms/SCCP/calltest.ll b/llvm/test/Transforms/SCCP/calltest.ll
index cf43ea2caa587..de793635600af 100644
--- a/llvm/test/Transforms/SCCP/calltest.ll
+++ b/llvm/test/Transforms/SCCP/calltest.ll
@@ -33,3 +33,12 @@ define i32 @test_1() {
%1 = call %empty @has_side_effects()
ret i32 0
}
+
+; TODO: Call should not get dropped.
+define i32 @test_not_willreturn() {
+; CHECK-LABEL: @test_not_willreturn(
+; CHECK-NEXT: ret i32 0
+;
+ %1 = call %empty @has_side_effects() nounwind readonly
+ ret i32 0
+}
More information about the llvm-commits
mailing list