search for: gettruncorbitcast

Displaying 3 results from an estimated 3 matches for "gettruncorbitcast".

2020 Apr 15
2
question on the signature of malloc
...p in LLVM 9.0.0: LLVMValueRef LLVMBuildMalloc(LLVMBuilderRef B, LLVMTypeRef Ty, const char *Name) { Type* ITy = Type::getInt32Ty(unwrap(B)->GetInsertBlock()->getContext()); Constant* AllocSize = ConstantExpr::getSizeOf(unwrap(Ty)); AllocSize = ConstantExpr::getTruncOrBitCast(AllocSize, ITy); Instruction* Malloc = CallInst::CreateMalloc(unwrap(B)->GetInsertBlock(), ITy, unwrap(Ty), AllocSize, nullptr, nullptr, ""); return wrap(unwrap(B)->Insert(Malloc, Twine...
2011 Feb 04
3
[LLVMdev] ConstantBuilder proposal
...static Constant *GetSExtOrBitCast( Constant *C, ///< The constant to sext or bitcast const Type *Ty ///< The type to sext or bitcast C to ) { return ConstantExpr::getSExtOrBitCast(C, Ty); } // @brief Create a Trunc or BitCast cast constant expression static Constant *GetTruncOrBitCast( Constant *C, ///< The constant to trunc or bitcast const Type *Ty ///< The type to trunc or bitcast C to ) { return ConstantExpr::getTruncOrBitCast(C, Ty); } /// @brief Create a BitCast or a PtrToInt cast constant expression static Constant *GetPointerCast( Constan...
2015 Jan 27
2
[LLVMdev] Create a call to function malloc using LLVM API
...= p->getType(); AllocaInst* arg_alloc = builder.CreateAlloca(tp);//builder is IRBuilder if(tp->isPointerTy()){ Type* tpp = tp->getPointerElementType(); Type* ITy = Type::getInt32Ty(getGlobalContext()); Constant* AllocSize = ConstantExpr::getSizeOf(tpp) AllocSize = ConstantExpr::getTruncOrBitCast(AllocSize, ITy); CallInst::CreateMalloc(arg_alloc, ITy, tpp, AllocSize); } But the generated LLVM IR seems incorrect: %malloccall = tail call i8* bitcast (i8* (i64)* @malloc to i8* (i32)*)(i32 ptrtoint (i32* getelementptr (i32* null, i32 1) to i32)) I don't quite understand the arguments o...