omit empty frames for leaf functions
This commit is contained in:
@@ -33,6 +33,21 @@ void RunFrameLowering(MachineFunction& function) {
|
|||||||
auto& blocks = function.GetBlocks();
|
auto& blocks = function.GetBlocks();
|
||||||
if (blocks.empty()) return;
|
if (blocks.empty()) return;
|
||||||
|
|
||||||
|
bool has_call = false;
|
||||||
|
for (const auto& block : blocks) {
|
||||||
|
for (const auto& inst : block.GetInstructions()) {
|
||||||
|
if (inst.GetOpcode() == Opcode::Call) {
|
||||||
|
has_call = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (has_call) break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (function.GetFrameSize() == 0 && !has_call) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// Insert Prologue at the start of the first block
|
// Insert Prologue at the start of the first block
|
||||||
auto& entry_insts = blocks.front().GetInstructions();
|
auto& entry_insts = blocks.front().GetInstructions();
|
||||||
entry_insts.insert(entry_insts.begin(), MachineInstr(Opcode::Prologue));
|
entry_insts.insert(entry_insts.begin(), MachineInstr(Opcode::Prologue));
|
||||||
|
|||||||
Reference in New Issue
Block a user