summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms/Scalar
diff options
context:
space:
mode:
authorTaewook Oh <twoh@fb.com>2018-11-05 18:16:32 +0000
committerTaewook Oh <twoh@fb.com>2018-11-05 18:16:32 +0000
commit2b7ae47ccb5039a3716e637a91f4f65833decbc4 (patch)
treefae7191541692e1f62ce1429dc27b34ffb86511d /llvm/lib/Transforms/Scalar
parent1cfba9b5edae7ae3c2c6694fa438187964411bc5 (diff)
downloadbcm5719-llvm-2b7ae47ccb5039a3716e637a91f4f65833decbc4.tar.gz
bcm5719-llvm-2b7ae47ccb5039a3716e637a91f4f65833decbc4.zip
[MergeICmps] Do not perform the transformation if GEP is used outside of block
Summary: This patch prevents MergeICmps to performn the transformation if the address operand GEP of the load instruction has a use outside of the load's parent block. Without this patch, compiler crashes with the given test case because the use of `%first.i` is still around when the basic block is erased from https://github.com/llvm-mirror/llvm/blob/master/lib/Transforms/Scalar/MergeICmps.cpp#L620. I think checking `isUsedOutsideOfBlock` with `GEP` is the original intention of the code, as the checking for `LoadI` is already performed in the same function. This patch is incomplete though, as this makes the pass overly conservative and fails the test `tuple-four-int8.ll`. I believe what needs to be done is checking if GEP has a use outside of block that is not the part of "Comparisons" chain. Submit the patch as of now to prevent compiler crash. Reviewers: courbet, trentxintong Reviewed By: courbet Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D54089 llvm-svn: 346151
Diffstat (limited to 'llvm/lib/Transforms/Scalar')
-rw-r--r--llvm/lib/Transforms/Scalar/MergeICmps.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/llvm/lib/Transforms/Scalar/MergeICmps.cpp b/llvm/lib/Transforms/Scalar/MergeICmps.cpp
index 3633485d5d5..69fd8b163a0 100644
--- a/llvm/lib/Transforms/Scalar/MergeICmps.cpp
+++ b/llvm/lib/Transforms/Scalar/MergeICmps.cpp
@@ -98,7 +98,7 @@ BCEAtom visitICmpLoadOperand(Value *const Val) {
Value *const Addr = LoadI->getOperand(0);
if (auto *const GEP = dyn_cast<GetElementPtrInst>(Addr)) {
LLVM_DEBUG(dbgs() << "GEP\n");
- if (LoadI->isUsedOutsideOfBlock(LoadI->getParent())) {
+ if (GEP->isUsedOutsideOfBlock(LoadI->getParent())) {
LLVM_DEBUG(dbgs() << "used outside of block\n");
return {};
}
OpenPOWER on IntegriCloud