Search in sources :

Example 51 with InsnArg

use of jadx.core.dex.instructions.args.InsnArg in project jadx by skylot.

the class LiveVarAnalysis method fillBasicBlockInfo.

private void fillBasicBlockInfo() {
    for (BlockNode block : mth.getBasicBlocks()) {
        int blockId = block.getId();
        BitSet gen = uses[blockId];
        BitSet kill = defs[blockId];
        for (InsnNode insn : block.getInstructions()) {
            for (InsnArg arg : insn.getArguments()) {
                if (arg.isRegister()) {
                    int regNum = ((RegisterArg) arg).getRegNum();
                    if (!kill.get(regNum)) {
                        gen.set(regNum);
                    }
                }
            }
            RegisterArg result = insn.getResult();
            if (result != null) {
                int regNum = result.getRegNum();
                kill.set(regNum);
                assignBlocks[regNum].set(blockId);
            }
        }
    }
}
Also used : BlockNode(jadx.core.dex.nodes.BlockNode) InsnNode(jadx.core.dex.nodes.InsnNode) RegisterArg(jadx.core.dex.instructions.args.RegisterArg) InsnArg(jadx.core.dex.instructions.args.InsnArg) BitSet(java.util.BitSet)

Example 52 with InsnArg

use of jadx.core.dex.instructions.args.InsnArg in project jadx by skylot.

the class SSATransform method removePhiList.

private static boolean removePhiList(MethodNode mth, List<PhiInsn> insnToRemove) {
    for (BlockNode block : mth.getBasicBlocks()) {
        PhiListAttr phiList = block.get(AType.PHI_LIST);
        if (phiList == null) {
            continue;
        }
        List<PhiInsn> list = phiList.getList();
        for (PhiInsn phiInsn : insnToRemove) {
            if (list.remove(phiInsn)) {
                for (InsnArg arg : phiInsn.getArguments()) {
                    if (arg == null) {
                        continue;
                    }
                    SSAVar sVar = ((RegisterArg) arg).getSVar();
                    if (sVar != null) {
                        sVar.setUsedInPhi(null);
                    }
                }
                InstructionRemover.remove(mth, block, phiInsn);
            }
        }
        if (list.isEmpty()) {
            block.remove(AType.PHI_LIST);
        }
    }
    insnToRemove.clear();
    return true;
}
Also used : BlockNode(jadx.core.dex.nodes.BlockNode) RegisterArg(jadx.core.dex.instructions.args.RegisterArg) PhiInsn(jadx.core.dex.instructions.PhiInsn) SSAVar(jadx.core.dex.instructions.args.SSAVar) InsnArg(jadx.core.dex.instructions.args.InsnArg) PhiListAttr(jadx.core.dex.attributes.nodes.PhiListAttr)

Aggregations

InsnArg (jadx.core.dex.instructions.args.InsnArg)52 InsnNode (jadx.core.dex.nodes.InsnNode)32 RegisterArg (jadx.core.dex.instructions.args.RegisterArg)24 IndexInsnNode (jadx.core.dex.instructions.IndexInsnNode)19 InsnWrapArg (jadx.core.dex.instructions.args.InsnWrapArg)15 ArgType (jadx.core.dex.instructions.args.ArgType)9 SSAVar (jadx.core.dex.instructions.args.SSAVar)9 LiteralArg (jadx.core.dex.instructions.args.LiteralArg)8 BlockNode (jadx.core.dex.nodes.BlockNode)8 FieldNode (jadx.core.dex.nodes.FieldNode)7 FieldInfo (jadx.core.dex.info.FieldInfo)6 ArithNode (jadx.core.dex.instructions.ArithNode)5 InvokeNode (jadx.core.dex.instructions.InvokeNode)5 ConstClassNode (jadx.core.dex.instructions.ConstClassNode)4 PhiInsn (jadx.core.dex.instructions.PhiInsn)4 ClassNode (jadx.core.dex.nodes.ClassNode)4 PhiListAttr (jadx.core.dex.attributes.nodes.PhiListAttr)3 MethodInfo (jadx.core.dex.info.MethodInfo)3 SwitchNode (jadx.core.dex.instructions.SwitchNode)3 MethodNode (jadx.core.dex.nodes.MethodNode)3