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

Tom Roeder tmroeder at google.com
Wed May 21 14:16:13 PDT 2014


On Wed, May 21, 2014 at 1:48 PM, Rafael EspĂ­ndola
<rafael.espindola at gmail.com> wrote:
>> Interesting. I didn't know you could do that. Will that global
>> variable work in all address-taken contexts as a replacement for a
>> function symbol in IR?
>
> With appropriate casting it should, yes.

After experimenting with this for a bit, I realized that my original
statement about the ideal case for GlobalAlias rewriting was wrong.
I'd said it would be best if I could just replace the alias target
with the jumptable function symbol. Your suggestion indeed seems to
solve that problem and get around the issues I ran into with undefined
functions.

However, looking more closely at the code, it looks like direct calls
to GlobalAliases turn into direct calls in the resulting assembly. For
efficiency reasons, I don't want direct calls to go through the
jumptable functions, so simply replacing the alias with any single
value won't work; the pass actually needs to go through the code and
replace the indirect uses and not replace the direct uses.

Given that it looks like the pass has to walk the aliases as a special
case, are you OK with me using my original function declaration
solution? It seems to me like using a function symbol makes the IR
match the eventual assembly more closely, since the jumptable symbol
is going to turn into a real, if somewhat unusual, function. The only
reason the declared function was a problem was in trying to replace a
GlobalAlias target, and that's not going to be needed anymore.

Thanks,

Tom




More information about the llvm-commits mailing list