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

Tom Roeder tmroeder at google.com
Wed May 21 13:03:10 PDT 2014


On Wed, May 21, 2014 at 12:58 PM, Rafael EspĂ­ndola
<rafael.espindola at gmail.com> wrote:
>> Oh wait. Another way of interpreting your suggestion is to make a list
>> of GlobalAliases to replace and only do the replacement at the end,
>> when there's actually a symbol to use. Yes, I think that could be made
>> to work. I'll look into it.
>
> No, the idea was to replace code that stores a function pointer into
> code that stores a dummy global variable:
>
> @jump_table_entry1 = global i8 0, section "llvm.metadata"
> @func_pointer = global i8* null
> define void @store_func_ptr() {
>   store i8* @jump_table_entry1, i8** @func_pointer
>   ret void
> }
>
> later in the pipeline you can turn @jump_table_entry1 into an actual
> table entry. That is what I mean by "like llvm.used". It is not that
> it is a list, just that is a fake variable that then gets converted to
> something else. It would be nice to have a more explicit say to
> represent those, but there is precedent for just using a global
> variable in the llvm.metadata section.
>
> Cheers,
> Rafael

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?




More information about the llvm-commits mailing list