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

Tom Roeder tmroeder at google.com
Wed May 21 16:53:10 PDT 2014


On Wed, May 21, 2014 at 4:42 PM, Rafael EspĂ­ndola
<rafael.espindola at gmail.com> wrote:
>>> At the llvm level such a transformation would only be valid if the
>>> function was marked with unnamed_addr. You should probably check for
>>> that and have a clang option that adds unnamed_addr to every function.
>>
>> I'm not sure what "check for that" means in this case. In my example,
>> the declaration of @f in M1 would need to be marked unnamed_addr based
>> on whether or not M2 had a definition @f with jumptable, and that's
>> something that's not known when M1 is compiled.
>
> Which is why I suggested a clang option that would add unnamed_addr to
> every function. Declaration or not.
>
>> It wouldn't be hard to add a clang option to do this, but even that's
>> technically not sufficient, since it could still cause problems with
>> modules compiled without the flag or compiled with a different
>> compiler.
>
> Well. The reasoning is that if the user says that a function
> declaration is unnamed_addr and has another file where that address is
> significant he will get undefined behaviour.
>
>> I think this shows that jumptable really does affect the
>> ABI, like Nick suggested. I don't know if this kind of pointer
>> equality is formally guaranteed at that level, however. Do you know?
>
> It is guaranteed, except for unnamed_addr. How about just requiring
> that jumptable can only be added to functions that also have
> unnamed_addr?

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.




More information about the llvm-commits mailing list