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

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


> 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.

I see. Special casing alias in this sense is correct. It seems that
for every use of a function you want to

* if it is a call, leave it.
* if in is not a call and not an alias, replace it
* if it is an alias, replace every use of the alias, but leave the alias as is.

Is that correct?

BTW, how do you handle external functions? Just don't process them and
depend on LTO to make the pass more applicable?

Cheers,
Rafael



More information about the llvm-commits mailing list