(no subject)

Hello,

I am trying to add an instruction before each function call to add/subtract the stack pointer by a value specified at the command line.
I wonder if I can do that during lowering. For example, in X86TargetLowering::LowerCALL. I appreciate it if you give me some hints how and where I can do that.

Thank you,
Babak

Hi,

During isel lowering, the backend insertes CALLSEQ_START / CALLSEQ_END target independent nodes to the DAG. These are then selected to X86 specific instructions ADJCALLSTACKDOWN / ADJCALLSTACKUP. At these point, they have a constant arguments which corresponds to the fixed frame size for argument passing. But the size of the stack frame isn't finalized until frame layout has been completed, these are not translated into stack dec / inc until very late (see X86RegisterInfo.cpp::eliminateCallFramePseudoInstr).

May I ask why are you adding a command line option to control stack frame size? If you must do it, it should be separate from the general mechanism. You can add a couple of special instructions that are "flagged" to the CALLSEQ nodes that will be emitted as stack inc / dec code.

Evan

Thank you Evan for your quick and helpful answer.
Actually, I want to add padding between function arguments and the return address. I am doing this only for research purposes.

Thank you again,
Babak