Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
当我们在 LLVM IR 中创建 LoadInst 时,结果是指向该值的指针。如果我正在读取LLVM IR 中int名为xusing的变量的值,LoadInst我得到的结果是另一个指向该值的指针。如何将结果存储在int?
int
x
LoadInst
LLVM IR 既没有变量也没有int类型。但是从类 C 语言中的变量读取int x通常会被转换为 LLVM IR 中的加载指令,我猜这就是你要问的。
int x
答案是创建任何LLVM 指令都会使您获得一个Value*(或指向 的子类型的指针Value)。问题是,该值的类型是什么。对于加载指令,如果其操作数是 type i32*,则加载本身将是 type i32- 所以加载确实从指针中获取实际值。
Value*
Value
i32*
i32
如果您想将整数放在其他地址下 - 将其存储在其他地方 - 您应该使用存储指令。