Calling convention & patchable functions.
kavon opened this issue · 5 comments
Since we embed the pristine bitcode before optimization, we don't know whether some internal function has had its calling convention changed to, say, fastcc
. The HaloPrepare
pass should embed information in an additional data section that describes the calling convention of the function.
In addition, since it's probably not profitable to mark all functions as being patchable with XRay as we do now, we may want to use this same information to describe what functions in the final output code are patchable.
Consider that the function's arguments / signature may also change without changing the function's name. Thus, you need to be embedding the post-optimize bitcode just before codegen.
Actually another idea would be to make all patchable function symbols external before the optimization pipeline runs so that the optimizer doesn't change the calling convention or mess with the arguments.
This should be done in the HaloPrepare pass, which needs to run at the very beginning of the pass pipeline. What it should be doing is determining which functions should be made patchable by marking with xray attribute and making it externally visible.
I believe this is the reason why #12 is seeing a failure at higher optimization levels: can't find the function symbol because it became internalized by the optimizer.
This has been fixed by marking the functions as extern.