【发布时间】:2018-08-21 23:03:40
【问题描述】:
我想存储有关正在分配和更改的每个堆栈内存的数据。
为此,我认为我需要某种数据结构,我可以在其中存储相关数据,例如局部变量的值以及它的任何更改,例如在store 指令之前。
此外,在读取任何局部变量(例如load 指令)之前,我应该能够使用保存在数据结构中的值来检查值。
如果我们假设 IR 看起来像这样
%1 = alloca i32,
[...]
%20 = store i32 0, %1
我需要将上面的代码更改为如下所示
%18 = call __Checking
%19 = <storing the return value from __Checking into a data structure>
%20 = store i32 0, %1
我的问题是我不知道如何将名为 __Checking 的库中的返回值存储到我在开头定义的 StructType 中。
我的相关代码
if (StoreInst *SI = dyn_cast<StoreInst>(&I)){
Value* newValue = IRB.CreateCall(....);
Type* strTy[] = { Type::getInt64Ty(m.getContext()),
Type::getInt64Ty(m.getContext()) };
Type* t = StructType::create(strTy);
}
【问题讨论】:
-
发布的 IR 不完整,有错误/错别字
标签: c++ llvm llvm-clang llvm-ir