Editing metadata

Hi all,

I’m using the JIT capabilities of LLVM. But so far, I’ve been unable to use the debug capabilities of LLVM in conjunction with the JIT. The problematic scenario goes as follow :

  • Emit some IR with debug infos.

  • Install hooks to get back into some codepath that I do not wish to codegen at this stage.

  • JIT the method. This require to finalize the DIBuilder to complete the emission of debug metadata.

  • Later on, emit IR for some of the missing branches. Here the problem surface :

  • Without debug infos, the codegen for this specific method can be invalidated and redone, all is fine.

  • With debug infos, the metadata have been finalized already, and it doesn’t seems that it is possible to revert this

Is there a way to make that work ? If not, is there a patch I can work on to make that work ?

Thank in advance,

Abstractly, (I don’t get inside this code as much as I should) debug info works on a translation-unit basis, not a function basis, so regenerating a single function’s debug info is not a natural or well-isolated operation.

You might have to emit each function as its own LLVM module and re-JIT the module?

People more deeply familiar with how the metadata stuff works might be able to offer better suggestions.

–paulr

This is about the best idea. There’s no way to take the non-temporary md nodes back to temporary.

-eric

Ok, so my best shot at this would be to just throw away existing debug infos and regenerating new ones, if I understand you.

That would work, I was hoping for something better, but it will do. Thank you.

Yep. That’s your best bet. I think if you’re effectively regenerating the IR from scratch (it’s what it feels like to me) then you should probably regenerate the debug information. If you were just deciding to optimize it after a run or two then that should be fine and be able to get updated.

-eric