[LLVMdev] Global Variable Recall

John Criswell criswell at illinois.edu
Tue Sep 10 12:01:07 PDT 2013


On 9/10/13 1:50 PM, Rasha Omar wrote:
> Hi All,
>
> I need to call global variable by its name from the following code
>
>  for(Function::iterator i=F->begin();i!=F->end();++i)
>       {
>     BasicBlock*Bb =&*i;
>     GlobalVariable* GV = new GlobalVariable(type,false, 
> F->getLinkage(),0,  "F$"+Bb->getName());
>     GV->setInitializer(Constant::getNullValue (typ));
>     GList.push_back(GV);
>       }
>
> Could I solve that by mapping the global variables in Stringmap?

If you know the name of the GlobalVariable that you want to find, you 
can use the Module::getGlobalVariable() method to get a pointer to it:

http://llvm.org/doxygen/classllvm_1_1Module.html#a17ebd56685ee19e7761ae577cd511e25

-- John T.

> I need to identify the global variable with its name in the IR to be 
> able to load and store its values.
>
> Thanks
>
>
> -- 
> *Rasha Salah Omar
> Msc Student at E-JUST
> Demonestrator  at Faculty of Computers and Informatics
> Benha University*
>
> *e-mail: rasha.omar at ejust.edu.eg <mailto:rasha.omar at ejust.edu.eg>*
>
> P* Please consider the environment before printing this email.*
>
>
>
> _______________________________________________
> LLVM Developers mailing list
> LLVMdev at cs.uiuc.edu         http://llvm.cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20130910/7a1cb0de/attachment.html>


More information about the llvm-dev mailing list