search for: creategep

Displaying 20 results from an estimated 37 matches for "creategep".

2015 May 28
1
[LLVMdev] Passing ConstantDataArray to GetElementPtrInst
...auto strValue = llvm::ConstantDataArray::getString(llvm::getGlobalContext(), llvm::StringRef("Hello world.")); std::vector<llvm::Value*> index_vector; index_vector.push_back(Builder.getInt32(0)); index_vector.push_back(Builder.getInt32(0)); auto valueAsPtr = Builder.CreateGEP(strValue, index_vector, "tmp1"); args.push_back(valueAsPtr); Builder.CreateCall(TheModule->getFunction("printf"), args, "callprintf"); Note that this is summarized, I already have the IRBuilder, etc initialized. I've also tried this with a LoadInstr th...
2011 Feb 01
2
[LLVMdev] Convenience methods in ConstantExpr et al
I notice that there's a lot of inconsistency in the various LLVM classes with respect to convenience methods. Here's some examples: For creating GEPS, IRBuilder has: CreateGEP (2 overloads) CreateInBoundsGEP (2 overloads) CreateConstGEP1_32 CreateConstInBoundsGEP1_32 CreateConstGEP2_32 CreateConstInBoundsGEP2_32 CreateConstGEP1_64 CreateConstInBoundsGEP1_64 CreateConstGEP2_64 CreateConstInBoundsGEP2_64 CreateStructGEP All of which are very useful. Ho...
2007 Dec 17
2
[LLVMdev] Elsa and LLVM and LLVM submissions
...her operator: If the operand is constant, the cast can be done at compile time. I've made the necessary changes to LLVMFoldingBuilder.h to handle casts and several other operators. I have attached the patch. There is one glaring thing that should be addressed. The #ifdef RICH around code in CreateGEP is there because I'm not familiar with STL enough to figure out how to get an array of pointers out of a vector. :-( If someone could clue me in as to the best way to do this, I'd greatly appreciate it. I've tested this code with my Elsa->LLVM stuff and also recompiled the LLVM...
2007 Dec 17
0
[LLVMdev] Elsa and LLVM and LLVM submissions
...> constant, the cast can be done at compile time. I've made the > necessary changes to LLVMFoldingBuilder.h to handle casts and > several other operators. > > I have attached the patch. There is one glaring thing that should be > addressed. The #ifdef RICH around code in CreateGEP is there because > I'm not familiar with STL enough to figure out how to get an array > of pointers out of a vector. :-( If someone could clue me in as to > the best way to do this, I'd greatly appreciate it. > > I've tested this code with my Elsa->LLVM stuff and...
2011 Feb 02
0
[LLVMdev] Convenience methods in ConstantExpr et al
On Mon, Jan 31, 2011 at 10:57 PM, Talin <viridia at gmail.com> wrote: > I notice that there's a lot of inconsistency in the various LLVM classes > with respect to convenience methods. Here's some examples: > > For creating GEPS, IRBuilder has: > > CreateGEP (2 overloads) > CreateInBoundsGEP (2 overloads) > CreateConstGEP1_32 > CreateConstInBoundsGEP1_32 > CreateConstGEP2_32 > CreateConstInBoundsGEP2_32 > CreateConstGEP1_64 > CreateConstInBoundsGEP1_64 > CreateConstGEP2_64 > CreateConstInBoundsGEP2_64 >...
2011 Feb 02
2
[LLVMdev] Convenience methods in ConstantExpr et al
...iridia at gmail.com > <mailto:viridia at gmail.com>> wrote: > > I notice that there's a lot of inconsistency in the various LLVM > classes with respect to convenience methods. Here's some examples: > > For creating GEPS, IRBuilder has: > > CreateGEP (2 overloads) > CreateInBoundsGEP (2 overloads) > CreateConstGEP1_32 > CreateConstInBoundsGEP1_32 > CreateConstGEP2_32 > CreateConstInBoundsGEP2_32 > CreateConstGEP1_64 > CreateConstInBoundsGEP1_64 > CreateConstGEP2_64...
2017 Oct 14
2
Bug in replaceUsesOfWith: does not keep addrspace consistent in GEP
...It = F->arg_begin(); Value *Arg = &*It; It++; Value *Arg2 = &*It; BasicBlock *Entry = BasicBlock::Create(ctx, "entry", F); Builder.SetInsertPoint(Entry); Instruction *Slot = nullptr;* if (SHOW_ERROR) { Slot = cast<Instruction>(Builder.CreateGEP(Arg, {Builder.getInt64(1)}, "slot")); errs() << "Slot(original): " << *Slot << "\n"; Slot->replaceUsesOfWith(Arg, Arg2); errs() << "Slot(replaced): " << *Slot << "\n"; } else {...
2016 Dec 30
3
Avoiding during my pass the optimization (copy propagation) of my LLVM IR code (at generation)
Hello. I'm writing an LLVM pass that is working on LLVM IR. To my surprise the following LLVM pass code generates optimized code - it does copy propagation on it. Value *vecShuffleOnePtr = Builder.CreateGEP(ptr_B, vecShuffleOne, "VectorGep"); ... packed_gather_params.push_back(vecShuffleOnePtr); CallInst *callGather = Builder.CreateCall(func_llvm_masked_gather_v128i16, packed_gather_params); callGather->addAttrib...
2020 Jan 14
2
sizeof implementation: how to get size as a constantInt?
I'm implementing c style "sizeof()", and I did as http://nondot.org/sabre/LLVMNotes/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));...
2012 Feb 22
1
[LLVMdev] Size of structs & arrays
...lvm::IntegerType::get(mod->getContext(), 64)); llvm::ConstantInt* 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 s...
2008 Apr 12
0
[LLVMdev] LLVMBuilder vs LLVMFoldingBuilder
Duncan Sands wrote: > + GetElementPtrInst *CreateStructGEP(Value *Ptr, unsigned Idx, > + const char *Name = "") { > + llvm::Value *Idxs[] = { > + ConstantInt::get(llvm::Type::Int32Ty, 0), > + ConstantInt::get(llvm::Type::Int32Ty, Idx) > + }; > + return Insert(GetElementPtrInst::Create(Ptr, Idxs, Idxs+2, Name));
2011 Feb 03
0
[LLVMdev] Convenience methods in ConstantExpr et al
...<mailto:viridia at gmail.com>> wrote: >> >> I notice that there's a lot of inconsistency in the various LLVM >> classes with respect to convenience methods. Here's some examples: >> >> For creating GEPS, IRBuilder has: >> >> CreateGEP (2 overloads) >> CreateInBoundsGEP (2 overloads) >> CreateConstGEP1_32 >> CreateConstInBoundsGEP1_32 >> CreateConstGEP2_32 >> CreateConstInBoundsGEP2_32 >> CreateConstGEP1_64 >> CreateConstInBoundsGEP1_64 >>...
2014 Oct 28
2
[LLVMdev] Storing values in global variables
...to fix my (until now quite careless) use of the different contexts. And this is where I could need help. The special case I am stuck at is about storing a value in a global variable. Here is some code: IRBuilder<> builder(pi); Value *elem = builder.CreateCall(...); Value *elem_ptr = builder.CreateGEP(global_array, idx); builder.CreateStore(get_crypted_funcptr(func, builder), elem_ptr); I get a IRBuilder before some instruction (pi) in main. The element I want to store (elem) is created by some call instruction which I create via the builder. To store elem in global_array, I need a pointer, whi...
2008 Apr 11
4
[LLVMdev] LLVMBuilder vs LLVMFoldingBuilder
Hi Dominic, +//===-- llvm/Support/IRBuilder.h - Builder for LLVM Instrs -----*- C++ -*-===// is this line the right length? It seems shorter than the similar lines below like this one: +//===----------------------------------------------------------------------===// + GetElementPtrInst *CreateStructGEP(Value *Ptr, unsigned Idx, + const char *Name =
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 >
2009 Jan 09
2
[LLVMdev] RFC: Store alignment should be LValue alignment, not source alignment
...IndexVal = CastToSIntType(IndexVal, IntPtrTy); // If this is an index into an LLVM array, codegen as a GEP. - if (isArrayCompatible(ArrayType)) { + if (isArrayCompatible(ArrayTreeType)) { Value *Idxs[2] = { ConstantInt::get(Type::Int32Ty, 0), IndexVal }; Value *Ptr = Builder.CreateGEP(ArrayAddr, Idxs, Idxs + 2); - return BitCastToType(Ptr, - PointerType::getUnqual(ConvertType(TREE_TYPE(exp)))); + const Type *ATy = cast<PointerType>(ArrayAddr->getType())- >getElementType(); + const Type *ElementTy = cast<ArrayType>(ATy)->g...
2019 Jul 03
2
optimisation issue in an llvm IR pass
...>setMetadata(M.getMDKindID("nosanitize"), MDNode::get(C, None)); Value *PrevLocCasted = IRB.CreateZExt(PrevLoc, IRB.getInt32Ty()); LoadInst *MapPtr = IRB.CreateLoad(AFLMapPtr); MapPtr->setMetadata(M.getMDKindID("nosanitize"), MDNode::get(C, None)); Value *MapPtrIdx = IRB.CreateGEP(MapPtr, IRB.CreateXor(PrevLocCasted, CurLoc)); LoadInst *Counter = IRB.CreateLoad(MapPtrIdx); Counter->setMetadata(M.getMDKindID("nosanitize"), MDNode::get(C, None)); Value *Incr = IRB.CreateAdd(Counter, ConstantInt::get(Int8Ty, 1)); // ^^^ same code before both variants // CODE FOR...
2019 Dec 17
2
Using "opaque pointers" right now?
> pointers. If you're writing a front-end this probably means you need > to keep your AST's representation of element types alongside LLVM > pointer Values in your own data-structures Yeah, that’s no problem - the type is needed for signed/unsigned integer distinctions anyway. There’s no getting around having one’s own type hierarchy. >> And also - is it possible to use
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
2019 Dec 18
5
RFC: Opaque pointer status and future direction
...an what I'm dropping here. Proposal ======== Short term (because otherwise we can't do it for another six months): 1. Add inalloca(<ty>) support. 2. Document for January release the planned removal of: * Old style byval * Old style inalloca * Typeless CreateCall, CreateLoad, CreateGEP. 3. Soon after January branch, strip out those bits. The third in particular should prevent front-end regression, I had to fix a fair few new deprecated callsites in Clang when rebasing everything this week. Short/medium term: 1. Commit serialization and Instruction changes. 2. Use that to add te...