summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms/AggressiveInstCombine/TruncInstCombine.cpp
diff options
context:
space:
mode:
authorAmjad Aboud <amjad.aboud@intel.com>2018-01-31 10:41:31 +0000
committerAmjad Aboud <amjad.aboud@intel.com>2018-01-31 10:41:31 +0000
commitd895bff5f280fe84b8c6e8d46a0c25b084d91e46 (patch)
tree82e0a09fd3f983b75affa7f55640f4f693707c2a /llvm/lib/Transforms/AggressiveInstCombine/TruncInstCombine.cpp
parent98d5359ea2a07ebeaf6eb9dbc7c80fb4fbd72885 (diff)
downloadbcm5719-llvm-d895bff5f280fe84b8c6e8d46a0c25b084d91e46.tar.gz
bcm5719-llvm-d895bff5f280fe84b8c6e8d46a0c25b084d91e46.zip
[AggressiveInstCombine] Make TruncCombine class ignore unreachable basic blocks.
Because dead code may contain non-standard IR that causes infinite looping or crashes in underlying analysis. See PR36134 for more details. Differential Revision: https://reviews.llvm.org/D42683 llvm-svn: 323862
Diffstat (limited to 'llvm/lib/Transforms/AggressiveInstCombine/TruncInstCombine.cpp')
-rw-r--r--llvm/lib/Transforms/AggressiveInstCombine/TruncInstCombine.cpp7
1 files changed, 6 insertions, 1 deletions
diff --git a/llvm/lib/Transforms/AggressiveInstCombine/TruncInstCombine.cpp b/llvm/lib/Transforms/AggressiveInstCombine/TruncInstCombine.cpp
index deb0979265c..0378ea79ef7 100644
--- a/llvm/lib/Transforms/AggressiveInstCombine/TruncInstCombine.cpp
+++ b/llvm/lib/Transforms/AggressiveInstCombine/TruncInstCombine.cpp
@@ -31,6 +31,7 @@
#include "llvm/Analysis/ConstantFolding.h"
#include "llvm/Analysis/TargetLibraryInfo.h"
#include "llvm/IR/DataLayout.h"
+#include "llvm/IR/Dominators.h"
#include "llvm/IR/IRBuilder.h"
using namespace llvm;
@@ -380,10 +381,14 @@ bool TruncInstCombine::run(Function &F) {
bool MadeIRChange = false;
// Collect all TruncInst in the function into the Worklist for evaluating.
- for (auto &BB : F)
+ for (auto &BB : F) {
+ // Ignore unreachable basic block.
+ if (!DT.isReachableFromEntry(&BB))
+ continue;
for (auto &I : BB)
if (auto *CI = dyn_cast<TruncInst>(&I))
Worklist.push_back(CI);
+ }
// Process all TruncInst in the Worklist, for each instruction:
// 1. Check if it dominates an eligible expression dag to be reduced.
OpenPOWER on IntegriCloud