/** * Removes all blocks containing only GOTOs from the control flow. * Although much of this work will be done later when converting * from rop to dex, not all simplification cases can be handled * there. Furthermore, any no-op block between the exit block and * blocks containing the real return or throw statements must be * removed. */ private void removeEmptyGotos() { final ArrayList<SsaBasicBlock> blocks = ssaMeth.getBlocks(); ssaMeth.forEachBlockDepthFirst(false, new SsaBasicBlock.Visitor() { @Override public void visitBlock(SsaBasicBlock b, SsaBasicBlock parent) { ArrayList<SsaInsn> insns = b.getInsns(); if ((insns.size() == 1) && (insns.get(0).getOpcode() == Rops.GOTO)) { BitSet preds = (BitSet) b.getPredecessors().clone(); for (int i = preds.nextSetBit(0); i >= 0; i = preds.nextSetBit(i + 1)) { SsaBasicBlock pb = blocks.get(i); pb.replaceSuccessor(b.getIndex(), b.getPrimarySuccessorIndex()); } } } }); }
/** * Removes all blocks containing only GOTOs from the control flow. * Although much of this work will be done later when converting * from rop to dex, not all simplification cases can be handled * there. Furthermore, any no-op block between the exit block and * blocks containing the real return or throw statements must be * removed. */ private void removeEmptyGotos() { final ArrayList<SsaBasicBlock> blocks = ssaMeth.getBlocks(); ssaMeth.forEachBlockDepthFirst(false, new SsaBasicBlock.Visitor() { public void visitBlock(SsaBasicBlock b, SsaBasicBlock parent) { ArrayList<SsaInsn> insns = b.getInsns(); if ((insns.size() == 1) && (insns.get(0).getOpcode() == Rops.GOTO)) { BitSet preds = (BitSet) b.getPredecessors().clone(); for (int i = preds.nextSetBit(0); i >= 0; i = preds.nextSetBit(i + 1)) { SsaBasicBlock pb = blocks.get(i); pb.replaceSuccessor(b.getIndex(), b.getPrimarySuccessorIndex()); } } } }); }
/** * Removes all blocks containing only GOTOs from the control flow. * Although much of this work will be done later when converting * from rop to dex, not all simplification cases can be handled * there. Furthermore, any no-op block between the exit block and * blocks containing the real return or throw statements must be * removed. */ private void removeEmptyGotos() { final ArrayList<SsaBasicBlock> blocks = ssaMeth.getBlocks(); ssaMeth.forEachBlockDepthFirst(false, new SsaBasicBlock.Visitor() { public void visitBlock(SsaBasicBlock b, SsaBasicBlock parent) { ArrayList<SsaInsn> insns = b.getInsns(); if ((insns.size() == 1) && (insns.get(0).getOpcode() == Rops.GOTO)) { BitSet preds = (BitSet) b.getPredecessors().clone(); for (int i = preds.nextSetBit(0); i >= 0; i = preds.nextSetBit(i + 1)) { SsaBasicBlock pb = blocks.get(i); pb.replaceSuccessor(b.getIndex(), b.getPrimarySuccessorIndex()); } } } }); }
/** * Removes all blocks containing only GOTOs from the control flow. * Although much of this work will be done later when converting * from rop to dex, not all simplification cases can be handled * there. Furthermore, any no-op block between the exit block and * blocks containing the real return or throw statements must be * removed. */ private void removeEmptyGotos() { final ArrayList<SsaBasicBlock> blocks = ssaMeth.getBlocks(); ssaMeth.forEachBlockDepthFirst(false, new SsaBasicBlock.Visitor() { public void visitBlock(SsaBasicBlock b, SsaBasicBlock parent) { ArrayList<SsaInsn> insns = b.getInsns(); if ((insns.size() == 1) && (insns.get(0).getOpcode() == Rops.GOTO)) { BitSet preds = (BitSet) b.getPredecessors().clone(); for (int i = preds.nextSetBit(0); i >= 0; i = preds.nextSetBit(i + 1)) { SsaBasicBlock pb = blocks.get(i); pb.replaceSuccessor(b.getIndex(), b.getPrimarySuccessorIndex()); } } } }); }
/** * Removes all blocks containing only GOTOs from the control flow. * Although much of this work will be done later when converting * from rop to dex, not all simplification cases can be handled * there. Furthermore, any no-op block between the exit block and * blocks containing the real return or throw statements must be * removed. */ private void removeEmptyGotos() { final ArrayList<SsaBasicBlock> blocks = ssaMeth.getBlocks(); ssaMeth.forEachBlockDepthFirst(false, new SsaBasicBlock.Visitor() { @Override public void visitBlock(SsaBasicBlock b, SsaBasicBlock parent) { ArrayList<SsaInsn> insns = b.getInsns(); if ((insns.size() == 1) && (insns.get(0).getOpcode() == Rops.GOTO)) { BitSet preds = (BitSet) b.getPredecessors().clone(); for (int i = preds.nextSetBit(0); i >= 0; i = preds.nextSetBit(i + 1)) { SsaBasicBlock pb = blocks.get(i); pb.replaceSuccessor(b.getIndex(), b.getPrimarySuccessorIndex()); } } } }); }
/** * Removes all blocks containing only GOTOs from the control flow. * Although much of this work will be done later when converting * from rop to dex, not all simplification cases can be handled * there. Furthermore, any no-op block between the exit block and * blocks containing the real return or throw statements must be * removed. */ private void removeEmptyGotos() { final ArrayList<SsaBasicBlock> blocks = ssaMeth.getBlocks(); ssaMeth.forEachBlockDepthFirst(false, new SsaBasicBlock.Visitor() { public void visitBlock(SsaBasicBlock b, SsaBasicBlock parent) { ArrayList<SsaInsn> insns = b.getInsns(); if ((insns.size() == 1) && (insns.get(0).getOpcode() == Rops.GOTO)) { BitSet preds = (BitSet) b.getPredecessors().clone(); for (int i = preds.nextSetBit(0); i >= 0; i = preds.nextSetBit(i + 1)) { SsaBasicBlock pb = blocks.get(i); pb.replaceSuccessor(b.getIndex(), b.getPrimarySuccessorIndex()); } } } }); }
/** * Removes all blocks containing only GOTOs from the control flow. * Although much of this work will be done later when converting * from rop to dex, not all simplification cases can be handled * there. Furthermore, any no-op block between the exit block and * blocks containing the real return or throw statements must be * removed. */ private void removeEmptyGotos() { final ArrayList<SsaBasicBlock> blocks = ssaMeth.getBlocks(); ssaMeth.forEachBlockDepthFirst(false, new SsaBasicBlock.Visitor() { public void visitBlock(SsaBasicBlock b, SsaBasicBlock parent) { ArrayList<SsaInsn> insns = b.getInsns(); if ((insns.size() == 1) && (insns.get(0).getOpcode() == Rops.GOTO)) { BitSet preds = (BitSet) b.getPredecessors().clone(); for (int i = preds.nextSetBit(0); i >= 0; i = preds.nextSetBit(i + 1)) { SsaBasicBlock pb = blocks.get(i); pb.replaceSuccessor(b.getIndex(), b.getPrimarySuccessorIndex()); } } } }); }
/** * Removes all blocks containing only GOTOs from the control flow. * Although much of this work will be done later when converting * from rop to dex, not all simplification cases can be handled * there. Furthermore, any no-op block between the exit block and * blocks containing the real return or throw statements must be * removed. */ private void removeEmptyGotos() { final ArrayList<SsaBasicBlock> blocks = ssaMeth.getBlocks(); ssaMeth.forEachBlockDepthFirst(false, new SsaBasicBlock.Visitor() { public void visitBlock(SsaBasicBlock b, SsaBasicBlock parent) { ArrayList<SsaInsn> insns = b.getInsns(); if ((insns.size() == 1) && (insns.get(0).getOpcode() == Rops.GOTO)) { BitSet preds = (BitSet) b.getPredecessors().clone(); for (int i = preds.nextSetBit(0); i >= 0; i = preds.nextSetBit(i + 1)) { SsaBasicBlock pb = blocks.get(i); pb.replaceSuccessor(b.getIndex(), b.getPrimarySuccessorIndex()); } } } }); }
meth.forEachBlockDepthFirst(postdom, walker);
meth.forEachBlockDepthFirst(postdom, walker);
meth.forEachBlockDepthFirst(postdom, walker);
meth.forEachBlockDepthFirst(postdom, walker);
meth.forEachBlockDepthFirst(postdom, walker);
meth.forEachBlockDepthFirst(postdom, walker);
meth.forEachBlockDepthFirst(postdom, walker);
meth.forEachBlockDepthFirst(postdom, walker);