[LLVMdev] Proposal: function prefix data

Jevin Sweval jevinsweval at gmail.com
Thu Jul 18 09:45:32 PDT 2013


On Wed, Jul 17, 2013 at 9:06 PM, Peter Collingbourne <peter at pcc.me.uk> wrote:
>
> To maintain the semantics of ordinary function calls, the prefix data
> must have a particular format.  Specifically, it must begin with a
> sequence of bytes which decode to a sequence of machine instructions,
> valid for the module's target, which transfer control to the point
> immediately succeeding the prefix data, without performing any other
> visible action.  This allows the inliner and other passes to reason
> about the semantics of the function definition without needing to
> reason about the prefix data.  Obviously this makes the format of the
> prefix data highly target dependent.


What if the prefix data was stored before the start of the function
code? The function's symbol will point to the code just as before,
eliminating the need to have instructions that skip the prefix data.

It would look something like:
| Prefix Data ... (variable length) | Prefix Data Length (fixed length
[32 bits?]) | Function code .... |

            ^ function symbol points here (function code)

I hope the simple ASCII art makes it through my mail client.

To access the data, you do

prefix_data = function_ptr - sizeof(prefix_length) - prefix_length

Cheers,
Jevin



More information about the llvm-dev mailing list