[llvm-dev] Global variables in C
Umesh Kalappa via llvm-dev
llvm-dev at lists.llvm.org
Fri Aug 30 10:43:04 PDT 2019
Hi All,
For our requirement ,we are creating the global variables like
GlobalValue *GV = new GlobalVariable(M, Type::getInt32Ty(*Context), false,
GlobalValue::ExternalLinkage, nullptr,
Name);
where "Name" is the global name with "Extern or Internal" Linkage .
Say "Name=foo" is already in the Module and when we try to create
"GlobalVariable" Instance again for "Name=foo" ,the current semantics
of GlobalVariable() is that ,it renames like "foo.<random number>" i.e
"foo.10" .
Currently we are overriding this semantics by iterating the
Module.globals() and if "Name"doesn't exist ,the we are creating the
new instance else we get the reference to it .
Is that better way to do so ?
Thank you
~Umesh
More information about the llvm-dev
mailing list