[llvm-dev] Question about global variable type

Tim Northover via llvm-dev llvm-dev at lists.llvm.org
Tue Jan 22 05:33:58 PST 2019

On Tue, 22 Jan 2019 at 13:22, Mahesha S via llvm-dev
<llvm-dev at lists.llvm.org> wrote:
> auto globalVar = M.getOrInsertGlobal("myVar", varType);

Globals (as an instance of Value) have a type that's a pointer to the
allocated storage. So in this case globalVar->getType() is actually
"i32*" rather than i32. GlobalValue::getValueType will return the
underlying type.

You could use Type::dump to see this kind of thing more quickly in future.



More information about the llvm-dev mailing list