[LLVMdev] Importing existing function declarations into LLVM C++ API

Duncan Sands baldrick at free.fr
Fri Apr 6 00:38:26 PDT 2012


Hi Dan,

> This is a tricky problem to search for on the llvmdev list as all the
> ways I can think of describing this seem to use pretty common keywords,
> so this may have been asked before.
>
> I'm looking for a way of importing or including existing function
> declarations or global variables into LLVM IR that I'm building manually
> using the API. These declarations are written in C++, so I guess there
> are two possible ways of doing this, either parsing and importing them
> using the Clang API (though I'm not particularly familiar with this) or
> compiling them to IR externally without running any optimisation passes
> and importing them from .ll files? Or maybe produce two separate modules
> and merge them?
>
> Is there anything in the codebase or the documentation that someone
> could point me to? Or any suggestions on how better to tackle this would
> be appreciated?

you should probably compile the C++ containing your definitions etc into
an IR module, which you then link with other modules as needed using the
linker API.

Ciao, Duncan.



More information about the llvm-dev mailing list