similar to: llvm::GlobalVariable usage (newbie question)

Displaying 20 results from an estimated 600 matches similar to: "llvm::GlobalVariable usage (newbie question)"

2017 Jun 07
2
[newbie] trouble with global variables and CreateLoad/Store in JIT
My code was hinky, but only in the sense that I was accidentally duplicating the definition variable in the module where the function was. With only the declaration in the second module loading the bitcode reproduces the issue. Managed an lli reproduction: $ cat jit-0.ll target datalayout = "e-m:x-p:32:32-i64:64-f80:32-n8:16:32-a:0:32-S32" target triple =
2017 Nov 01
0
llvm.gcroot trouble with non-i8* allocas
Solved by using alloca i8*, i32 2 which the system seems happy enough with, and bitcasting to the actual type for rest of the code after llvm.gcroot. Not entirely sure if this is a terrible workaround or exactly the way gcroot is supposed to be used... On Wed, Nov 1, 2017 at 11:59 AM, Nikodemus Siivola < nikodemus at random-state.net> wrote: > I'm allocating { i8*, i32 } on the
2017 Nov 05
2
calling va_arg functions on win32 seems to require explicit stack alignment?
target datalayout = "e-m:x-p:32:32-i64:64-f80:32-n8:16:32-a:0:32-S32" target triple = "i686-pc-windows-msvc" declare void @llvm.va_start(i8**) declare void @llvm.va_end(i8**) define i64 @foo(...) { %va = alloca i8*, i32 16 ; 4 words should be enough? call void @llvm.va_start(i8** %va) %x = va_arg i8** %va, i64 call void @llvm.va_end(i8** %va) ret i64 %x }
2017 Jun 06
2
[newbie] trouble with global variables and CreateLoad/Store in JIT
That's useful to know that the static compilation code path works. Furthermore, as expected from that: 52: c7 05 04 00 00 00 d5 00 00 00 movl $213, 4 00000054: IMAGE_REL_I386_DIR32 _foo It looks like the offset `4` of the second field of your struct is correct in the object file, so this does seem to be a problem in the JIT-specific linking/loading.
2017 Nov 01
2
llvm.gcroot trouble with non-i8* allocas
I'm allocating { i8*, i32 } on the stack, and would like to add this as a GC root, but I'm having trouble figuring this out. This works as expected: declare void @llvm.gcroot(i8** %ptrloc, i8* %metadata) define i8* @bar(i8* %x) gc "shadow-stack" { entry: %objptr = alloca i8* call void @llvm.gcroot(i8** %objptr, i8* null) store i8* %x, i8** %objptr %v = load i8*, i8**
2017 Jun 06
2
[newbie] trouble with global variables and CreateLoad/Store in JIT
On Mon, Jun 5, 2017 at 1:34 PM, Nikodemus Siivola < nikodemus at random-state.net> wrote: > Uh. Turns out that if I hide the pointer to @foo from LLVM by passing it > through an opaque identity function ... then everything works fine. > > Is this a bug in LLVM or is there some magic involving globals I'm > misunderstanding? > This looks like a bug in the handling of
2007 Sep 22
4
[LLVMdev] RFC: Patch
Hi all, I have a patch that would potentially help Objective-C 2. In the "make_decl_llvm()" in llvm-backend.cpp, there is code to search through the already generated global variables. Objective-C goes through this code twice with the same identifier. The first time, is to create meta-data for a "property". The second time is to add a reference to that property into the
2019 Feb 22
1
Create the GlobalVariable which have extern in one header file
I have changed it to ExternalLinkage. Now, in LLVM IR, it looks like that: @DATA_TABLE = external global [0 x i8*], section "data_section", align 16 #0 @DATA_TABLE.1 = global [10 x i8*] [i8* inttoptr (i64 53415718 to i8*), i8* bitcast (void (%class.Hello*)* @_ZN5Hello5ptofnEv to i8*),...], section "data_section", align 16 #0 In my uses: %arrayidx = getelementptr inbounds [0 x
2017 Nov 23
2
JIT and atexit crash
Maybe the easiest workaround would be overriding symbol resolution for the function name and redirect it to your own version in static code (and hope it has no bad side effect on your use case). I think when running 3rd party code, the only way to definitely avoid this kind of trouble is to never deallocate any code or data sections. Doug Binks mentioned that too in his cppcast about Runtime
2017 Jun 05
2
[newbie] trouble with global variables and CreateLoad/Store in JIT
Since the getelementptrs were implicitly generated by the CreateStore/Load I'm not sure how to get access to them. So I hacked the assignment to be done thrice: once using a manual decomposition into two GEPs and stores, once using the "big" CreateStore, once via the setGlobal function, printing addresses and memory contents at each point to the degree that I have access to them.
2020 Jun 03
2
Fwd: I cannot change value of global variable in LLVM IR using IRBuilder
Hi Everyone, I'm quite new to LLVM and I want to update value of global variable in LLVM IR. I created new global variable in ModulePass: bool runOnModule(llvm::Module &M) { IRBuilder<> Builder(M.getContext()); Instruction *I = &*inst_begin(M.getFunction("main")); Builder.SetInsertPoint(I); M.getOrInsertGlobal("globalKey",
2017 Jun 11
2
Force casting a Value*
On 11 June 2017 at 07:53, David Blaikie <dblaikie at gmail.com> wrote: > Sounds like you're looking for reinterpret_cast: http://en. > cppreference.com/w/cpp/language/reinterpret_cast > I tried cast<ConstInt>(vo), but that failed at run-time. > > On Sun, Jun 11, 2017 at 3:06 AM Dipanjan Das via llvm-dev < > llvm-dev at lists.llvm.org> wrote: >
2020 Jun 03
2
Fwd: I cannot change value of global variable in LLVM IR using IRBuilder
I don't think it's the same problem as you described. By printing I meant calling printf function and passing my global variable as one of the arguments. My code: Instruction* InstructionVisitor::incrementGlobalKey(Instruction* I) { IRBuilder<> Builder(I->getContext()); Builder.SetInsertPoint(I->getNextNode()); GlobalVariable* key =
2017 Nov 23
1
JIT and atexit crash
Hi, Not sure whether this matches your use case, but the Orc-based JIT used in LLI appears to be using `llvm::orc::LocalCXXRuntimeOverrides` (http://llvm.org/doxygen/classllvm_1_1orc_1_1LocalCXXRuntimeOverrides.html) to override `__cxa_atexit`: https://github.com/llvm-mirror/llvm/blob/release_50/tools/lli/OrcLazyJIT.h#L74
2017 Jun 04
2
[newbie] trouble with global variables and CreateLoad/Store in JIT
Emitting calls to these functions (written in an .ll file linked in) works fine, and does the right thing. %Any = type { i8*, i32 } define dllexport void @setGlobal(%Any* %ptr, %Any %value) { store %Any %value, %Any* %ptr ret void } define dllexport %Any @getGlobal(%Any* %ptr) { %val = load %Any, %Any* %ptr ret %Any %val } Trying to replace the setGlobal call with what should be
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
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
2013 Jan 20
1
[LLVMdev] Get the value of a GlobalVariable
Hi, I am executing a C program using JIT. When the program exits, the control comes back to my program which initiates the JIT. Now, I want to read the value(not the LLVM nomenclature) of a global variable (not the LLVM nomenclature). I am able to get the global variable, using the following command: GlobalVariable *my_global = Mod->getNamedGlobal("MY_GLOBAL"); I want to know the
2017 Jun 11
2
Force casting a Value*
On 11 June 2017 at 11:32, Nikodemus Siivola <nikodemus at random-state.net> wrote: > On Sun, Jun 11, 2017 at 7:49 PM, Dipanjan Das via llvm-dev < > llvm-dev at lists.llvm.org> wrote: > >> >> >> On 11 June 2017 at 07:53, David Blaikie <dblaikie at gmail.com> wrote: >> >>> Sounds like you're looking for reinterpret_cast: http://en.cp
2017 Nov 21
2
JIT and atexit crash
> It's not the job of the Orc engine. I could argue about this, but I won’t :) > Just don't use atexit. The problem is that I run third-party programs. I cannot control them. > On 20. Nov 2017, at 01:04, Joerg Sonnenberger via llvm-dev <llvm-dev at lists.llvm.org> wrote: > > On Mon, Nov 20, 2017 at 12:22:49AM +0100, Alex Denisov via llvm-dev wrote: >> JIT