[LLVMdev] Controlling the stack layout
Bill Wendling
isanbard at gmail.com
Mon Dec 29 17:36:47 PST 2008
Hi Nicolas,
>> This might help. See how "stack protectors" is implemented here:
>>
>> lib/CodeGen/StackProtector.cpp
>>
>> It places a special value at a specific place on the stack. You can
>> use the same trick to put your own information on a set stack
>> position. There's more to the code than just that .cpp file. It's
>> done
>> with intrinsics. You'll also need to check out the
>> PrologEpilogInserter.cpp code.
>>
>>
> Thanks. I've already looked at what stack protector does, and indeed
> the
> need is similar. However, I'd like to add the functionality as a new
> machine pass, so that I don't need to add new intrinsics and modify
> the
> llvm code base. Do you think that's possible?
>
I suppose that it's possible, though not as elegant. :-) What type of
information are you storing? Is it stuff that is known before we
convert the LLVM IR into its DAG format for the back-end? If so, then
it's probably cleaner to go the way of the stack protector. It's
easier to send this information to the back-end so that it knows how
to set up the prologue and epilogue. I'm not too familiar with the
JIT, so I don't know if making this a machine function pass will work.
In all, modifying LLVM to create a new intrinsic (a la stack
protectors) isn't all that much work. ;-) And modifying LLVM IR is
*much* easier than modifying its DAG format.
-bw
More information about the llvm-dev
mailing list