Nikodemus Siivola via llvm-dev
2017-May-30 19:39 UTC
[llvm-dev] 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::GlobalValue::ExternalLinkage, nullptr, // no initializer name); global = _module->getNamedGlobal(name); } return global; } Cheers, -- nikodemus -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20170530/372d8d64/attachment.html>
Tim Northover via llvm-dev
2017-May-30 19:58 UTC
[llvm-dev] llvm::GlobalVariable usage (newbie question)
On 30 May 2017 at 12:39, Nikodemus Siivola via llvm-dev <llvm-dev at lists.llvm.org> wrote:> 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?Have you looked at Module::getOrInsertGlobal? It seems to be pretty much exactly what you're doing. Cheers. Tim.
Nikodemus Siivola via llvm-dev
2017-May-30 20:04 UTC
[llvm-dev] llvm::GlobalVariable usage (newbie question)
No, thanks for the hint! On Tue, May 30, 2017 at 10:58 PM, Tim Northover <t.p.northover at gmail.com> wrote:> On 30 May 2017 at 12:39, Nikodemus Siivola via llvm-dev > <llvm-dev at lists.llvm.org> wrote: > > 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? > > Have you looked at Module::getOrInsertGlobal? It seems to be pretty > much exactly what you're doing. > > Cheers. > > Tim. >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20170530/91478a47/attachment.html>
Possibly Parallel Threads
- [newbie] trouble with global variables and CreateLoad/Store in JIT
- llvm.gcroot trouble with non-i8* allocas
- calling va_arg functions on win32 seems to require explicit stack alignment?
- [newbie] trouble with global variables and CreateLoad/Store in JIT
- llvm.gcroot trouble with non-i8* allocas