: InstX8632(Func, InstX8632::Fstp, 0, Dest) {}
InstX8632Pop::InstX8632Pop(Cfg *Func, Variable *Dest)
- : InstX8632(Func, InstX8632::Pop, 0, Dest) {}
+ : InstX8632(Func, InstX8632::Pop, 0, Dest) {
+ // A pop instruction affects the stack pointer and so it should not
+ // be allowed to be automatically dead-code eliminated. (The
+ // corresponding push instruction doesn't need this treatment
+ // because it has no dest variable and therefore won't be dead-code
+ // eliminated.) This is needed for late-stage liveness analysis
+ // (e.g. asm-verbose mode).
+ HasSideEffects = true;
+}
InstX8632Push::InstX8632Push(Cfg *Func, Variable *Source)
: InstX8632(Func, InstX8632::Push, 1, nullptr) {
Variable *esp = getPhysicalRegister(RegX8632::Reg_esp);
_push(ebp);
_mov(ebp, esp);
+ // Keep ebp live for late-stage liveness analysis
+ // (e.g. asm-verbose mode).
+ Context.insert(InstFakeUse::create(Func, ebp));
}
// Align the variables area. SpillAreaPaddingBytes is the size of
Variable *esp = getPhysicalRegister(RegX8632::Reg_esp);
if (IsEbpBasedFrame) {
Variable *ebp = getPhysicalRegister(RegX8632::Reg_ebp);
+ // For late-stage liveness analysis (e.g. asm-verbose mode),
+ // adding a fake use of esp before the assignment of esp=ebp keeps
+ // previous esp adjustments from being dead-code eliminated.
+ Context.insert(InstFakeUse::create(Func, esp));
_mov(esp, ebp);
_pop(ebp);
} else {
RegNum = RegsForType.find_first();
Preg = getPhysicalRegister(RegNum, Dest->getType());
SpillLoc = Func->makeVariable(Dest->getType());
+ // Create a fake def of the physical register to avoid
+ // liveness inconsistency problems during late-stage liveness
+ // analysis (e.g. asm-verbose mode).
+ Context.insert(InstFakeDef::create(Func, Preg));
if (IsVector)
_movp(SpillLoc, Preg);
else
_movp(Preg, SpillLoc);
else
_mov(Preg, SpillLoc);
+ // Create a fake use of the physical register to keep it live
+ // for late-stage liveness analysis (e.g. asm-verbose mode).
+ Context.insert(InstFakeUse::create(Func, Preg));
}
}
// Update register availability before moving to the previous