[llvm-dev] RFC: New function attribute "patchable-prologue"="<kind>"

Sanjoy Das via llvm-dev llvm-dev at lists.llvm.org
Wed Apr 6 10:52:26 PDT 2016



Mehdi Amini wrote:
>> On Apr 6, 2016, at 12:10 AM, Sanjoy Das via llvm-dev<llvm-dev at lists.llvm.org>  wrote:
>>
>> [Proposed langref entry]
>>
>> The "patchable-prologue" attribute on a function is a general
>> mechanism to control the form of a function's prologue in ways that
>> make it easy to patch at runtime.
>>
>> Currently only one value is supported:
>>
>> # "hotpatch-compact"
>>
>> If a function is marked with "patchable-prologue"="hotpatch-compact"
>> then:
>>
>> 1. The first instruction of the function is at least two bytes long.
>
> IIRC the motivation is to insert a branch instruction in a thread-safe way?

Yes.

> Isn’t the “two bytes” something that is target specific?

Yes, that's a good point.  I can think of two ways to fix this:

  - Change the spec to say "large enough to accommodate a short jump 
instruction"

  - Rename the "hotpatch-compact" scheme to "hotpatch-compact-x86-64" 
and basically live with the fact that it is a target specific attribute.

I like the first one better, but I can live with either since at this 
time I really only care about x86_64.

-- Sanjoy


More information about the llvm-dev mailing list