summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNick Lewycky <nicholas@mxc.ca>2009-06-13 19:09:52 +0000
committerNick Lewycky <nicholas@mxc.ca>2009-06-13 19:09:52 +0000
commita142c9302b690cda799737d78ec29414e3b47fc8 (patch)
treedac13aa620db1b1db82606d9f9f2f6d63eabaae3
parentdcb6da3efdfeb007ce222192f3af00736133682d (diff)
downloadllvm-a142c9302b690cda799737d78ec29414e3b47fc8.tar.gz
llvm-a142c9302b690cda799737d78ec29414e3b47fc8.tar.bz2
llvm-a142c9302b690cda799737d78ec29414e3b47fc8.tar.xz
Unlike the other instructions, GEP really does need to look at the type of a
pointer. This fixes kimwitu++. Pointed out by Frits van Bommel on review! git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@73299 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/Transforms/IPO/MergeFunctions.cpp14
1 files changed, 14 insertions, 0 deletions
diff --git a/lib/Transforms/IPO/MergeFunctions.cpp b/lib/Transforms/IPO/MergeFunctions.cpp
index 1dd3279b9e..5693cc0fc3 100644
--- a/lib/Transforms/IPO/MergeFunctions.cpp
+++ b/lib/Transforms/IPO/MergeFunctions.cpp
@@ -284,6 +284,20 @@ static bool equals(const BasicBlock *BB1, const BasicBlock *BB2,
if (!isEquivalentOperation(FI, GI))
return false;
+ if (isa<GetElementPtrInst>(FI)) {
+ const GetElementPtrInst *GEPF = cast<GetElementPtrInst>(FI);
+ const GetElementPtrInst *GEPG = cast<GetElementPtrInst>(GI);
+ if (GEPF->hasAllZeroIndices() && GEPG->hasAllZeroIndices()) {
+ // It's effectively a bitcast.
+ ++FI, ++GI;
+ continue;
+ }
+
+ // TODO: we only really care about the elements before the index
+ if (FI->getOperand(0)->getType() != GI->getOperand(0)->getType())
+ return false;
+ }
+
if (ValueMap[FI] == GI) {
++FI, ++GI;
continue;