diff --git a/projects/libpredictor b/projects/libpredictor index 5cf49ec..d08cb25 160000 --- a/projects/libpredictor +++ b/projects/libpredictor @@ -1 +1 @@ -Subproject commit 5cf49ecbffaeb9280ea00bf375c0275e68203684 +Subproject commit d08cb25cc6b0fd13a452ee634abc1e65e0901c3d diff --git a/src/CFGraph/private_variables_analysis.cpp b/src/CFGraph/private_variables_analysis.cpp index 653ca2a..ef9fee6 100644 --- a/src/CFGraph/private_variables_analysis.cpp +++ b/src/CFGraph/private_variables_analysis.cpp @@ -200,20 +200,46 @@ static void fillOutForFunc(const FuncInfo* func, const vectorfuncName] = { defined, common_defined }; } -static void getDefsFromBlock(SAPFOR::BasicBlock* block, set& res, +static bool isInstructionSpfParameter(SAPFOR::Instruction* instr) +{ + SgStatement* st = instr->getOperator(); + + // check if this operator is SPF(ANALYSIS(PARAMETER( ))) + if (st && st->variant() == ASSIGN_STAT) + { + if (st->lineNumber() < 0 && st->numberOfAttributes()) + { + for (int i = 0; i < st->numberOfAttributes(); ++i) + { + SgAttribute* attr = st->getAttribute(i); + SgStatement* attributeStatement = (SgStatement*)(attr->getAttributeData()); + int type = st->attributeType(i); + + if (type == SPF_PARAMETER_OP) + return true; + } + } + } + return false; +} + +static void getDefsFromBlock(SAPFOR::BasicBlock* block, set& res, const vector>& commonVars, const FuncInfo* func) { vector lastParamRef; - for (auto ir_block : block->getInstructions()) + for (const auto &ir_block : block->getInstructions()) { SAPFOR::Instruction* instr = ir_block->getInstruction(); + if (isInstructionSpfParameter(instr)) + continue; + SAPFOR::CFG_OP instr_operation = instr->getOperation(); if (instr_operation == SAPFOR::CFG_OP::PARAM) { SAPFOR::Argument* arg = instr->getArg1(); - if(arg->getType() == SAPFOR::CFG_ARG_TYPE::VAR) + if (arg->getType() == SAPFOR::CFG_ARG_TYPE::VAR) addPlaceWithDef(commonVars, func, arg, instr); lastParamRef.push_back(arg); @@ -236,12 +262,20 @@ static void getDefsFromBlock(SAPFOR::BasicBlock* block, set& int last_instr_num = block->getInstructions().back()->getNumber(); for (const auto& def : block->getRD_Out()) + { for (int place : def.second) + { if (place >= first_instr_num && place <= last_instr_num && def.first->getType() == SAPFOR::CFG_ARG_TYPE::VAR) { + SAPFOR::Instruction* instr = block->getInstructions()[place - first_instr_num]->getInstruction(); + if (isInstructionSpfParameter(instr)) + continue; + res.insert(def.first); - addPlaceWithDef(commonVars, func, def.first, block->getInstructions()[place - first_instr_num]->getInstruction()); + addPlaceWithDef(commonVars, func, def.first, instr); } + } + } } // recursively analyze FOR loops @@ -266,7 +300,7 @@ static set analyzeLoop(LoopGraph* loop, const setlineNum, loop_end = loop->lineNumAfterLoop; - for (auto bb : blocks) + for (const auto &bb : blocks) { if (!bb || (bb->getInstructions().size() == 0)) continue; @@ -348,7 +382,7 @@ static set analyzeLoop(LoopGraph* loop, const set