Skip to content
Snippets Groups Projects
Commit 7c671b68 authored by Christian Dietrich's avatar Christian Dietrich
Browse files

x86: Supporting Stack-Switch on function call

modified X86FrameLowering.cpp as well as X86RegisterInfo.cpp.
added corresponding testcases: test/CodeGen/X86/stackswitch-symbol-*.ll

X86FrameLowering.cpp:
[emitPrologue]
Now each function is queried whether it has the function attribute
"stackswitch-sp-symbol" set or not. If it is set we assume that it's string
value is a global variable and then proceed to load the value of the global
variable into %esp. This happens exactly after moving the
old value of %esp to %ebp.
[emitEpilogue]
Also, because we now have a situation where the function arguments are on the
old stack but local variables are on the new stack, the %esp is being reset to
the last callee saved slot before popping them off.  (Same procedure as with
dynamic alloca being in use)

X86RegisterInfo.cpp:
As the %ebp is still pointing to the old stack, it can still be used as an
argument pointer. But the local variables are residing on the new stack, so
they have to be addressed by another register. This is done by using a
BasePointer (NOT %ebp, but some other register).

testcases:

stackswitch-symbol-basic.ll
Calls a function which changes the stack and returns the paramater it was given.

stackswitch-symbol-recursive.ll
After the stackswitch another recursive function is being called.
(The function which changes the stack must not be recursive by itself!)

stackswitch-symbol-dynamic.ll
The stack switching function uses it's paramter for dynamic memory allocation
on the stack.
parent d5784797
No related branches found
No related tags found
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment