Displaying 16 results from an estimated 16 matches for "global_iterator".
2010 Jan 25
1
[LLVMdev] Deterministic code generation and llvm::Iterators
Guys,
It seems as though the llvm system doesn't deterministically iterate over
Module::iterator, or global_iterator. To make myself clearer, the iterators
iterate over all the global_variables but on different llvm passes
(different calls to opt -load), the iterators iterate over them in different
orders.
I was thinking that it has something non deterministic to do with byte code
reading or the llvm system init...
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 inst...
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("Di...
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 ite...
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
Hi Dong Chen,
You can write a ModulePass class and implement a runOnModule method.
Inside this method you can access Module::global_iterator and get a
reference to all global variables of a module. With this reference,
you can change this variable. But be careful, you may need to change
also the references to those variables. Have a look to the method
GlobalVariable::use_begin and use_end. They give you references to the
users of the gl...
2012 Dec 05
0
[LLVMdev] how to get and modify a global variable inside a module
...the IR. It modifies global variables and
the final 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) {
//...
2013 Feb 28
0
[LLVMdev] how can I parse a Value* ?
...ow the definition of @f = global
i32 0, align 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 "<<...
2005 Mar 15
0
[LLVMdev] Consistency patches to Module and Function
Dear llvm-devs,
we discussed a consistency issue with the naming of
iterators in the #llvm IRC channel and I came up
with a patch to Module.h and Function.h.
The patch renames the aiterator family of typedefs
to arg_iterator in Function and correspondingly
giterator and friends to global_iterator.
The accessor functions also change accordingly.
Right now the old spellings are preserved, but
will go away after some time. So this is a heads-up
to do a global replace in your non-LLVM-CVS codes
from the old names to the new ones.
The change is blessed by Chris Lattner and the
others on IRC se...
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:
2012 Dec 05
4
[LLVMdev] how to get and modify a global variable inside a module
recently, i use LLVM API to write a program to read *.ll and excute it
automatically.
Further more, i want to change some global variables inside a module.
i tried some functions provided by Module.h and ExecutionEngine.h but none
were seemed to match my need.
did someone have the experience or some advices?
thank you ;)
--
View this message in context:
2015 Jun 08
2
[LLVMdev] Removing AvailableExternal values in GlobalDCE (was Re: RFC: ThinLTO Impementation Plan)
...inate Available External Globals", false, 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))
+...
2015 Jun 08
4
[LLVMdev] Removing AvailableExternal values in GlobalDCE (was Re: RFC: ThinLTO Impementation Plan)
...an reduce object file size, so I'd mention 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 (i...
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
>
>