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

Rafael EspĂ­ndola rafael.espindola at gmail.com
Wed May 21 15:42:40 PDT 2014


> Right. Any code that assumes pointer equality between modules for a
> function declared as jumptable in both modules will fail.  Now that I
> think about it, this is true even without putting jumptable into two
> separate modules, and without adding jumptable to external functions.
>
> For example, consider two modules: module M1 declares @f as a normal
> undefined function, and module M2 defines @f as jumptable. If M2
> passes a function pointer for @f to M1, it will pass @f_JT. @f_JT will
> still work perfectly as a function pointer for @f except it will
> happen not to have the same function pointer value as @f. So, equality
> comparisons with @f will fail.
>
> Is this OK?

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.

Cheers,
Rafael



More information about the llvm-commits mailing list