search for: createptrtoint

Displaying 12 results from an estimated 12 matches for "createptrtoint".

2020 Jan 14
2
sizeof implementation: how to get size as a constantInt?
...tes/SizeOf-OffsetOf-VariableSizedStructs.txt illuarstrated, and it works find, here's an example of my implementation: auto *p = builder.CreateGEP(structTy, llvm::ConstantPointerNull::get(pointerTy), constint1); auto *size = builder.CreatePtrToInt(p, llvm::IntegerType::get(context, 64)); and type definitions: auto *constint1 = llvm::ConstantInt::get(context, llvm::APInt(64, 1)); auto *int64Ty = llvm::IntegerType::get(context, 64); auto *doubleTy = llvm::Type::getDoubleTy(context); auto *structTy = llvm::StructType::create(context, "Foo...
2012 Feb 22
1
[LLVMdev] Size of structs & arrays
...two = llvm::ConstantInt::get(mod->getContext(), llvm::APInt(32, llvm::StringRef("1"), 10)); std::vector<llvm::Value*> indices; indices.push_back(one); indices.push_back(two); llvm::Value* size = builder->CreateGEP(struct_ptr, indices); llvm::Value* size_int = builder->CreatePtrToInt(size, llvm::IntegerType::get(mod->getContext(), 64)) And I'm getting the assertion error "Invalid GetElementPtrInst indices for type!"'. 'struct_ptr' is a pointer to the struct I'm trying to size. I've also tried using getNullValue on the struct's own type....
2012 Feb 22
0
[LLVMdev] Size of structs & arrays
On Wed, Feb 22, 2012 at 1:56 PM, Fraser Cormack <frasercrmck at gmail.com> wrote: > > I'm trying to work out the size of a struct so that I can pass this to the > 'llvm.memcpy' intrinsic. It's easy to find out how I'm supposed to do this, > as I keep seeing the following: > > %Size = getelementptr %T* null, int 1 > %SizeI = cast %T* %Size to uint >
2017 Jun 05
2
[newbie] trouble with global variables and CreateLoad/Store in JIT
...t;dump(); // Print memory ctx.EmitCall1("debugPointer", ptr); // Set class pointer auto c = ctx.bld.CreateExtractValue(val, 0, "class"); auto cp = ctx.bld.CreateConstGEP2_32(ty, ptr, 0, 0); auto cx = ctx.bld.CreatePtrToInt(cp, ctx.Int32Type()); ctx.EmitCall1("debugInt", cx); ctx.bld.CreateStore(c, cp); // Set datum auto d = ctx.bld.CreateExtractValue(val, 1, "datum"); auto dp = ctx.bld.CreateConstGEP2_32(ty, ptr, 0, 1); auto d...
2012 Feb 22
5
[LLVMdev] Size of structs & arrays
I'm trying to work out the size of a struct so that I can pass this to the 'llvm.memcpy' intrinsic. It's easy to find out how I'm supposed to do this, as I keep seeing the following: %Size = getelementptr %T* null, int 1 %SizeI = cast %T* %Size to uint But I'm unsure how I actually do this in the C++ API. Is the 'null' here a llvm::ConstantPointerNull? Any help
2017 Jun 06
2
[newbie] trouble with global variables and CreateLoad/Store in JIT
...; ctx.EmitCall1("debugPointer", ptr); >> // Set class pointer >> auto c = ctx.bld.CreateExtractValue(val, 0, "class"); >> auto cp = ctx.bld.CreateConstGEP2_32(ty, ptr, 0, 0); >> auto cx = ctx.bld.CreatePtrToInt(cp, ctx.Int32Type()); >> ctx.EmitCall1("debugInt", cx); >> ctx.bld.CreateStore(c, cp); >> // Set datum >> auto d = ctx.bld.CreateExtractValue(val, 1, "datum"); >> auto dp = ctx.bld.CreateCo...
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
2017 Jun 06
2
[newbie] trouble with global variables and CreateLoad/Store in JIT
...t;debugPointer", ptr); >>>> // Set class pointer >>>> auto c = ctx.bld.CreateExtractValue(val, 0, "class"); >>>> auto cp = ctx.bld.CreateConstGEP2_32(ty, ptr, 0, 0); >>>> auto cx = ctx.bld.CreatePtrToInt(cp, ctx.Int32Type()); >>>> ctx.EmitCall1("debugInt", cx); >>>> ctx.bld.CreateStore(c, cp); >>>> // Set datum >>>> auto d = ctx.bld.CreateExtractValue(val, 1, "datum"); >>>&gt...
2017 Jun 07
2
[newbie] trouble with global variables and CreateLoad/Store in JIT
...>>>>> // Set class pointer >>>>>> auto c = ctx.bld.CreateExtractValue(val, 0, "class"); >>>>>> auto cp = ctx.bld.CreateConstGEP2_32(ty, ptr, 0, 0); >>>>>> auto cx = ctx.bld.CreatePtrToInt(cp, ctx.Int32Type()); >>>>>> ctx.EmitCall1("debugInt", cx); >>>>>> ctx.bld.CreateStore(c, cp); >>>>>> // Set datum >>>>>> auto d = ctx.bld.CreateExtractValue(val, 1, &qu...
2007 Dec 17
0
[LLVMdev] Elsa and LLVM and LLVM submissions
...st char *Name = "") { > + return CreateCast(Instruction::FPTrunc, V, DestTy, Name); > + } > + Value *CreateFPExt(Value *V, const Type *DestTy, const char *Name > = "") { > + return CreateCast(Instruction::FPExt, V, DestTy, Name); > + } > + Value *CreatePtrToInt(Value *V, const Type *DestTy, > + const char *Name = "") { > + return CreateCast(Instruction::PtrToInt, V, DestTy, Name); > + } > + Value *CreateIntToPtr(Value *V, const Type *DestTy, > + const char *Name = &q...
2007 Dec 17
2
[LLVMdev] Elsa and LLVM and LLVM submissions
Devang Patel wrote: > On Dec 15, 2007, at 12:15 PM, Richard Pennington wrote: > >> I got the current version of LLVM via svn yesterday and modified my >> code to >> use the LLVMFoldingBuilder. Very nice! >> >> My question is this: I noticed that the folding builder doesn't fold >> some >> operations, e.g. casts. Is there some reason why? If
2014 Nov 03
8
[LLVMdev] [PATCH] Protection against stack-based memory corruption errors using SafeStack
...{ + // Re-align the base pointer according to the max requested alignment + assert(isPowerOf2_32(MaxAlignment)); + IRB.SetInsertPoint(cast<Instruction>(BasePointer->getNextNode())); + BasePointer = cast<Instruction>(IRB.CreateIntToPtr( + IRB.CreateAnd(IRB.CreatePtrToInt(BasePointer, IntPtrTy), + ConstantInt::get(IntPtrTy, ~uint64_t(MaxAlignment-1))), + StackPtrTy)); + } + + // Allocate space for every unsafe static AllocaInst on the unsafe stack + int64_t StaticOffset = 0; // Current stack top + for (SmallVectorImpl<A...