diff options
| author | Sanjay Patel <spatel@rotateright.com> | 2019-09-04 15:12:55 +0000 |
|---|---|---|
| committer | Sanjay Patel <spatel@rotateright.com> | 2019-09-04 15:12:55 +0000 |
| commit | 4a2cd7be5a6fbca1be111ad56927e0dfc3185f88 (patch) | |
| tree | 1d8f9f06983c4b7ef1d829355e485e443ebbaaa6 /llvm/lib/Transforms | |
| parent | 433927595dde3821c76b33725aab8ccd472a5137 (diff) | |
| download | bcm5719-llvm-4a2cd7be5a6fbca1be111ad56927e0dfc3185f88.tar.gz bcm5719-llvm-4a2cd7be5a6fbca1be111ad56927e0dfc3185f88.zip | |
[InstSimplify] guard against unreachable code (PR43218)
This would crash:
https://bugs.llvm.org/show_bug.cgi?id=43218
llvm-svn: 370911
Diffstat (limited to 'llvm/lib/Transforms')
| -rw-r--r-- | llvm/lib/Transforms/Scalar/InstSimplifyPass.cpp | 7 |
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; |

