summaryrefslogtreecommitdiffstats
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
commit47b71c5844fdfc55c159db290cd32ebb3526426b (patch)
tree931e6c60e52c25c094745da8d6d5caa45c3d2d3e
parentc54e242fb4c10b5baaef148fd85b95f4678f9269 (diff)
downloadbcm5719-llvm-47b71c5844fdfc55c159db290cd32ebb3526426b.tar.gz
bcm5719-llvm-47b71c5844fdfc55c159db290cd32ebb3526426b.zip
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! llvm-svn: 73299
-rw-r--r--llvm/lib/Transforms/IPO/MergeFunctions.cpp14
1 files changed, 14 insertions, 0 deletions
diff --git a/llvm/lib/Transforms/IPO/MergeFunctions.cpp b/llvm/lib/Transforms/IPO/MergeFunctions.cpp
index 1dd3279b9eb..5693cc0fc3b 100644
--- a/llvm/lib/Transforms/IPO/MergeFunctions.cpp
+++ b/llvm/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;
OpenPOWER on IntegriCloud