mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-07-29 10:25:12 +00:00
Fix a layering violation: hasConstantValue, which is part of the PHINode
class, uses DominatorTree which is an analysis. This change moves all of the tricky hasConstantValue logic to SimplifyInstruction, and replaces it with a very simple literal implementation. I already taught users of hasConstantValue that need tricky stuff to use SimplifyInstruction instead. I didn't update InlineFunction because the IR looks like it might be in a funky state at the point it calls hasConstantValue, which makes calling SimplifyInstruction dangerous since it can in theory do a lot of tricky reasoning. This may be a pessimization, for example in the case where all phi node operands are either undef or a fixed constant. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@119459 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -582,7 +582,7 @@ Value *Lint::findValueImpl(Value *V, bool OffsetOk,
|
||||
BBI = BB->end();
|
||||
}
|
||||
} else if (PHINode *PN = dyn_cast<PHINode>(V)) {
|
||||
if (Value *W = PN->hasConstantValue(DT))
|
||||
if (Value *W = PN->hasConstantValue())
|
||||
return findValueImpl(W, OffsetOk, Visited);
|
||||
} else if (CastInst *CI = dyn_cast<CastInst>(V)) {
|
||||
if (CI->isNoopCast(TD ? TD->getIntPtrType(V->getContext()) :
|
||||
@@ -615,7 +615,7 @@ Value *Lint::findValueImpl(Value *V, bool OffsetOk,
|
||||
|
||||
// As a last resort, try SimplifyInstruction or constant folding.
|
||||
if (Instruction *Inst = dyn_cast<Instruction>(V)) {
|
||||
if (Value *W = SimplifyInstruction(Inst, TD))
|
||||
if (Value *W = SimplifyInstruction(Inst, TD, DT))
|
||||
if (W != Inst)
|
||||
return findValueImpl(W, OffsetOk, Visited);
|
||||
} else if (ConstantExpr *CE = dyn_cast<ConstantExpr>(V)) {
|
||||
|
Reference in New Issue
Block a user