mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2025-01-30 08:44:48 +00:00
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. llvm-svn: 121886
This commit is contained in:
parent
295ba3ab26
commit
8b09daa387
@ -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!");
|
||||
|
Loading…
x
Reference in New Issue
Block a user