search for: getglobalvariable

Displaying 20 results from an estimated 29 matches for "getglobalvariable".

2006 Mar 26
1
[LLVMdev] A question about Module::getGlobalVariable()
I want to find a global variable by name in some module , I find LLVM function Module::getGlobalVariable(string name,Type* ty); My question is , is it necessary to specify the global variable type (second param) ? Why not just getGlobalVariable(string name). I look up the source , and find that it depend on SymbolTable.find() and SymbolTable only support find with type .is it True ? or I make someth...
2007 Sep 22
4
[LLVMdev] RFC: Patch
...t time through, the variable's created and all is good. It has "internal global" linkage, which is correct. The second time through, it tries to look up that variable in the module, but because it has "internal global" (and not "external global") linkage, the "getGlobalVariable()" method returns null. This patch uses the "getNamedGlobal" method, which ignores whether it's internally or externally global. My question is, is this liable to break something else down the line? Should it be modified to call the getNamedGlobal method only if it's an Obj...
2007 Sep 22
0
[LLVMdev] RFC: Patch
Hi Bill, why not just add "true" to the getGlobalVariable call? GlobalVariable *getGlobalVariable(const std::string &Name, bool AllowInternal = false) const; Ciao, Duncan.
2012 Sep 19
3
[LLVMdev] newbie question on getelementptr
Hi All, I'm new to LLVM and I'm having a coding problem. I'm creating a GlobalVariable that contains a StructType that contains a Function. The function returns i32 and takes two i32's. Here is my code: GlobalVariable* retrieved = module->getGlobalVariable("myGV"); ... Constant* result = ConstantExpr::getGetElementPtr(retrieved, indices); How do I get my Function back from the Constant* result? I'd like to be able to run the function. result->dump() shows the following: i32 (i32, i32)** getelementptr inbounds (%myStruct* @myGV, i32...
2015 Sep 14
2
JIT: Mapping global variable in JIT'ted code to variable in running program
...rintf("myglobal: %d\n", myglobal); } int main(int argc, char *argv[]) { // This file, jit.cpp has been compiled to bitcode (clang -S -emit-llvm jit.cpp) // and is read into Module M here Module *M = ... ExecutionEngine *ee = ... myglobal = 42; ee->addGlobalMapping(M->getGlobalVariable("myglobal"), (void*)&myglobal); ee->finalizeObject(); void(*fptr)() = (void(*)())ee->getFunctionAddress("printMyGlobal"); fptr(); printMyGlobal(); } // end file jit.cpp I compile this file (jit.cpp) into bitcode which I then load int M. M also contains a gl...
2012 May 23
0
[LLVMdev] lli unable to resolve symbol _ZNKSt3__16locale9use_facetERNS0_2idE in bitcode
...les and running lli, nobody has defined it. It seems reasonable to me that lli should define __dso_handle if it's declared in the module. You could module tools/lli/lli.cpp to add a global: char *dummy_dso_handle = 0; and tie it to __dso_handle via. if (GlobalVariable *DSO = Mod->getGlobalVariable("__dso_handle")) if (!DSO->hasInitializer()) EE->updateGlobalMapping(DSO, &dummy_dso_handle); somewhere in main(), say after disabling lazy compilation. Entirely untested though; we might need to give dummy_dso_handle a real value. Nick > tia > > On 5/21...
2012 Dec 10
2
[LLVMdev] how to get and modify a local variable's value through executionEngine?
hello guys, recently, i successfully get and modify global variable by execution engine. the functions i used are listed here: int m=1; EE->updateGlobalMapping(p->M->getGlobalVariable("x",true),&m); EE->recompileAndRelinkFunction(EntryFn); x is the global variable in the module. but how to modify the local variable in the module? -- View this message in context: http://llvm.1065342.n5.nabble.com/how-to-get-and-modify-a-local-variable-s-value-through-executio...
2005 Nov 02
1
[LLVMdev] Statically Initialized Arrays
...raseFromParent(); > > At the end of this, any instructions or other globals that referenced > the temporary global will now reference the new one. Ah ha! I was looking for something like this. Why didn't I see that there? I must be blind. In a vaguely related node, why does Module::getGlobalVariable *not* return types with internal linkage? There must be some logic behind that choice that I can't figure out. It is easy to copy the code out of Module.cpp if you need to find variables with internal linkage, but it seems unnecessary to me. Thanks, Evan -- Evan Jones http://evanjones.ca...
2017 Jun 19
2
JIT, LTO and @llvm.global_ctors: Looking for advise
...ed llvm/lib/Linker/LinkModules.cpp with: bool ModuleLinker::run() { // .... if (shouldImportIntrinsicGlobalVariables()) { auto addIntrinsicGlobalVariable = [ValuesToLink, srcM](llvm::StringRef name) { if (GlobalValue *GV = SrcM->getGlobalVariable(name)) { ValuesToLink.insert(GV); } }; // These are added here, because they must not be internalized. addIntrinsicGlobalVariable("llvm.used"); addIntrinsicGlobalVariable("llvm.compiler.used"); addIntrinsicGlobalVariable("llv...
2012 May 23
1
[LLVMdev] lli unable to resolve symbol _ZNKSt3__16locale9use_facetERNS0_2idE in bitcode
...t; It seems reasonable to me that lli should define __dso_handle if it's > declared in the module. > > You could module tools/lli/lli.cpp to add a global: > > char *dummy_dso_handle = 0; > > and tie it to __dso_handle via. > > if (GlobalVariable *DSO = Mod->getGlobalVariable("__dso_handle")) > if (!DSO->hasInitializer()) > EE->updateGlobalMapping(DSO,&dummy_dso_handle); > > somewhere in main(), say after disabling lazy compilation. Entirely > untested though; we might need to give dummy_dso_handle a real value. this is...
2012 May 22
5
[LLVMdev] lli unable to resolve symbol _ZNKSt3__16locale9use_facetERNS0_2idE in bitcode
Resending :(. Any pointers? tia On 5/21/2012 2:46 PM, Ashok Nalkund wrote: > On 5/21/2012 11:15 AM, Nick Lewycky wrote: >> Ashok Nalkund wrote: >>> Resending, any pointers? I demangled the symbol and it turns out to be: >>> std::__1::locale::use_facet(std::__1::locale::id&) const >> >> My guess is that you've got a .bc file produced on a mac using
2012 Sep 19
0
[LLVMdev] newbie question on getelementptr
...has initializer, specified below /*Name=*/myGVName); Constant* ptr_to_func_add = ConstantStruct::get(myStructType, func_add); mainGV->setInitializer(ptr_to_func_add); // now try to retrieve func_add from the global variable GlobalVariable* retrieved = module->getGlobalVariable(myGVName); if (retrieved) { std::vector<Constant*> indices; ConstantInt* constI32_0 = ConstantInt::get(module->getContext(), APInt(32, StringRef("0"), 10)); indices.push_back(constI32_0); indices.push_back(constI32_0);...
2019 Apr 19
2
Question: How to access c++ vtable pointer to use as Value* in LLVM pass
Dear Mailing List, This might sound unconventional, but I am trying to access a C++ objects vtable to pass as an argument to a function call for a library function I created. Creating & inserting a function call at the correct location in LLVM is done. I have learned that C++ objects are represented as struct types. But I'm just not quite sure how to get at the vtable pointer within,
2017 Jun 20
2
JIT, LTO and @llvm.global_ctors: Looking for advise
...ith: > > bool ModuleLinker::run() { > > // .... > > if (shouldImportIntrinsicGlobalVariables()) { > auto addIntrinsicGlobalVariable = [ValuesToLink, > srcM](llvm::StringRef name) { > if (GlobalValue *GV = SrcM->getGlobalVariable(name)) { > ValuesToLink.insert(GV); > } > }; > > // These are added here, because they must not be internalized. > addIntrinsicGlobalVariable("llvm.used"); > addIntrinsicGlobalVariable("llvm.compiler.used"); > addI...
2012 Dec 05
0
[LLVMdev] how to get and modify a global variable inside a module
On 05/12/12 12:07, Dong Chen wrote: > 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 ;) You
2012 Dec 10
0
[LLVMdev] how to get and modify a local variable's value through executionEngine?
Dong Chen <jameschennerd at gmail.com> writes: > hello guys, > recently, i successfully get and modify global variable by execution engine. > the functions i used are listed here: > int m=1; > EE->updateGlobalMapping(p->M->getGlobalVariable("x",true),&m); > EE->recompileAndRelinkFunction(EntryFn); > x is the global variable in the module. > but how to modify the local variable in the module? A local variable does not exists until the function that defines it is executed, so pretending to get and modify it a...
2013 Sep 10
1
[LLVMdev] Global Variable Recall
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
2017 May 30
2
llvm::GlobalVariable usage (newbie question)
The docs are pretty vague about this. After digging into the examples I got the following to work with JIT to gain a pointer to variable elsewhere in the runtime, but I'd like to understand what is going on here, and if there is a, um, nicer API that I'm missing? llvm::Value* C::getGlobalVariable(const char* name, llvm::Type* t) { auto global = _module->getNamedGlobal(name); if (!global) { new llvm::GlobalVariable( *_module, t, true, // constant llvm::Glo...
2012 Dec 05
3
[LLVMdev] how to get and modify a global variable inside a module
hi Duncan Sands, i have tried the functions: GlobalValue * getNamedValue (StringRef Name) const GlobalVariable * getGlobalVariable (StringRef Name, bool AllowInternal=false) const GlobalVariable * getNamedGlobal (StringRef Name) const but i think these functions just return the ID or something else (not the Global Variable's main memory address, i am not sure) here is the thing. i want to know the exact main memory ad...
2005 Nov 02
0
[LLVMdev] Statically Initialized Arrays
On Wed, 2 Nov 2005, Evan Jones wrote: > I am trying to generate LLVM code that references a global array. > Unfortunately, while I am generating the code I do not know the final length > of the array, as I add elements to it as my compiler goes along. What is the > best way to do this in LLVM? Ideally, I would be able to define the > GlobalVariable array and change its length