private void calculateGenKillSets(CFGBlock block, BlockDataFlowState bFlow) { for (int i = block.getStatements().size() - 1; i >= 0; i--) { LIRStatement stmt = block.getStatements().get(i); if (stmt.getClass().equals(QuadrupletStmt.class)) { QuadrupletStmt qStmt = (QuadrupletStmt) stmt; if (!qStmt.getDestination().getClass().equals(RegisterName.class)) { updateKillGenSet(block.getMethodName(), qStmt, bFlow); } } else if (stmt.getClass().equals(StoreStmt.class)) { updateKillGenSet(block.getMethodName(), (StoreStmt) stmt, bFlow); } else if (stmt.getClass().equals(CallStmt.class)) { updateKillGenSet(block.getMethodName(), (CallStmt) stmt, bFlow); } } }
private BlockDataFlowState generateDFState(CFGBlock block) { int totalGlobals = this.uniqueGlobals.get(block.getMethodName()).size(); // Get the original inBitSet for this block BitSet origIn; if (this.cfgBlocksState.containsKey(block)) { origIn = this.cfgBlocksState.get(block).getIn(); } else { origIn = new BitSet(totalGlobals); origIn.set(0, totalGlobals); } // Calculate the in BitSet by taking intersection of predecessors BlockDataFlowState bFlow = new BlockDataFlowState(totalGlobals); // If there exist at least one successor, set Out to all True if (block.getSuccessors().size() > 0) { bFlow.getOut().set(0, totalGlobals); } BitSet out = bFlow.getOut(); for (CFGBlock pred : block.getSuccessors()) { if (this.cfgBlocksState.containsKey(pred)) { out.and(this.cfgBlocksState.get(pred).getIn()); } } calculateGenKillSets(block, bFlow); // Calculate Out BitSet in = bFlow.getIn(); // IN = (OUT - KILL) U GEN in.or(out); in.xor(bFlow.getKill()); in.or(bFlow.getGen()); if (!in.equals(origIn)) { // Add successors to cfgBlocks list for (CFGBlock pred : block.getPredecessors()) { if (!cfgBlocksToProcess.contains(pred)) { cfgBlocksToProcess.add(pred); } } } // Remove this block, since it has been processed cfgBlocksToProcess.remove(block); return bFlow; }