-
- Downloads
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.
Showing
- lib/Target/X86/X86FrameLowering.cpp 25 additions, 7 deletionslib/Target/X86/X86FrameLowering.cpp
- lib/Target/X86/X86RegisterInfo.cpp 3 additions, 0 deletionslib/Target/X86/X86RegisterInfo.cpp
- test/CodeGen/X86/stackswitch-symbol-basic.ll 34 additions, 0 deletionstest/CodeGen/X86/stackswitch-symbol-basic.ll
- test/CodeGen/X86/stackswitch-symbol-dynamic.ll 26 additions, 0 deletionstest/CodeGen/X86/stackswitch-symbol-dynamic.ll
- test/CodeGen/X86/stackswitch-symbol-recursion.ll 30 additions, 0 deletionstest/CodeGen/X86/stackswitch-symbol-recursion.ll
Loading
Please register or sign in to comment