diff --git a/src/mir/FrameLowering.cpp b/src/mir/FrameLowering.cpp index d29a0da..6363701 100644 --- a/src/mir/FrameLowering.cpp +++ b/src/mir/FrameLowering.cpp @@ -33,6 +33,21 @@ void RunFrameLowering(MachineFunction& function) { auto& blocks = function.GetBlocks(); 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 auto& entry_insts = blocks.front().GetInstructions(); entry_insts.insert(entry_insts.begin(), MachineInstr(Opcode::Prologue));