inline void markInstructionLive(Instruction *I) {
if (LiveSet.count(I)) return;
- DEBUG(std::cerr << "Insn Live: " << I);
+ DEBUG(std::cerr << "Insn Live: " << *I);
LiveSet.insert(I);
WorkList.push_back(I);
}
inline void markTerminatorLive(const BasicBlock *BB) {
- DEBUG(std::cerr << "Terminator Live: " << BB->getTerminator());
+ DEBUG(std::cerr << "Terminator Live: " << *BB->getTerminator());
markInstructionLive(const_cast<TerminatorInst*>(BB->getTerminator()));
}
};
Relation::KnownResult Result = getSetCCResult(SCI, RI);
if (Result != Relation::Unknown) {
DEBUG(std::cerr << "Replacing setcc with " << Result
- << " constant: " << SCI);
+ << " constant: " << *SCI);
SCI->replaceAllUsesWith(ConstantBool::get((bool)Result));
// The instruction is now dead, remove it from the program.
if (Value *Repl = VI->getReplacement()) {
// If we know if a replacement with lower rank than Op0, make the
// replacement now.
- DEBUG(std::cerr << "In Inst: " << I << " Replacing operand #" << i
- << " with " << Repl << "\n");
+ DEBUG(std::cerr << "In Inst: " << *I << " Replacing operand #" << i
+ << " with " << *Repl << "\n");
I->setOperand(i, Repl);
Changed = true;
++NumOperandsCann;
if (isa<Constant>(Op1)) {
if (Constant *Result = ConstantFoldInstruction(SCI)) {
// Wow, this is easy, directly eliminate the SetCondInst.
- DEBUG(std::cerr << "Replacing setcc with constant fold: " << SCI);
+ DEBUG(std::cerr << "Replacing setcc with constant fold: " << *SCI);
return cast<ConstantBool>(Result)->getValue()
? Relation::KnownTrue : Relation::KnownFalse;
}
return Changed;
}
#endif
- DEBUG(std::cerr << "\n====--- Expression: " << Expr);
+ DEBUG(std::cerr << "\n====--- Expression: " << *Expr);
const Type *ExprType = Expr->getType();
// AnticipatibleBlocks - Blocks where the current expression is anticipatible.
BasicBlock *BB = Occurrence->getParent();
Definitions.erase(Definitions.begin());
- DEBUG(std::cerr << "PROCESSING Occurrence: " << Occurrence);
+ DEBUG(std::cerr << "PROCESSING Occurrence: " << *Occurrence);
// Check to see if there is already an incoming value for this block...
AvailableBlocksTy::iterator LBI = AvailableBlocks.find(BB);
// Yes, there is a dominating definition for this block. Replace this
// occurrence with the incoming value.
if (LBI->second != Occurrence) {
- DEBUG(std::cerr << " replacing with: " << LBI->second);
+ DEBUG(std::cerr << " replacing with: " << *LBI->second);
Occurrence->replaceAllUsesWith(LBI->second);
BB->getInstList().erase(Occurrence); // Delete instruction
++NumRedundant;
DFBlock->begin());
ProcessedExpressions.insert(PN);
- DEBUG(std::cerr << " INSERTING PHI on frontier: " << PN);
+ DEBUG(std::cerr << " INSERTING PHI on frontier: " << *PN);
// Add the incoming blocks for the PHI node
for (pred_iterator PI = pred_begin(DFBlock),
Instruction *&BlockOcc = Definitions[DFBlockID];
if (BlockOcc) {
- DEBUG(std::cerr <<" PHI superceeds occurrence: "<<BlockOcc);
+ DEBUG(std::cerr <<" PHI superceeds occurrence: "<<
+ *BlockOcc);
BlockOcc->replaceAllUsesWith(PN);
BlockOcc->getParent()->getInstList().erase(BlockOcc);
++NumRedundant;
//
PHINode *PN = new PHINode(ExprType, Expr->getName()+".PRE",
AFBlock->begin());
- DEBUG(std::cerr << "INSERTING PHI for PR: " << PN);
+ DEBUG(std::cerr << "INSERTING PHI for PR: " << *PN);
// If there is a pending occurrence in this block, make sure to replace it
// with the PHI node...
// There is already an occurrence in this block. Replace it with PN and
// remove it.
Instruction *OldOcc = EDFI->second;
- DEBUG(std::cerr << " Replaces occurrence: " << OldOcc);
+ DEBUG(std::cerr << " Replaces occurrence: " << *OldOcc);
OldOcc->replaceAllUsesWith(PN);
AFBlock->getInstList().erase(OldOcc);
Definitions.erase(EDFI);
New->setName(NonPHIOccurrence->getName() + ".PRE-inserted");
ProcessedExpressions.insert(New);
- DEBUG(std::cerr << " INSERTING OCCURRRENCE: " << New);
+ DEBUG(std::cerr << " INSERTING OCCURRRENCE: " << *New);
// Insert it into the bottom of the predecessor, right before the
// terminator instruction...
std::swap(LHSRank, RHSRank);
Changed = true;
++NumSwapped;
- DEBUG(std::cerr << "Transposed: " << I
+ DEBUG(std::cerr << "Transposed: " << *I
/* << " Result BB: " << I->getParent()*/);
}
I->getParent()->getInstList().insert(I, LHSI);
++NumChanged;
- DEBUG(std::cerr << "Reassociated: " << I/* << " Result BB: "
+ DEBUG(std::cerr << "Reassociated: " << *I/* << " Result BB: "
<< I->getParent()*/);
// Since we modified the RHS instruction, make sure that we recheck it.
New->setOperand(1, NegateValue(New->getOperand(1), BI));
Changed = true;
- DEBUG(std::cerr << "Negated: " << New /*<< " Result BB: " << BB*/);
+ DEBUG(std::cerr << "Negated: " << *New /*<< " Result BB: " << BB*/);
}
// If this instruction is a commutative binary operator, and the ranks of
I = Tmp;
++NumLinear;
Changed = true;
- DEBUG(std::cerr << "Linearized: " << I/* << " Result BB: " << BB*/);
+ DEBUG(std::cerr << "Linearized: " << *I/* << " Result BB: " << BB*/);
}
// Make sure that this expression is correctly reassociated with respect
Instruction *I = InstWorkList.back();
InstWorkList.pop_back();
- DEBUG(std::cerr << "\nPopped off I-WL: " << I);
+ DEBUG(std::cerr << "\nPopped off I-WL: " << *I);
// "I" got into the work list because it either made the transition from
// bottom to constant, or to Overdefined.
BasicBlock *BB = BBWorkList.back();
BBWorkList.pop_back();
- DEBUG(std::cerr << "\nPopped off BBWL: " << BB);
+ DEBUG(std::cerr << "\nPopped off BBWL: " << *BB);
// Notify all instructions in this basic block that they are newly
// executable.
InstVal &IV = ValueState[&Inst];
if (IV.isConstant()) {
Constant *Const = IV.getConstant();
- DEBUG(std::cerr << "Constant: " << Const << " = " << Inst);
+ DEBUG(std::cerr << "Constant: " << *Const << " = " << Inst);
// Replaces all of the uses of a variable with uses of the constant.
Inst.replaceAllUsesWith(Const);
I != E; ++I)
if (!isSafeUseOfAllocation(cast<Instruction>(*I))) {
DEBUG(std::cerr << "Cannot transform: " << *AI << " due to user: "
- << *I);
+ << **I);
return false;
}
return true;