Instruction *getPrev() { return Prev; }
const Instruction *getPrev() const { return Prev; }
Instruction *getPrev() { return Prev; }
const Instruction *getPrev() const { return Prev; }
- virtual bool hasSideEffects() const { return false; } // Memory & Call insts
+ /// mayWriteToMemory - Return true if this instruction may modify memory.
+ ///
+ virtual bool mayWriteToMemory() const { return false; }
// ---------------------------------------------------------------------------
/// Subclass classification... getOpcode() returns a member of
// ---------------------------------------------------------------------------
/// Subclass classification... getOpcode() returns a member of
virtual Instruction *clone() const { return new FreeInst(Operands[0]); }
virtual Instruction *clone() const { return new FreeInst(Operands[0]); }
- virtual bool hasSideEffects() const { return true; }
+ virtual bool mayWriteToMemory() const { return true; }
// Methods for support type inquiry through isa, cast, and dyn_cast:
static inline bool classof(const FreeInst *) { return true; }
// Methods for support type inquiry through isa, cast, and dyn_cast:
static inline bool classof(const FreeInst *) { return true; }
StoreInst(Value *Val, Value *Ptr, Instruction *InsertBefore = 0);
virtual Instruction *clone() const { return new StoreInst(*this); }
StoreInst(Value *Val, Value *Ptr, Instruction *InsertBefore = 0);
virtual Instruction *clone() const { return new StoreInst(*this); }
- virtual bool hasSideEffects() const { return true; }
+ virtual bool mayWriteToMemory() const { return true; }
Value *getPointerOperand() { return getOperand(1); }
const Value *getPointerOperand() const { return getOperand(1); }
Value *getPointerOperand() { return getOperand(1); }
const Value *getPointerOperand() const { return getOperand(1); }
Instruction* InsertBefore = 0);
virtual Instruction *clone() const { return new CallInst(*this); }
Instruction* InsertBefore = 0);
virtual Instruction *clone() const { return new CallInst(*this); }
- bool hasSideEffects() const { return true; }
+ bool mayWriteToMemory() const { return true; }
const Function *getCalledFunction() const {
return dyn_cast<Function>(Operands[0].get());
const Function *getCalledFunction() const {
return dyn_cast<Function>(Operands[0].get());
virtual Instruction *clone() const { return new InvokeInst(*this); }
virtual Instruction *clone() const { return new InvokeInst(*this); }
- bool hasSideEffects() const { return true; }
+ bool mayWriteToMemory() const { return true; }
// getCalledFunction - Return the function called, or null if this is an
// indirect function invocation...
// getCalledFunction - Return the function called, or null if this is an
// indirect function invocation...
BBI != BBE; ++BBI) {
BasicBlock *BB = *BBI;
for (BasicBlock::iterator II = BB->begin(), EI = BB->end(); II != EI; ) {
BBI != BBE; ++BBI) {
BasicBlock *BB = *BBI;
for (BasicBlock::iterator II = BB->begin(), EI = BB->end(); II != EI; ) {
- if (II->hasSideEffects() || II->getOpcode() == Instruction::Ret) {
+ if (II->mayWriteToMemory() || II->getOpcode() == Instruction::Ret) {
markInstructionLive(II);
++II; // Increment the inst iterator if the inst wasn't deleted
} else if (isInstructionTriviallyDead(II)) {
markInstructionLive(II);
++II; // Increment the inst iterator if the inst wasn't deleted
} else if (isInstructionTriviallyDead(II)) {
if (I->getOpcode() == Instruction::PHINode ||
I->getOpcode() == Instruction::Alloca ||
I->getOpcode() == Instruction::Malloc || isa<TerminatorInst>(I) ||
if (I->getOpcode() == Instruction::PHINode ||
I->getOpcode() == Instruction::Alloca ||
I->getOpcode() == Instruction::Malloc || isa<TerminatorInst>(I) ||
+ I->mayWriteToMemory()) // Cannot move inst if it writes to memory!
return RankMap[I->getParent()];
unsigned &CachedRank = InstRankMap[I];
return RankMap[I->getParent()];
unsigned &CachedRank = InstRankMap[I];
//
bool isInstructionTriviallyDead(Instruction *I) {
//
bool isInstructionTriviallyDead(Instruction *I) {
- return I->use_empty() && !I->hasSideEffects() && !isa<TerminatorInst>(I);
+ return I->use_empty() && !I->mayWriteToMemory() && !isa<TerminatorInst>(I);
}
// dceInstruction - Inspect the instruction at *BBI and figure out if it's
}
// dceInstruction - Inspect the instruction at *BBI and figure out if it's