需处理问题:
1、函数的指针参数之间独立性分析与解决。
2、函数参数为数组指针中的元素指针,导致数组指针整体信息丢失。
2020-8-18 整理的基本框架
2020-8-19
void processEligibleCallInst(call_list){
}
算法目标是修改函数的指针参数 (指针参数 : 被简化为int*的memory)
void processFunction(Function *f) {
//(0)对Function进行PointerAnalysis
pa->pointToAnalysis(f);
//(1)记录处理对象:Function的所有需处理CallInst及指针参数memory
list<llvm::CallInst *> call_list;
getTargetedCallInst(f, call_list);
//(2)对Function的指令进行memory 和 offset的标记
MarkRelatedInst(f);
//(3)处理修改call_list中的每条callInst,并用new_callInst替换callInst
//1、函数参数指令的替换。2、函数参数独立性分析。3、新建Function中指令插入。
processTargetedCallInst(call_list);
//(4)process the all the Functions by BFS
while(!call_list.empty()) {
CallInst *call_inst = call_list.front();
call_list.pop_front();
processFunction(call_inst->getCalledFunction());
}
}
void getTargetedCallInst(Function *f, call_list) {
for each CallInst of Function:
if (has pointer argument) {
call_list.push_back(CallInst);
for each operand of CallInst:
memory = pa->PointsTo(operand);//此处需要调用getPointsTo函数
pointer_map_.insert(memory, vector);//pointer_map_记录指针参数memory
}
}
void MarkRelatedInst(Function *f) {
for each Instruction of Function:
//根据指令得到memory 和 offset,并用vector存储
memory、offset = MarkInst(Instruction);
vector.push_back(memory);
vector.push_back(offset);
pointer_map_(Instruction, vector);
}
void processTargetedCallInst(call_list) {
//处理CallInst,将int* 修改为 memory + offset, 创建new_callInst,new_func
for each CallInst of call_inst:
}