[LLVMdev] Passing a pointer to a function
Scott Ricketts
sricketts at maxentric.com
Thu May 21 08:17:46 PDT 2009
Eli: Thanks for the quick and helpful response.
> I would suggest bit-casting p to an i8*.
Yup, that did the trick:
void
visitLoadInst(LoadInst &I) {
Value *P = I.getPointerOperand();
const Type *PtrTy = PointerType::getUnqual(Type::Int8Ty);
BasicBlock::iterator it(I);
++it;
CastInst *CI =
CastInst::Create(Instruction::BitCast, P, PtrTy, "", it);
CallInst::Create(load_fcall, CI, "", it);
}
> I'm not sure why you're getting crashes with the last approach; it
> looks like it should work.
In that particular case, it encounters a pointer to an element of type
label and then segfaults on the call to isInteger(). I didn't look
into this bug because of the bitcast solution works for now.
Thanks,
Scott
More information about the llvm-dev
mailing list