search for: global_end

Displaying 15 results from an estimated 15 matches for "global_end".

2011 Dec 09
1
[LLVMdev] Finding the uses of a global variable
Hi everyone, I am writing a pass that finds all uses of global variables (my goal is to find the uses of strings, and strings are defined as global variables). So, I can iterate over global vars by for(Module::global_iterator gi = M.global_begin(), gend = M.global_end(); gi != gend; ++gi) ...... But if I use its def-use chain for(Value::use_iterator i = gi->use_begin(), e = F->use_end; i!=e; ++i) it is not actually able to find its uses, as it gives <null> instructions! I have even tried to iterate over instructions in the module, then find the use-d...
2012 Aug 18
1
[LLVMdev] GlobalVariable initializer using from beyond the grave
For LLDB I'm writing a dumb module pass that removes all global variables, by running the following code: bool erased = true; while (erased) { erased = false; for (Module::global_iterator gi = llvm_module.global_begin(), ge = llvm_module.global_end(); gi != ge; ++gi) { GlobalVariable *global_var = dyn_cast<GlobalVariable>(gi); if (global_var->use_empty()) { log->Printf("Did remove %s", PrintValue(glo...
2013 Apr 07
1
[LLVMdev] How to get the Instruction where one function use the global variable.
Hi, all I try to get the Instructions where one function use the global variable. for (llvm::Module::global_iterator gvar_iter = M.global_begin(); gvar_iter != M.global_end(); gvar_iter++) { llvm::GlobalVariable *gvar = &*gvar_iter; llvm::errs() << "const global var: " << gvar->getName() << "\n"; for ( llvm::GlobalVariable::use_iterator iter = gvar->use_begin(); iter != gvar->use_end(); it...
2017 Aug 29
5
Is the flow "llvm-extract -> llvm-link -> clang++ " supposed to be used in this way? To Extract and Re-insert functions?
Hi all, First post to the list, I hope you can help or guide me on this task. I am involved in a project that requires to re-link extracted and edited IR code Thus I want to know if these tools can be used in this way? clang++-4.0 code03.cpp -emit-llvm -S -o code03.ll llvm-extract-4.0 code03.ll -func main -S -o extracted_main.ll llvm-link-4.0 code03.ll -only-needed -override extracted_main.ll
2012 Dec 05
0
[LLVMdev] how to get and modify a global variable inside a module
...IR is intended to be compiled. A snippet of what I do looks like this: class TestClass : public llvm::ModulePass { public: TestClass() : llvm::ModulePass(TestClass::ID) { } virtual bool runOnModule(llvm::Module &m) { for (llvm::Module::global_iterator ii = m.global_begin(); ii != m.global_end(); ++ii) { GlobalVariable* gv = ii; // here you can modify the gv variable (actually I am creating new globals and deleting the old ones) for (llvm::Value::use_iterator jj = gv->use_begin(); jj != gv->use_end(); ++jj) { // jj is a reference for the user of the global va...
2013 Feb 28
0
[LLVMdev] how can I parse a Value* ?
...n 4 ) and also I need to get "DS" from @.str. In my target code I have : __attribute__((annotate("DS"))) int f=0; I have problems to parse @llvm.global.annotations and I assume I will have with @.str. What I tried: 1. for (Module::global_iterator I = F.global_begin(), E = F.global_end(); I != E; ++I) { if (I->getName() == "llvm.global.annotations") { Value *V = cast<Value>(I->getOperand(0)); errs()<<"\n "<<*(V)<<"\n"; errs()<<"\n "<<*(V->getType())<<"\n&quot...
2011 Nov 21
1
[LLVMdev] ModulePass and Strings
Hi everybody, I am writing an LLVM pass and I want to iterate over the whole module (including global variables), that's why I use ModulePass instead of FunctionPass. But I don't know how to do it. Using Module::iterator seams to iterate only over functions. But I need to iterate over all the Instructions in the module. How should I do such an iteration? Also, I would like to find all the
2012 Dec 05
2
[LLVMdev] how to get and modify a global variable inside a module
hi Eduardo, thanks for your attention, i checked the iterator, but i didn't see any fucntion can return or modify the main memory address of a global variable inside the module. can you provide some reference code or program can achieve this? thank you very much -- View this message in context:
2015 Jun 08
2
[LLVMdev] Removing AvailableExternal values in GlobalDCE (was Re: RFC: ThinLTO Impementation Plan)
...e, false) + +ModulePass *llvm::createElimAvailExternPass() { return new ElimAvailExtern(); } + +bool ElimAvailExtern::runOnModule(Module &M) { + bool Changed = false; + + // Drop initializers of available externally global variables. + for (Module::global_iterator I = M.global_begin(), E = M.global_end(); + I != E; ++I) { + if (!I->hasAvailableExternallyLinkage()) + continue; + if (I->hasInitializer()) { + Constant *Init = I->getInitializer(); + I->setInitializer(nullptr); + if (isSafeToDestroyConstant(Init)) + Init->destroyConstant(); + }...
2016 Mar 28
2
llvm extract struct elements and struct size in C++
...ce { class StructModulePass: public ModulePass { public: static char ID; StructModulePass() : ModulePass(ID) {} virtual bool runOnModule(Module &M1) override { // iterate over global structures M = &M1; int i; for(auto G = M->global_begin(); G!= M->global_end() ; G++, i++){ errs() << i << " == > " ; errs().write_escaped(G->getName()) << "\n"; } // iterate through each instruction. module->function->BB->Inst for(auto &F_ : M->functions()){ F = &F_; for(auto &B_ : *F)...
2015 Jun 08
4
[LLVMdev] Removing AvailableExternal values in GlobalDCE (was Re: RFC: ThinLTO Impementation Plan)
...on that instead. Ok, right in your case that is the benefit. Will update the comment. > > + MPM.add(createElimAvailExternPass()); > + } > > + // Drop initializers of available externally global variables. > + for (Module::global_iterator I = M.global_begin(), E = M.global_end(); > + I != E; ++I) { > + if (!I->hasAvailableExternallyLinkage()) > + continue; > + if (I->hasInitializer()) { > + Constant *Init = I->getInitializer(); > + I->setInitializer(nullptr); > + if (isSafeToDestroyConstant(Init)) > +...
2006 Mar 19
1
[LLVMdev] Idioms for retrieving global symbols and inheritance
Hello, I have a couple of doubts, as listed below: 1. To list all the global variables in the module, I am iterating using type_iterator and for each Type I get, I am using value_iterator to iterate over Values . In the second iteration I am getting unexpected results. For each type obtained from type_iterator->second, value_iterator->first produces the same list as what
2015 Jun 04
5
[LLVMdev] Removing AvailableExternal values in GlobalDCE (was Re: RFC: ThinLTO Impementation Plan)
On Thu, Jun 4, 2015 at 3:58 PM, Duncan P. N. Exon Smith < dexonsmith at apple.com> wrote: > > > Personally, I think the right approach is to add a bool to > createGlobalDCEPass defaulting to true named something like > IsAfterInlining. In most standard pass pipelines, GlobalDCE runs after > inlining for obvious reasons, so the default makes sense. The special case > is
2015 Jun 05
2
[LLVMdev] Removing AvailableExternal values in GlobalDCE (was Re: RFC: ThinLTO Impementation Plan)
On Thu, Jun 4, 2015 at 5:33 PM, Reid Kleckner <rnk at google.com> wrote: > On Thu, Jun 4, 2015 at 5:17 PM, Teresa Johnson <tejohnson at google.com> wrote: >> >> Agreed. Although I assume you mean invoke the new pass under a >> ThinLTO-only option so that avail extern are not dropped in the >> compile pass before the LTO link? > > > No, this pass
2015 Dec 03
3
Function attributes for LibFunc and its impact on GlobalsAA
----- Original Message ----- > From: "James Molloy via llvm-dev" <llvm-dev at lists.llvm.org> > To: "Vaivaswatha Nagaraj" <vn at compilertree.com> > Cc: "LLVM Dev" <llvm-dev at lists.llvm.org> > Sent: Thursday, December 3, 2015 4:41:46 AM > Subject: Re: [llvm-dev] Function attributes for LibFunc and its impact on GlobalsAA > >