Search code examples
c++llvmllvm-irllvm-c++-api

How to define a LLVM GlobalValue variable in C++ with llvm-10 library?


In LLVM-10 library, I didn't find any C++ API to define a LLVM GlobalValue, please help me.

Here's document of LLVM-10 GlobalValue. But the constructor of GlobalValue is protected, not public.


Solution

  • GlobalValue is a common base class for Function and GlobalVariable. It is not intended to be used directly, so you most probably want GlobalVariable, which does have public constructor: https://llvm.org/doxygen/GlobalVariable_8h_source.html#l00050