We switched from compiling LLVM with gcc to clang (3.3) and it appears that clang (correctly I think) optimizes away the GDBRegistrar’s __jit_debug_register_code() function that’s used to trigger reading debug info from JIT-ted code, breaking GDB support.
This patch forces it to leave the call using the method described here in the ‘noinline’ section:
GDBRegistrar.patch (553 Bytes)
Use asm volatile("":::"memory") to make sure that it doesn't leave
trackes. The noinline can likely go in that case...
I’ve made the change you suggested and verified that it still works. I think the noinline is still required though as this function can be called from a couple of places and gdb will want to set its breakpoint on the single function address. Let me know if you think otherwise though.
GDBRegistrar.patch (573 Bytes)
LGTM with a comment explaining the issue.
Hi Rafael, comment explanation added now. Thanks.
GDBRegistrar-2.patch (735 Bytes)
LGTM. Do you have commit access?
I don’t have commit access, I wasn’t sure if this was the right protocol to get a patch accepted but just let me know if not and I’ll get it right the next time.
Wouldn’t LLVM_ATTRIBUTE_USED be the correct thing here to prevent dead stripping, if that’s the problem?
My understanding is that they want the calls to not be removed, not
just to keep the symbol. Andrew, is my understanding correct?
I tweaked the comment a bit and committed as r199350.