[LLVMdev] should PEI::calculateFrameObjectOffsets align the stack?

Rafael EspĂ­ndola rafael.espindola at gmail.com
Fri Oct 6 06:08:26 PDT 2006


In ARM the stack should be 8 bytes aligned during function calls. A
function that has at least one  function call then has a stack size of
8 bytes. PEI::calculateFrameObjectOffsets corretly computes this
correctly.

The problem is that the alignment is computed before adding space for
the call frame size. This is done in emitProlog. Currently the ARM
backend has a bug in that it doesn't align the new stack.

Fixing this bug is simple, but it introduces an inefficiency due to
aligning twice. For example, consider f:

-------------------------------------------------
void g(int a, int b, int c, int d, int e);

void f(void) {
 g(1,2,3,4,5);
}
--------------------------------------------------

It needs only 8 bytes for the stack (4 bytes for SP and 4 for "e").
But PEI::calculateFrameObjectOffsets will align to 8 and, after adding
the call frame, the stack will be aligned to 16.

I see two options:
1) make PEI::calculateFrameObjectOffsets consider the call frame before aligning
2) don't align at all in PEI::calculateFrameObjectOffsets.

Best Regards,
Rafael



More information about the llvm-dev mailing list