[LLVMdev] replacing a global variable by a constant

Duncan Sands baldrick at free.fr
Wed Oct 5 01:56:09 PDT 2011

Hi nada,

> i want  replacing a global variable by a constant  value for erase instruction.

I'm not sure what you mean exactly.  A GlobalVariable has pointer type.  Do you
want to replace that pointer by a constant pointer?  Or is it rather that you
want to say that the contents of the memory pointed to by the GlobalVariable is
constant, and have all places that load that GlobalVariable use the constant

Ciao, Duncan.

> i had seen the code that as follows
> for (llvm::GlobalVariable::use_iterator U = gv->use_begin(); U != gv->use_end();--U ) {
>      llvm::Instruction *I = llvm::cast<llvm::Instruction>(U);
>      I->replaceAllUsesWith(constPtr);
>      I->eraseFromParent();
> }
> but i dont know how can declare constptr.
> _______________________________________________
> LLVM Developers mailing list
> LLVMdev at cs.uiuc.edu         http://llvm.cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev

More information about the llvm-dev mailing list