[llvm] 24d271b - Revert "https://godbolt.org/z/5vhv4K5b8"
Roman Lebedev via llvm-commits
llvm-commits at lists.llvm.org
Fri Jul 2 07:18:23 PDT 2021
Author: Roman Lebedev
Date: 2021-07-02T17:17:55+03:00
New Revision: 24d271bb18bfdb314762ceebc10b57a9c50ed506
URL: https://github.com/llvm/llvm-project/commit/24d271bb18bfdb314762ceebc10b57a9c50ed506
DIFF: https://github.com/llvm/llvm-project/commit/24d271bb18bfdb314762ceebc10b57a9c50ed506.diff
LOG: Revert "https://godbolt.org/z/5vhv4K5b8"
This reverts commit 597ccc92ce4b0f90883406d1f78d9d776f602804.
Added:
Modified:
llvm/lib/Transforms/Utils/SimplifyCFG.cpp
llvm/test/Transforms/SimplifyCFG/trapping-load-unreachable.ll
Removed:
################################################################################
diff --git a/llvm/lib/Transforms/Utils/SimplifyCFG.cpp b/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
index 8294a79a1c0a1..6288a62326554 100644
--- a/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
+++ b/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
@@ -4673,13 +4673,17 @@ bool SimplifyCFGOpt::simplifyUnreachable(UnreachableInst *UI) {
if (BBI->mayHaveSideEffects()) {
if (auto *SI = dyn_cast<StoreInst>(BBI)) {
- // Temporarily disable removal of volatile stores preceding unreachable,
- // pending a potential LangRef change permitting volatile stores to
- // trap.
- // TODO: Either remove this code, or properly integrate the check into
- // isGuaranteedToTransferExecutionToSuccessor().
if (SI->isVolatile())
break;
+ } else if (auto *LI = dyn_cast<LoadInst>(BBI)) {
+ if (LI->isVolatile())
+ break;
+ } else if (auto *RMWI = dyn_cast<AtomicRMWInst>(BBI)) {
+ if (RMWI->isVolatile())
+ break;
+ } else if (auto *CXI = dyn_cast<AtomicCmpXchgInst>(BBI)) {
+ if (CXI->isVolatile())
+ break;
} else if (isa<CatchPadInst>(BBI)) {
// A catchpad may invoke exception object constructors and such, which
// in some languages can be arbitrary code, so be conservative by
@@ -4688,9 +4692,8 @@ bool SimplifyCFGOpt::simplifyUnreachable(UnreachableInst *UI) {
if (classifyEHPersonality(BB->getParent()->getPersonalityFn()) !=
EHPersonality::CoreCLR)
break;
- } else if (!isa<LoadInst>(BBI) && !isa<AtomicRMWInst>(BBI) &&
- !isa<AtomicCmpXchgInst>(BBI) && !isa<FenceInst>(BBI) &&
- !isa<VAArgInst>(BBI) && !isa<LandingPadInst>(BBI)) {
+ } else if (!isa<FenceInst>(BBI) && !isa<VAArgInst>(BBI) &&
+ !isa<LandingPadInst>(BBI)) {
break;
}
// Note that deleting LandingPad's here is in fact okay, although it
diff --git a/llvm/test/Transforms/SimplifyCFG/trapping-load-unreachable.ll b/llvm/test/Transforms/SimplifyCFG/trapping-load-unreachable.ll
index e437f40cbe753..b277cb6cf4f9a 100644
--- a/llvm/test/Transforms/SimplifyCFG/trapping-load-unreachable.ll
+++ b/llvm/test/Transforms/SimplifyCFG/trapping-load-unreachable.ll
@@ -10,8 +10,11 @@ define void @test1(i32 %x) nounwind {
; CHECK-LABEL: @test1(
; CHECK-NEXT: entry:
; CHECK-NEXT: [[TMP0:%.*]] = icmp eq i32 [[X:%.*]], 0
-; CHECK-NEXT: [[TMP1:%.*]] = xor i1 [[TMP0]], true
-; CHECK-NEXT: call void @llvm.assume(i1 [[TMP1]])
+; CHECK-NEXT: br i1 [[TMP0]], label [[BB:%.*]], label [[RETURN:%.*]]
+; CHECK: bb:
+; CHECK-NEXT: [[TMP1:%.*]] = load volatile i32, i32* null, align 4
+; CHECK-NEXT: unreachable
+; CHECK: return:
; CHECK-NEXT: ret void
;
entry:
@@ -31,8 +34,11 @@ define void @test1_no_null_opt(i32 %x) nounwind #0 {
; CHECK-LABEL: @test1_no_null_opt(
; CHECK-NEXT: entry:
; CHECK-NEXT: [[TMP0:%.*]] = icmp eq i32 [[X:%.*]], 0
-; CHECK-NEXT: [[TMP1:%.*]] = xor i1 [[TMP0]], true
-; CHECK-NEXT: call void @llvm.assume(i1 [[TMP1]])
+; CHECK-NEXT: br i1 [[TMP0]], label [[BB:%.*]], label [[RETURN:%.*]]
+; CHECK: bb:
+; CHECK-NEXT: [[TMP1:%.*]] = load volatile i32, i32* null, align 4
+; CHECK-NEXT: unreachable
+; CHECK: return:
; CHECK-NEXT: ret void
;
entry:
@@ -121,8 +127,11 @@ F:
define void @test5(i1 %C, i32* %P) {
; CHECK-LABEL: @test5(
; CHECK-NEXT: entry:
-; CHECK-NEXT: [[TMP0:%.*]] = xor i1 [[C:%.*]], true
-; CHECK-NEXT: call void @llvm.assume(i1 [[TMP0]])
+; CHECK-NEXT: br i1 [[C:%.*]], label [[T:%.*]], label [[F:%.*]]
+; CHECK: T:
+; CHECK-NEXT: [[TMP0:%.*]] = cmpxchg volatile i32* [[P:%.*]], i32 0, i32 1 seq_cst seq_cst, align 4
+; CHECK-NEXT: unreachable
+; CHECK: F:
; CHECK-NEXT: ret void
;
entry:
@@ -138,8 +147,11 @@ F:
define void @test6(i1 %C, i32* %P) {
; CHECK-LABEL: @test6(
; CHECK-NEXT: entry:
-; CHECK-NEXT: [[TMP0:%.*]] = xor i1 [[C:%.*]], true
-; CHECK-NEXT: call void @llvm.assume(i1 [[TMP0]])
+; CHECK-NEXT: br i1 [[C:%.*]], label [[T:%.*]], label [[F:%.*]]
+; CHECK: T:
+; CHECK-NEXT: [[TMP0:%.*]] = atomicrmw volatile xchg i32* [[P:%.*]], i32 0 seq_cst, align 4
+; CHECK-NEXT: unreachable
+; CHECK: F:
; CHECK-NEXT: ret void
;
entry:
More information about the llvm-commits
mailing list