Displaying 20 results from an estimated 21 matches for "global_begin".
2013 Aug 02
5
[LLVMdev] Coding Standards: Iterator begin and end functions.
...classes that look
like STL ones should use similar names for the methods (begin(),
push_back(), etc...).
But different parts of llvm have different opinions on how to handle
the related case of classes that are not STL like, but have multiple
collections that can be iterated over.
* llvm/IR uses global_begin, alias_begin, etc. I.E., singular name + _begin().
* llvm/Object uses begin_symbols, begin_sections, etc. I.E, begin_ +
plural name.
* others (YAML, LoopIterator) use beginSequence, beginFlowSequence, etc.
I would like to propose adding the the format used by llvm/IR to the
coding standard since i...
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 modu...
2013 Aug 02
0
[LLVMdev] Coding Standards: Iterator begin and end functions.
...should use similar names for the methods (begin(),
> push_back(), etc...).
>
> But different parts of llvm have different opinions on how to handle
> the related case of classes that are not STL like, but have multiple
> collections that can be iterated over.
>
> * llvm/IR uses global_begin, alias_begin, etc. I.E., singular name +
> _begin().
> * llvm/Object uses begin_symbols, begin_sections, etc. I.E, begin_ +
> plural name.
> * others (YAML, LoopIterator) use beginSequence, beginFlowSequence, etc.
>
> I would like to propose adding the the format used by llvm/IR t...
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",...
2013 Dec 20
2
[LLVMdev] [LLVM] What has happened to LLVM bitcode archive support?
...bitcode files, using code in LLVM trunk, my only choice at the
moment is to...
1. Collect a set of undefined symbols from the destination module.
2. Load **all** the `llvm::Module`s in the archive into memory
3. Iterate over each module's GlobalValues (does the list starting
with llvm::Module::global_begin() include the module's functions
too??) and if a GlobalValue in a module is not a declaration and is in
the set of undefined symbols then link that module into the
destination module using Linker::LinkModules()
4. Update the set of undefined symbols
5. repeat 1 and 2 until a fixed point (the se...
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(); i...
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
...obal 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) {
// jj is a reference fo...
2013 Feb 28
0
[LLVMdev] how can I parse a Value* ?
...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 "<<*(V->getType())&...
2013 Aug 02
0
[LLVMdev] Coding Standards: Iterator begin and end functions.
...ould use similar names for the methods (begin(),
> push_back(), etc...).
>
> But different parts of llvm have different opinions on how to handle
> the related case of classes that are not STL like, but have multiple
> collections that can be iterated over.
>
> * llvm/IR uses global_begin, alias_begin, etc. I.E., singular name + _begin().
> * llvm/Object uses begin_symbols, begin_sections, etc. I.E, begin_ +
> plural name.
> * others (YAML, LoopIterator) use beginSequence, beginFlowSequence, etc.
>
> I would like to propose adding the the format used by llvm/IR to th...
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)
...al 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))
+ Init->destro...
2016 Mar 28
2
llvm extract struct elements and struct size in C++
...mespace llvm;
namespace {
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_;...
2015 Jun 08
4
[LLVMdev] Removing AvailableExternal values in GlobalDCE (was Re: RFC: ThinLTO Impementation Plan)
...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 (isSafeToDestroyConst...
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
2013 Oct 28
0
[LLVMdev] [cfe-dev] RFC: A proposal to move toward using C++11 features in LLVM & Clang / bounding support for old host compilers
...would also love to use standard types like std::unique_ptr, move semantics, etc without worrying about conditional code or reinventing them in the llvm ADT library. I also have a personal love affair for range-based for loops, and I expect a number of awesome new adaptors to paper over the Module::global_begin() sorts of ranges. It would also be great to get something like python's enumerate function etc. In short, you don't have to convince me about the benefits of dropping old compilers! :-)
At root, my conservatism comes from not wanting to hurt adoption of LLVM. The hosts that I specifica...
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
2013 Oct 28
2
[LLVMdev] [cfe-dev] RFC: A proposal to move toward using C++11 features in LLVM & Clang / bounding support for old host compilers
On Sun, Oct 27, 2013 at 11:18 AM, Chris Lattner <clattner at apple.com> wrote:
> On Sun, Oct 27, 2013 at 2:23 AM, Chandler Carruth <chandlerc at google.com>
> wrote:> Concrete long term proposal:
> >
> > We support building with C++ toolchains which were released and widely
> available on their respective target platforms at least 2 years prior to
> the next
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