summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorDan Gohman <gohman@apple.com>2010-12-15 20:10:26 +0000
committerDan Gohman <gohman@apple.com>2010-12-15 20:10:26 +0000
commit243712720ad1da144d4376bdd854d81260c1beaa (patch)
tree89d26602bf01aa016d933a6ff177c8c3074f29b5 /lib
parent5034dd318a9dfa0dc45a3ac01e58e60f2aa2498d (diff)
downloadllvm-243712720ad1da144d4376bdd854d81260c1beaa.tar.gz
llvm-243712720ad1da144d4376bdd854d81260c1beaa.tar.bz2
llvm-243712720ad1da144d4376bdd854d81260c1beaa.tar.xz
Strengthen GetUnderlyingObject using InstructionSimplify.
While LLVM's main design is that analysis code shouldn't go out of its way to understand code which hasn't been InstCombined, analysis utility routines like this can find themselves being called in the middle of transform passes when instcombine hasn't had a chance to run. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@121886 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r--lib/Analysis/ValueTracking.cpp9
1 files changed, 9 insertions, 0 deletions
diff --git a/lib/Analysis/ValueTracking.cpp b/lib/Analysis/ValueTracking.cpp
index d1b75c3f9f..75062953cb 100644
--- a/lib/Analysis/ValueTracking.cpp
+++ b/lib/Analysis/ValueTracking.cpp
@@ -13,6 +13,7 @@
//===----------------------------------------------------------------------===//
#include "llvm/Analysis/ValueTracking.h"
+#include "llvm/Analysis/InstructionSimplify.h"
#include "llvm/Constants.h"
#include "llvm/Instructions.h"
#include "llvm/GlobalVariable.h"
@@ -1440,6 +1441,14 @@ Value *llvm::GetUnderlyingObject(Value *V, unsigned MaxLookup) {
return V;
V = GA->getAliasee();
} else {
+ // See if InstructionSimplify knows any relevant tricks.
+ if (Instruction *I = dyn_cast<Instruction>(V))
+ // TODO: Aquire TargetData and DominatorTree and use them.
+ if (Value *Simplified = SimplifyInstruction(I, 0, 0)) {
+ V = Simplified;
+ continue;
+ }
+
return V;
}
assert(V->getType()->isPointerTy() && "Unexpected operand type!");