Indeed, IRBuilder
does not expose an interface to do that, but you can create it manually - e.g. by using the constructors of GlobalVariable
. You can store all the pointers in an array using conversion constant expressions, i.e. by generating:
@global = global [4 x i64*] [
i64* bitcast (void()* @f to i64*),
i64* bitcast (float(i32)* @g to i64*),
...
]
So, use ConstantExpr::getBitCast()
to generate the casts from the Function
to the array element type (which should preferrably be a pointer, I don't see the advantage in storing an i64
). Then create a new GlobalVariable
in the module and initialize it with all the constant expressions you've created.