See DebugInfo.h for the mappings from the C++ LLVM debug info APIs to the C bindings. Examples that you'll need are:
- new DIBuilder -> LLVMCreateDIBuilder()
- DIBuilder::createFile() -> LLVMDIBuilderCreateFile()
- DIBuilder::createCompileUnit() -> LLVMDIBuilderCreateCompileUnit()
- DIBuilder::createBasicType() -> LLVMDIBuilderCreateBasicType()
(use those functions to setup the dwarf context for your compiler)
The LLVMSetCurrentDebugLocation() function you mentioned is the equivalent of IRBuilder<>::SetCurrentDebugLocation()
For each debug expression, you want a debug location, and DWARF metadata for the expression. That's done like the following (C++ fragment):
auto loc_glc = DebugLoc::get( line, column, dwFunc );
m_dwBuilder->insertDeclare( r, dwVar_gr, m_dwBuilder->createExpression(), loc_glc, fooBB );
m_builder.SetCurrentDebugLocation( loc_glc );
you'll want to associate the debug location with the DWARF expression, and then "anchor" that to your IRBuilder using LLVMSetCurrentDebugLocation().
llvm
mailing list, perhaps llvm-dev – Savina