search for: getorinsertglob

Displaying 14 results from an estimated 14 matches for "getorinsertglob".

Did you mean: getorinsertglobal
2014 Feb 18
3
[LLVMdev] How to codegen an LLVM-IR that has dynamic arrays in it?
Hi Fellows, Is there a way to allocate dynamic array within an LLVM IR file from my code generator? Say., how to create an array type with a size determined through a global variable. Symbolically, something like below: Value *sz = Mod->getOrInsertGlobal("SIZE", Int32Ty); Type *ArrayTy = ArrayType::get(FloatTy, sz) AllocaInst *AI = CreateAlloca(ArrayTy, 0, ""); Thanks, Paul -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/piperma...
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) {
2013 Jun 24
2
[LLVMdev] Questions on writing a pass that adds instrumentation code
...art of the function? (Even though my goal, as phrased above, would work if I put the load/add/store instrumentation just before the terminator of the first basic block, that doesn't serve my broader goal.) 2. I currently create the global variables holding the counter by calling "module.getOrInsertGlobal(...)". Will this ensure that the global starts with the value 0, or do I have to do this via other means? (E.g. make an explicit GlobalVariable object instead of using that convenience function) 3. How can I add code that is called when the program exits? 4. Suppose I want to call a func...
2009 Oct 06
0
[LLVMdev] 2.6/trunk Execution Engine question
...e <assert.h> using namespace llvm; static raw_stdout_ostream raw_cout; int main(int argc, char** argv) { // Test JITting a variable without JITting any functions.' Module* mod = new Module("test", getGlobalContext()); GlobalVariable* gv = cast<GlobalVariable>(mod->getOrInsertGlobal("TestGV", Type::getInt32Ty(getGlobalContext()))); gv->setInitializer(ConstantInt::get( Type::getInt32Ty(getGlobalContext()), 24601)); ModuleProvider* modp = new ExistingModuleProvider(mod); InitializeNativeTarget(); std::string errstring; ExecutionEngine* eeng = Execution...
2009 Oct 06
1
[LLVMdev] 2.6/trunk Execution Engine question
On Tue, Oct 6, 2009 at 5:49 PM, Reid Kleckner <rnk at mit.edu> wrote: >> Also, the null pointer is coming from a call to JCE->allocateSpace(). >> This is a virtual function; I'm trying to discover what subclass it >> is. > > So, there's JITEmitter::allocateSpace which overrides > JITCodeEmitter::allocateSpace(), but *most* of the time it just calls >
2015 Mar 24
2
[LLVMdev] IR blocks for calling function pointers
Hello, I am trying to create IR block for making a call to function pointer. For creating the IR for a function call to "foo", with "foo" being defined as "void foo(int)", I can use the "getOrInsertFunction" call from Module class as follows: std::vector<Type*> FooArgs; FooArgs.push_back(IRB.getInt64Ty()); Value *FooFunction =
2020 Jun 03
2
Fwd: I cannot change value of global variable in LLVM IR using IRBuilder
...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", Builder.getInt64Ty()); GlobalVariable* gVar = M.getNamedGlobal("globalKey"); gVar->setLinkage(GlobalValue::InternalLinkage); gVar->setAlignment(Align(8)); gVar->setInitializer(Builder.getInt64(0)); gVar->setConstant(false); for...
2020 Jun 03
2
Fwd: I cannot change value of global variable in LLVM IR using IRBuilder
...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", Builder.getInt64Ty()); > > GlobalVariable* gVar = M.getNamedGlobal("globalKey"); > > gVar->setLinkage(GlobalValue::InternalLinkage); > > gVar->setAlignment(Align(8)); > > gVar->setInitializer(Builder.getInt64(0)); &...
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
2014 Oct 07
2
[LLVMdev] Debug Info and DFSan
...nted(const Function *F); @@ -573,6 +575,8 @@ bool DataFlowSanitizer::runOnModule(Module &M) { if (ABIList.isIn(M, "skip")) return false; + FunctionDIs = makeSubprogramMap(M); + if (!GetArgTLSPtr) { Type *ArgTLSTy = ArrayType::get(ShadowTy, 64); ArgTLS = Mod->getOrInsertGlobal("__dfsan_arg_tls", ArgTLSTy); @@ -725,6 +729,12 @@ bool DataFlowSanitizer::runOnModule(Module &M) { Value *WrappedFnCst = ConstantExpr::getBitCast(NewF, PointerType::getUnqual(FT)); F.replaceAllUsesWith(WrappedFnCst); + + // Patch the pointer to LLVM fu...
2019 Jul 05
2
Allocating shadow tables at the bottom of memory on Linux.
...ntation pass as an exercise to get up to speed on how llvm operates. I am curious about what the best way would be to create a shadow table at a fixed address in low memory starting at 0x10000 and extending upwards. I am unclear about the correct approach from looking at the DataFlowSanitizer since getOrInsertGlobal seems to be used on a limited number of times in runModule primarily to allocate thread local storage and I am uncertain how the code ensures that the runtime metadata doesnt get overwritten by alloca calls for the stack. Thanks in advance, Carter. -------------- next part -------------- An HTM...
2014 Oct 07
2
[LLVMdev] Debug Info and DFSan
...le(Module &M) { > > if (ABIList.isIn(M, "skip")) > > return false; > > > > + FunctionDIs = makeSubprogramMap(M); > > + > > if (!GetArgTLSPtr) { > > Type *ArgTLSTy = ArrayType::get(ShadowTy, 64); > > ArgTLS = Mod->getOrInsertGlobal("__dfsan_arg_tls", ArgTLSTy); > > @@ -725,6 +729,12 @@ bool DataFlowSanitizer::runOnModule(Module &M) { > > Value *WrappedFnCst = > > ConstantExpr::getBitCast(NewF, PointerType::getUnqual(FT)); > > F.replaceAllUsesWith(WrappedFnCst);...
2009 Oct 06
4
[LLVMdev] 2.6/trunk Execution Engine question
> 6. When ExecutionEngine::create was called with parameter > "GVsWithCode" set to its default value of true, I got a segfault when > trying to get a pointer to one of my globals.  JIT::getMemoryForGV was > returning NULL in that case.  Explicitly passing false for > "GVsWithCode" cleared it up. That's no good. Could you send me a stack trace and explain
2014 Oct 07
2
[LLVMdev] Debug Info and DFSan
On Tue, Oct 7, 2014 at 12:18 PM, David Blaikie <dblaikie at gmail.com> wrote: > > > On Tue, Oct 7, 2014 at 12:10 PM, David Blaikie <dblaikie at gmail.com> wrote: > >> >> >> On Tue, Oct 7, 2014 at 11:48 AM, Peter Collingbourne <peter at pcc.me.uk> >> wrote: >> >>> On Tue, Oct 07, 2014 at 10:04:30AM -0700, David Blaikie wrote: