aboutsummaryrefslogtreecommitdiffstats
path: root/lib/Analysis
diff options
context:
space:
mode:
authorDan Gohman <gohman@apple.com>2011-05-24 18:24:08 +0000
committerDan Gohman <gohman@apple.com>2011-05-24 18:24:08 +0000
commit9adf151b3d46740ac103c4e21fbdec66d6ef1cdf (patch)
tree6b1fe821d1e94a8bd459a0ee74871917f73b81ba /lib/Analysis
parent6b918b84661687f7b5fc92dabd6d58e258bf39f2 (diff)
downloadexternal_llvm-9adf151b3d46740ac103c4e21fbdec66d6ef1cdf.zip
external_llvm-9adf151b3d46740ac103c4e21fbdec66d6ef1cdf.tar.gz
external_llvm-9adf151b3d46740ac103c4e21fbdec66d6ef1cdf.tar.bz2
Make DecomposeGEPExpression check SimplifyInstruction only
after checking for a GEP, so that it matches what GetUnderlyingObject does. This fixes an obscure bug turned up by bugpoint in the testcase for PR9931. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@131971 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Analysis')
-rw-r--r--lib/Analysis/BasicAliasAnalysis.cpp21
1 files changed, 12 insertions, 9 deletions
diff --git a/lib/Analysis/BasicAliasAnalysis.cpp b/lib/Analysis/BasicAliasAnalysis.cpp
index 989d8e0..03785fd 100644
--- a/lib/Analysis/BasicAliasAnalysis.cpp
+++ b/lib/Analysis/BasicAliasAnalysis.cpp
@@ -281,17 +281,20 @@ DecomposeGEPExpression(const Value *V, int64_t &BaseOffs,
continue;
}
- if (const Instruction *I = dyn_cast<Instruction>(V))
- // TODO: Get a DominatorTree and use it here.
- if (const Value *Simplified =
- SimplifyInstruction(const_cast<Instruction *>(I), TD)) {
- V = Simplified;
- continue;
- }
-
const GEPOperator *GEPOp = dyn_cast<GEPOperator>(Op);
- if (GEPOp == 0)
+ if (GEPOp == 0) {
+ // If it's not a GEP, hand it off to SimplifyInstruction to see if it
+ // can come up with something. This matches what GetUnderlyingObject does.
+ if (const Instruction *I = dyn_cast<Instruction>(V))
+ // TODO: Get a DominatorTree and use it here.
+ if (const Value *Simplified =
+ SimplifyInstruction(const_cast<Instruction *>(I), TD)) {
+ V = Simplified;
+ continue;
+ }
+
return V;
+ }
// Don't attempt to analyze GEPs over unsized objects.
if (!cast<PointerType>(GEPOp->getOperand(0)->getType())