Tas*_*man 4 c++ compiler-construction optimization performance llvm
我正在尝试创建 IR 指令
store i32 0, i32* %3, align 4
Run Code Online (Sandbox Code Playgroud)
我正在使用该方法
StoreInst *CreateAlignedStore(Value *Val, Value *Ptr, unsigned Align, bool isVolatile = false)
Run Code Online (Sandbox Code Playgroud)
创建指令。由于第一个参数采用Value*,因此我需要转换0为Value*。
你能帮我吗?
小智 5
您可以使用 llvm::Constant 作为 *val,llvm Constant 继承自 Value。为 0 创建常量的一种方法是
llvm::ConstantInt::get(llvm::Type::getInt64Ty(Ctx), 0)
Run Code Online (Sandbox Code Playgroud)
其中 Ctx 是您要插入 StoreInst 的函数的上下文