void AEFlowFunction::visitBinaryOperator(BinaryOperator &bo) { errs() << "Enter Binary Operator\n"; map<Value*, Instruction*> node = Realin.back() -> node; if(node.count(&bo) > 0) { //While , For will trigger second and more visiting. errs() << "AE Binary Operator, redefined\n"; AELatticeNode *ae = new AELatticeNode(*(Realin.back())); out.push_back(ae); return; } //continue process Value* key = &bo; Instruction* value; bool found = false; string opname = bo.getOpcodeName(); for(map<Value*, Instruction*>::iterator it = node.begin(); it != node.end(); ++it) { Instruction* cache_instruction = it->second; if(cache_instruction->isIdenticalToWhenDefined(&bo)) { found = true; value = cache_instruction; break; } /* * special case * handle case like 1+2 / 2+1 */ if(opname == "add") { bo.swapOperands(); if(cache_instruction->isIdenticalToWhenDefined(&bo)) { found = true; value = cache_instruction; bo.swapOperands(); break; } bo.swapOperands(); } } if(found) { node[key] = value; } else { node[key] = dyn_cast<Instruction>(key); } AELatticeNode *ae = new AELatticeNode(false, false, node); out.push_back(ae); errs() << "Leave Binary Operator\n"; }