Commit 3e738292 authored by Jason Hiser's avatar Jason Hiser 🚜

minor code cleanup for release

parent 31b6524e
Pipeline #2706 passed with stages
in 16 minutes and 33 seconds
......@@ -129,16 +129,18 @@ void InitStack_t::initStack(Function_t* f)
const auto scratch_reg = getFileIR()->getArchitectureBitWidth()==64 ? "r11" : "ecx";
// Now, do the dirty work of inserting new assembly to initialize the stack.
// assume: flags and scratch_reg are dead at function entry.
// insert these instructions at the start of the function (to initialize the stack frame before the function runs)
// Insert these instructions at the start of the function (to initialize the stack frame before the function runs)
// Assume: flags and scratch_reg are dead at function entry.
// Future work: Verify this is true using dead register list.
// Note: we initialize 128 bytes passed the end of the frame to make sure the "red zone" is initialized too
// Future work: Red zone on i686 is 4k, may need to adjust or reconsider how this works. Analyze function for red zone usage?
auto tmp=entry;
//todo: anh to comment assembly and explain -100 constant.
insertAssemblyBefore (tmp, string()+"mov ["+sp_reg+"+"+to_string(-f->getStackFrameSize()-100)+"], "+scratch_reg);
insertAssemblyBefore (tmp, string()+"mov ["+sp_reg+"+"+to_string(-f->getStackFrameSize()-128)+"], "+scratch_reg);
tmp = insertAssemblyAfter (tmp, string()+"mov "+scratch_reg+", -" + to_string(num_locs));
const auto L1 = tmp = insertAssemblyAfter (tmp, string()+"mov dword ["+sp_reg+"+"+scratch_reg+"*4-4], " + to_string(m_init_value));
tmp = insertAssemblyAfter (tmp, string()+"inc "+scratch_reg);
tmp = insertAssemblyAfter (tmp, string()+"jnz 0", L1); // jnz to L1
tmp = insertAssemblyAfter (tmp, string()+"mov "+scratch_reg+", ["+sp_reg+"+"+to_string(-f->getStackFrameSize()-100)+"] ");
tmp = insertAssemblyAfter (tmp, string()+"mov "+scratch_reg+", ["+sp_reg+"+"+to_string(-f->getStackFrameSize()-128)+"] ");
// bump stats
m_num_transformed++;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment