[llvm] 1a8c9cd - Fix PR45442: Bail out when MemorySSA information is not available
Aditya Kumar via llvm-commits
llvm-commits at lists.llvm.org
Thu Aug 13 11:27:22 PDT 2020
Author: Aditya Kumar
Date: 2020-08-13T11:25:58-07:00
New Revision: 1a8c9cd1d96e680a3c519e9b3295ba9c4a34736d
URL: https://github.com/llvm/llvm-project/commit/1a8c9cd1d96e680a3c519e9b3295ba9c4a34736d
DIFF: https://github.com/llvm/llvm-project/commit/1a8c9cd1d96e680a3c519e9b3295ba9c4a34736d.diff
LOG: Fix PR45442: Bail out when MemorySSA information is not available
Reviewers: sebpop, uabelho, fhahn
Reviewed by: fhahn
Differential Revision: https://reviews.llvm.org/D85881
Added:
Modified:
llvm/lib/Transforms/Scalar/GVNHoist.cpp
llvm/test/Transforms/GVNHoist/pr45442.ll
Removed:
################################################################################
diff --git a/llvm/lib/Transforms/Scalar/GVNHoist.cpp b/llvm/lib/Transforms/Scalar/GVNHoist.cpp
index 07f40de6a1f2..74c4a480098a 100644
--- a/llvm/lib/Transforms/Scalar/GVNHoist.cpp
+++ b/llvm/lib/Transforms/Scalar/GVNHoist.cpp
@@ -521,10 +521,6 @@ class GVNHoist {
if (NewPt == OldPt)
return true;
- // MemoryUseDef information is not available, bail out.
- if (!U)
- return false;
-
const BasicBlock *NewBB = NewPt->getParent();
const BasicBlock *OldBB = OldPt->getParent();
const BasicBlock *UBB = U->getBlock();
@@ -609,9 +605,10 @@ class GVNHoist {
if (safeToHoistScalar(BB, Insn->getParent(), NumBBsOnAllPaths))
Safe.push_back(CHI);
} else {
- MemoryUseOrDef *UD = MSSA->getMemoryAccess(Insn);
- if (safeToHoistLdSt(BB->getTerminator(), Insn, UD, K, NumBBsOnAllPaths))
- Safe.push_back(CHI);
+ auto *T = BB->getTerminator();
+ if (MemoryUseOrDef *UD = MSSA->getMemoryAccess(Insn))
+ if (safeToHoistLdSt(T, Insn, UD, K, NumBBsOnAllPaths))
+ Safe.push_back(CHI);
}
}
}
diff --git a/llvm/test/Transforms/GVNHoist/pr45442.ll b/llvm/test/Transforms/GVNHoist/pr45442.ll
index db3ecb2a8d87..fe6a8be01507 100644
--- a/llvm/test/Transforms/GVNHoist/pr45442.ll
+++ b/llvm/test/Transforms/GVNHoist/pr45442.ll
@@ -1,32 +1,32 @@
; RUN: opt < %s -gvn-hoist -S | FileCheck %s
; gvn-hoist shouldn't crash in this case.
-; CHECK-LABEL: @func()
+; CHECK-LABEL: @func(i1 %b)
; CHECK: entry:
; CHECK-NEXT: br i1
; CHECK: bb1:
-; CHECK-NEXT: unreachable
+; CHECK-NEXT: ret void
; CHECK: bb2:
; CHECK-NEXT: call
; CHECK-NEXT: call
-; CHECK-NEXT: unreachable
+; CHECK-NEXT: ret void
define void @v_1_0() #0 {
entry:
ret void
}
-define void @func() {
+define void @func(i1 %b) {
entry:
- br i1 undef, label %bb1, label %bb2
+ br i1 %b, label %bb1, label %bb2
bb1:
- unreachable
+ ret void
bb2:
call void @v_1_0()
call void @v_1_0()
- unreachable
+ ret void
}
attributes #0 = { nounwind readonly }
More information about the llvm-commits
mailing list