[PATCH] Add a jumptable attribute and support for creating jump-instruction tables

Nick Lewycky nicholas at mxc.ca
Wed May 21 19:57:59 PDT 2014


Rafael EspĂ­ndola wrote:
>> That sounds fine to me, since as you note, I can add passes either in
>> LLVM or clang to add unnamed_addr to all or a subset of functions
>> first.
>>
>> Even better for me would if jumptable implies unnamed_addr: as part of
>> the transformation, the jumptable pass will add unnamed_addr to every
>> function marked with jumptable. Will that work?
>>
>> Then there's no need to add unnamed_addr with a clang option or a
>> special pass, since anything marked as jumptable will get
>> unnamed_addr.
>
> It would work. I am not sure how I feel about having an attribute that
> is a superset of another. Nick, what do you think?

We already do that a bit. sret implies noalias and nonnull, readnone 
implies readonly, etc. I'd rather the we kept the two attributes 
separate in the IR and set them independently (for example, refuse to 
mark 'jumptable' on a function that isn't 'unnamed_addr' if necessary to 
avoid miscompiles).

I'm a bit surprised that the resolution appears to be that the jumptable 
transform requires an ABI break (ie., that we can't guarantee that 
&func1 == &func2 is preserved across all combinations of mixing .o files 
with and without jumptable transform applies). Is that correct, thinking 
from a generated .o-files point of view. (Relatedly, I hear there are 
similar patches in the works for GCC. Will we be ABI-compatible or 
incompatible with the GCC implementation?)

Nick



More information about the llvm-commits mailing list