[llvm-dev] Wiring a function into a new DICompileUnit

Nathan Schagen via llvm-dev llvm-dev at lists.llvm.org
Wed Jul 6 15:51:37 PDT 2016

Hi llvm users,

I'm using CloneFunctionInto() move a function to another module. This
function is actually a different version of a function that already exists
and I want to make it debuggable. It has all the metadata, but it needs to
be rewired to make it easy to debug in gdb.

I would like to make a fake compile unit and add the function
(DISubprogram) to it. All scope references of the metadata (e.g local vars)
must also point to the DIFile that is associated with the new compile unit.
I have the source of the function so I can let the DIFile point to the
actual file.

I've been studying the llvm 3.7 sourcecode but it's not obvious to me how
to do this. Creating a new DICompileUnit with a DIFile and adding the
DISubprogram is easy, but how can I rewire all scope references in the
function's metadata to the new DIFile entry? Can I use MapMetadata for this?

I know it's a rather complicated scenario, but I hope someone can give me
some pointers to look into.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20160707/50b9895a/attachment.html>

More information about the llvm-dev mailing list