summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms/Scalar/InstSimplifyPass.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/lib/Transforms/Scalar/InstSimplifyPass.cpp')
-rw-r--r--llvm/lib/Transforms/Scalar/InstSimplifyPass.cpp7
1 files changed, 6 insertions, 1 deletions
diff --git a/llvm/lib/Transforms/Scalar/InstSimplifyPass.cpp b/llvm/lib/Transforms/Scalar/InstSimplifyPass.cpp
index 920b12b8a6a..e3edfe51458 100644
--- a/llvm/lib/Transforms/Scalar/InstSimplifyPass.cpp
+++ b/llvm/lib/Transforms/Scalar/InstSimplifyPass.cpp
@@ -34,6 +34,11 @@ static bool runImpl(Function &F, const SimplifyQuery &SQ,
do {
for (BasicBlock &BB : F) {
+ // Unreachable code can take on strange forms that we are not prepared to
+ // handle. For example, an instruction may have itself as an operand.
+ if (!SQ.DT->isReachableFromEntry(&BB))
+ continue;
+
SmallVector<Instruction *, 8> DeadInstsInBB;
for (Instruction &I : BB) {
// The first time through the loop, ToSimplify is empty and we try to
@@ -87,7 +92,7 @@ struct InstSimplifyLegacyPass : public FunctionPass {
AU.addRequired<OptimizationRemarkEmitterWrapperPass>();
}
- /// runOnFunction - Remove instructions that simplify.
+ /// Remove instructions that simplify.
bool runOnFunction(Function &F) override {
if (skipFunction(F))
return false;
OpenPOWER on IntegriCloud