Reputation: 69
I am trying to create an IR instruction
store i32 0, i32* %3, align 4
I am using the method
StoreInst *CreateAlignedStore(Value *Val, Value *Ptr, unsigned Align, bool isVolatile = false)
to create the instruction. Since the first argument takes a Value*
, somehow I need to convert 0
to Value*
.
Can you help me with that?
Upvotes: 4
Views: 4051
Reputation: 161
You can use llvm::Constant for the *val, llvm Constant inherits from Value. One way to create a Constant for 0 is
llvm::ConstantInt::get(llvm::Type::getInt64Ty(Ctx), 0)
Where Ctx is context of a function you'r inserting StoreInst to
Upvotes: 5