diff --git a/src/mapleall/bin/dex2mpl b/src/mapleall/bin/dex2mpl index 85f50967dbf5e5deb7fef8a24eb88ff3e570cd1c..48d02708904973cf64a4fa31b56f29507d03b73b 100755 Binary files a/src/mapleall/bin/dex2mpl and b/src/mapleall/bin/dex2mpl differ diff --git a/src/mapleall/bin/dex2mpl_android b/src/mapleall/bin/dex2mpl_android index f8c967e95aa27a28d1b61ba3e273e2662e814c0f..c63ad5ec2b337412a953f9293e1a97f2ba0ed174 100755 Binary files a/src/mapleall/bin/dex2mpl_android and b/src/mapleall/bin/dex2mpl_android differ diff --git a/src/mapleall/bin/jbc2mpl b/src/mapleall/bin/jbc2mpl index 043c0fee411604d1df78b17e99db691f65f1dbc9..bdf1ee430b000cbf59ec4768421682ddb6c55c62 100755 Binary files a/src/mapleall/bin/jbc2mpl and b/src/mapleall/bin/jbc2mpl differ diff --git a/src/mapleall/maple_be/include/be/common_utils.h b/src/mapleall/maple_be/include/be/common_utils.h index 659024f6369fb53b51c9c9a904cf5198253c692b..24a73f53c72537206363617a9303e6b7ac9bd4c9 100644 --- a/src/mapleall/maple_be/include/be/common_utils.h +++ b/src/mapleall/maple_be/include/be/common_utils.h @@ -81,7 +81,6 @@ constexpr uint32 kOperandPosition0 = 0; constexpr uint32 kOperandPosition1 = 1; constexpr uint32 kOperandPosition2 = 2; - /* Size of struct for memcpy */ constexpr uint32 kParmMemcpySize = 40; diff --git a/src/mapleall/maple_be/include/be/lower.h b/src/mapleall/maple_be/include/be/lower.h index a2f94b183ffd6a34e3c19fcf78e2a616fbdfa829..f1ba66884a31527740f4961b42eb9ce4764fd824 100644 --- a/src/mapleall/maple_be/include/be/lower.h +++ b/src/mapleall/maple_be/include/be/lower.h @@ -132,7 +132,7 @@ class CGLowerer { BaseNode *LowerIaddrof(const IreadNode &iaddrof); BaseNode *SplitBinaryNodeOpnd1(BinaryNode &bNode, BlockNode &blkNode); BaseNode *SplitTernaryNodeResult(TernaryNode &tNode, BaseNode &parent, BlockNode &blkNode); - bool IsComplexSelect(const TernaryNode &tNode); + bool IsComplexSelect(const TernaryNode &tNode) const; BaseNode *LowerComplexSelect(TernaryNode &tNode, BaseNode &parent, BlockNode &blkNode); BaseNode *LowerFarray(ArrayNode &array); BaseNode *LowerArrayDim(ArrayNode &array, int32 dim); diff --git a/src/mapleall/maple_be/include/cg/aarch64/aarch64_insn.h b/src/mapleall/maple_be/include/cg/aarch64/aarch64_insn.h index 8235e373ef31ce10eeb952f8094029d7d3747216..a6d3512233a787c549f23a843b22fb22344ac4ae 100644 --- a/src/mapleall/maple_be/include/cg/aarch64/aarch64_insn.h +++ b/src/mapleall/maple_be/include/cg/aarch64/aarch64_insn.h @@ -159,7 +159,7 @@ class AArch64Insn : public Insn { uint32 GetJumpTargetIdxFromMOp(MOperator mOp) const override; - MOperator FlipConditionOp(MOperator flippedOp, int &targetIdx) override; + MOperator FlipConditionOp(MOperator flippedOp, uint32 &targetIdx) override; bool CheckRefField(size_t opndIndex, bool isEmit) const; diff --git a/src/mapleall/maple_be/include/cg/cgbb.h b/src/mapleall/maple_be/include/cg/cgbb.h index f63b43b50f02a08ffaf858467e0a8b2dc30bef50..f990ab17217c4871066ce742db5b93510380bc6b 100644 --- a/src/mapleall/maple_be/include/cg/cgbb.h +++ b/src/mapleall/maple_be/include/cg/cgbb.h @@ -341,7 +341,7 @@ class BB { void SetLastInsn(Insn *arg) { lastInsn = arg; } - bool IsLastInsn(Insn *insn) { + bool IsLastInsn(const Insn *insn) const{ return (lastInsn == insn); } const MapleList &GetPreds() const { diff --git a/src/mapleall/maple_be/include/cg/insn.h b/src/mapleall/maple_be/include/cg/insn.h index 4511765f8e95b0ea1ec9c6fb4cfee36f05456995..50f24668f5f06f0449981385ebbf93c940a70ac2 100644 --- a/src/mapleall/maple_be/include/cg/insn.h +++ b/src/mapleall/maple_be/include/cg/insn.h @@ -477,10 +477,13 @@ class Insn { } virtual uint32 GetJumpTargetIdxFromMOp(MOperator mOp) const { + (void)mOp; return 0; } - virtual MOperator FlipConditionOp(MOperator flippedOp, int &targetIdx) { + virtual MOperator FlipConditionOp(MOperator flippedOp, uint32 &targetIdx) { + (void)flippedOp; + (void)targetIdx; return 0; } diff --git a/src/mapleall/maple_be/src/be/lower.cpp b/src/mapleall/maple_be/src/be/lower.cpp index 61beeb2cd6e34d4be40b45fee0a58f7e4ec1cdae..1faf839cf9491bf2f9f83b631ff8da3c9bbb386d 100644 --- a/src/mapleall/maple_be/src/be/lower.cpp +++ b/src/mapleall/maple_be/src/be/lower.cpp @@ -223,7 +223,7 @@ BaseNode *CGLowerer::SplitTernaryNodeResult(TernaryNode &tNode, BaseNode &parent blkNode.InsertAfter(blkNode.GetLast(), dassignNode); BaseNode *dreadNode = mirbuilder->CreateExprDread(*dassignNodeSym); - for (int32 i = 0; i < parent.NumOpnds(); i++) { + for (size_t i = 0; i < parent.NumOpnds(); i++) { if (parent.Opnd(i) == &tNode) { parent.SetOpnd(dreadNode, i); break; @@ -236,12 +236,12 @@ BaseNode *CGLowerer::SplitTernaryNodeResult(TernaryNode &tNode, BaseNode &parent /* Check if the operand of the select node is complex enough for either * functionality or performance reason so we need to lower it to if-then-else. */ -bool CGLowerer::IsComplexSelect(const TernaryNode &tNode) { +bool CGLowerer::IsComplexSelect(const TernaryNode &tNode) const { if (tNode.GetPrimType() == PTY_agg) return true; /* Iread may have side effect which may cause correctness issue. */ - if (tNode.Opnd(1)->op == OP_iread ||tNode.Opnd(2)->op == OP_iread) + if (tNode.Opnd(1)->op == OP_iread || tNode.Opnd(2)->op == OP_iread) return true; return false; @@ -261,7 +261,8 @@ BaseNode *CGLowerer::LowerComplexSelect(TernaryNode &tNode, BaseNode &parent, Bl resultTy = mirModule.CurFunction()->GetLocalOrGlobalSymbol(trueNode->GetStIdx())->GetType(); } else if (tNode.Opnd(1)->op == OP_iread) { IreadNode *trueNode = static_cast(tNode.Opnd(1)); - MIRPtrType *ptrty = static_cast(GlobalTables::GetTypeTable().GetTypeFromTyIdx(trueNode->GetTyIdx())); + MIRPtrType *ptrty = + static_cast(GlobalTables::GetTypeTable().GetTypeFromTyIdx(trueNode->GetTyIdx())); resultTy = static_cast(GlobalTables::GetTypeTable().GetTypeFromTyIdx(ptrty->GetPointedTyIdx())); if (trueNode->GetFieldID() != 0) { MIRStructType *structty = static_cast(resultTy); @@ -274,7 +275,7 @@ BaseNode *CGLowerer::LowerComplexSelect(TernaryNode &tNode, BaseNode &parent, Bl resultTy = GlobalTables::GetTypeTable().GetTypeFromTyIdx((TyIdx)(tNode.GetPrimType())); } - MIRSymbol * resultSym = mirbuilder->GetOrCreateLocalDecl(const_cast(name), *resultTy); + MIRSymbol *resultSym = mirbuilder->GetOrCreateLocalDecl(const_cast(name), *resultTy); CondGotoNode *brTargetStmt = mirModule.CurFuncCodeMemPool()->New(OP_brfalse); brTargetStmt->SetOpnd(tNode.Opnd(0), 0); LabelIdx targetIdx = mirModule.CurFunction()->GetLabelTab()->CreateLabel(); @@ -295,7 +296,8 @@ BaseNode *CGLowerer::LowerComplexSelect(TernaryNode &tNode, BaseNode &parent, Bl lableStmt->SetLabelIdx(targetIdx); blkNode.InsertAfter(blkNode.GetLast(), lableStmt); - DassignNode *dassignFalse = mirbuilder->CreateStmtDassign(static_cast(*resultSym), 0, tNode.Opnd(2)); + DassignNode *dassignFalse = + mirbuilder->CreateStmtDassign(static_cast(*resultSym), 0, tNode.Opnd(2)); blkNode.InsertAfter(blkNode.GetLast(), dassignFalse); lableStmt = mirModule.CurFuncCodeMemPool()->New(); @@ -303,7 +305,7 @@ BaseNode *CGLowerer::LowerComplexSelect(TernaryNode &tNode, BaseNode &parent, Bl blkNode.InsertAfter(blkNode.GetLast(), lableStmt); BaseNode *dreadNode = mirbuilder->CreateExprDread(*resultSym); - for (int32 i = 0; i < parent.NumOpnds(); i++) { + for (size_t i = 0; i < parent.NumOpnds(); i++) { if (parent.Opnd(i) == &tNode) { parent.SetOpnd(dreadNode, i); break; @@ -2703,8 +2705,9 @@ BaseNode *CGLowerer::LowerIntrinsicop(const BaseNode &parent, IntrinsicopNode &i } if (intrnID == INTRN_C_constant_p) { BaseNode *opnd = intrinNode.Opnd(0); - return mirModule.GetMIRBuilder()->CreateIntConst(opnd->op == OP_constval || opnd->op == OP_sizeoftype || - opnd->op == OP_conststr || opnd->op == OP_conststr16, PTY_i32); + int64 val = (opnd->op == OP_constval || opnd->op == OP_sizeoftype || + opnd->op == OP_conststr || opnd->op == OP_conststr16) ? 1 : 0; + return mirModule.GetMIRBuilder()->CreateIntConst(val, PTY_i32); } CHECK_FATAL(false, "unexpected intrinsic type in CGLowerer::LowerIntrinsicop"); return &intrinNode; diff --git a/src/mapleall/maple_be/src/cg/aarch64/aarch64_cgfunc.cpp b/src/mapleall/maple_be/src/cg/aarch64/aarch64_cgfunc.cpp index 806f12e8e012d7df9e72812d45da616fbf9232c3..2e831945769f901d232130a97942dffadb57e373 100644 --- a/src/mapleall/maple_be/src/cg/aarch64/aarch64_cgfunc.cpp +++ b/src/mapleall/maple_be/src/cg/aarch64/aarch64_cgfunc.cpp @@ -3747,9 +3747,8 @@ Operand *AArch64CGFunc::SelectRetype(TypeCvtNode &node, Operand &opnd0) { } if ((IsPrimitiveFloat(fromType) && IsPrimitiveInteger(toType)) || (IsPrimitiveFloat(toType) && IsPrimitiveInteger(fromType))) { - MOperator mopFmov = - isImm ? is64Bits ? MOP_xdfmovri : MOP_wsfmovri - : isFromInt ? (is64Bits ? MOP_xvmovdr : MOP_xvmovsr) : (is64Bits ? MOP_xvmovrd : MOP_xvmovrs); + MOperator mopFmov = (isImm ? (is64Bits ? MOP_xdfmovri : MOP_wsfmovri) : isFromInt) ? + (is64Bits ? MOP_xvmovdr : MOP_xvmovsr) : (is64Bits ? MOP_xvmovrd : MOP_xvmovrs); GetCurBB()->AppendInsn(GetCG()->BuildInstruction(mopFmov, *resOpnd, *newOpnd0)); return resOpnd; } else { diff --git a/src/mapleall/maple_be/src/cg/aarch64/aarch64_insn.cpp b/src/mapleall/maple_be/src/cg/aarch64/aarch64_insn.cpp index 0be0b7b071313cd2bea2137b2fef0e3f7a114f11..7488ed7a7c6d3e45b5521561960d197767843095 100644 --- a/src/mapleall/maple_be/src/cg/aarch64/aarch64_insn.cpp +++ b/src/mapleall/maple_be/src/cg/aarch64/aarch64_insn.cpp @@ -1505,7 +1505,7 @@ uint32 AArch64Insn::GetJumpTargetIdxFromMOp(MOperator mOp) const { return kOperandPosition0; } -MOperator AArch64Insn::FlipConditionOp(MOperator originalOp, int &targetIdx) { +MOperator AArch64Insn::FlipConditionOp(MOperator originalOp, uint32 &targetIdx) { targetIdx = 1; switch (originalOp) { case AArch64MOP_t::MOP_beq: diff --git a/src/mapleall/maple_be/src/cg/aarch64/aarch64_optimize_common.cpp b/src/mapleall/maple_be/src/cg/aarch64/aarch64_optimize_common.cpp index f71796864a7f2057c281b5d3186404ee359d23eb..b34da32948fc1e4753e96c963b7ad01de1cc5eed 100644 --- a/src/mapleall/maple_be/src/cg/aarch64/aarch64_optimize_common.cpp +++ b/src/mapleall/maple_be/src/cg/aarch64/aarch64_optimize_common.cpp @@ -18,7 +18,6 @@ #include "cgbb.h" namespace maplebe { - void AArch64InsnVisitor::ModifyJumpTarget(Operand &targetOperand, BB &bb) { bb.GetLastInsn()->SetOperand(bb.GetLastInsn()->GetJumpTargetIdx(), targetOperand); } @@ -28,7 +27,8 @@ void AArch64InsnVisitor::ModifyJumpTarget(maple::LabelIdx targetLabel, BB &bb) { } void AArch64InsnVisitor::ModifyJumpTarget(BB &newTarget, BB &bb) { - ModifyJumpTarget(newTarget.GetLastInsn()->GetOperand(newTarget.GetLastInsn()->GetJumpTargetIdx()), bb); + ModifyJumpTarget(newTarget.GetLastInsn()->GetOperand( + static_cast(newTarget.GetLastInsn()->GetJumpTargetIdx())), bb); } Insn *AArch64InsnVisitor::CloneInsn(Insn &originalInsn) { @@ -49,7 +49,7 @@ Insn *AArch64InsnVisitor::CloneInsn(Insn &originalInsn) { * because a register instead of label. So we don't take it as a branching instruction. */ LabelIdx AArch64InsnVisitor::GetJumpLabel(const Insn &insn) const { - int operandIdx = insn.GetJumpTargetIdx(); + int operandIdx = static_cast(insn.GetJumpTargetIdx()); if (insn.GetOperand(operandIdx).IsLabelOpnd()) { return static_cast(insn.GetOperand(operandIdx)).GetLabelIndex(); } diff --git a/src/mapleall/maple_be/src/cg/cfgo.cpp b/src/mapleall/maple_be/src/cg/cfgo.cpp index 9fc601e80681885713d77403c74c464af6919d1a..94bd5f41056774eef61a420e2235485674e7af4e 100644 --- a/src/mapleall/maple_be/src/cg/cfgo.cpp +++ b/src/mapleall/maple_be/src/cg/cfgo.cpp @@ -411,7 +411,7 @@ void FlipBRPattern::RelocateThrowBB(BB &curBB) { CHECK_FATAL(curBBBranchInsn != nullptr, "curBB(it is a kBBif) has no branch"); /* Reverse the branch */ - int targetIdx = 1; + uint32 targetIdx = 1; MOperator mOp = curBBBranchInsn->FlipConditionOp(curBBBranchInsn->GetMachineOpcode(), targetIdx); LabelOperand &brTarget = cgFunc->GetOrCreateLabelOperand(*ftBB); curBBBranchInsn->SetMOperator(mOp); @@ -471,9 +471,8 @@ bool FlipBRPattern::Optimize(BB &curBB) { ASSERT(brInsn != nullptr, "FlipBRPattern: ftBB has no branch"); /* Reverse the branch */ - int targetIdx = brInsn->GetJumpTargetIdx(); - MOperator mOp = curBBBranchInsn->FlipConditionOp(curBBBranchInsn->GetMachineOpcode(), - targetIdx); + uint32 targetIdx = brInsn->GetJumpTargetIdx(); + MOperator mOp = curBBBranchInsn->FlipConditionOp(curBBBranchInsn->GetMachineOpcode(), targetIdx); if (mOp == 0) { return false; } @@ -484,7 +483,7 @@ bool FlipBRPattern::Optimize(BB &curBB) { (!IsLabelInLSDAOrSwitchTable(tgtBB->GetLabIdx()) && cgFunc->GetTheCFG()->CanMerge(*ftBB, *tgtBB)))) { curBBBranchInsn->SetMOperator(mOp); - Operand &brTarget = brInsn->GetOperand(brInsn->GetJumpTargetIdx()); + Operand &brTarget = brInsn->GetOperand(static_cast(brInsn->GetJumpTargetIdx())); curBBBranchInsn->SetOperand(targetIdx, brTarget); /* Insert ftBB's insn at the beginning of tgtBB. */ if (!ftBB->IsSoloGoto()) { diff --git a/src/mapleall/maple_ir/src/parser.cpp b/src/mapleall/maple_ir/src/parser.cpp index 31d369c532269c4133cefea828f53ae515c89464..b80a4253ba9045ff79b70af7a4856f3d04b4c3ad 100644 --- a/src/mapleall/maple_ir/src/parser.cpp +++ b/src/mapleall/maple_ir/src/parser.cpp @@ -816,8 +816,7 @@ bool MIRParser::ParseStructType(TyIdx &styIdx) { // Dex file create a struct type with name, but do not check the type field. if (styIdx != 0u) { MIRType *prevType = GlobalTables::GetTypeTable().GetTypeFromTyIdx(styIdx); - ASSERT(prevType->GetKind() == kTypeStruct || prevType->IsIncomplete(), - "type kind should be consistent."); + ASSERT(prevType->GetKind() == kTypeStruct || prevType->IsIncomplete(), "type kind should be consistent."); if (static_cast(prevType)->IsIncomplete() && !(structType.IsIncomplete())) { structType.SetNameStrIdx(prevType->GetNameStrIdx()); structType.SetTypeIndex(styIdx); @@ -1463,7 +1462,6 @@ bool MIRParser::ParseTypedef() { const std::string &name = lexer.GetName(); GStrIdx strIdx = GlobalTables::GetStrTable().GetOrCreateStrIdxFromName(name); TyIdx prevTyIdx; - MIRStructType *prevStructType = nullptr; TyIdx tyIdx(0); // dbginfo class/interface init if (tokenKind == TK_gname) { @@ -1477,8 +1475,7 @@ bool MIRParser::ParseTypedef() { if (!mod.IsCModule()) { CHECK_FATAL(prevType->IsStructType(), "type error"); } - prevStructType = dynamic_cast(prevType); - if ((prevType->GetKind() != kTypeByName) && (prevStructType && !prevStructType->IsIncomplete())) { + if ((prevType->GetKind() != kTypeByName) && !prevType->IsIncomplete()) { // allow duplicated type def if kKeepFirst is set which is the default if (options & kKeepFirst) { lexer.NextToken(); @@ -1502,8 +1499,7 @@ bool MIRParser::ParseTypedef() { prevTyIdx = mod.CurFunction()->GetTyIdxFromGStrIdx(strIdx); if (prevTyIdx != 0u) { MIRType *prevType = GlobalTables::GetTypeTable().GetTypeFromTyIdx(prevTyIdx); - prevStructType = dynamic_cast(prevType); - if ((prevType->GetKind() != kTypeByName) && (prevStructType && !prevStructType->IsIncomplete())) { + if ((prevType->GetKind() != kTypeByName) && !prevType->IsIncomplete()) { Error("redefined local type name "); return false; } @@ -1544,7 +1540,7 @@ bool MIRParser::ParseTypedef() { if (prevTyIdx != TyIdx(0) && prevTyIdx != tyIdx) { // replace all uses of prev_tyidx by tyIdx in typeTable - typeDefIdxMap[prevTyIdx] = tyIdx; // record the real tydix + typeDefIdxMap[prevTyIdx] = tyIdx; // record the real tydix // remove prev_tyidx from classlist mod.RemoveClass(prevTyIdx); } diff --git a/src/mapleall/mpl2mpl/include/constantfold.h b/src/mapleall/mpl2mpl/include/constantfold.h index 0bf8d497a0775c36977b71a6a67618e434f91cd8..4b45e1b58a601643acfe9477adf67979cfd01a93 100644 --- a/src/mapleall/mpl2mpl/include/constantfold.h +++ b/src/mapleall/mpl2mpl/include/constantfold.h @@ -133,9 +133,6 @@ class DoConstantFold : public ModulePhase { AnalysisResult *Run(MIRModule *mod, ModuleResultMgr *mrm) override { OPT_TEMPLATE(ConstantFold); - if (MeOption::meVerify) { - VerifyGlobalTypeTable(); - } return nullptr; } }; diff --git a/src/mapleall/mpl2mpl/src/preme.cpp b/src/mapleall/mpl2mpl/src/preme.cpp index 494121f293316870e4000773ffb102a8ef68f188..bea7353308f16bb80eecd4271910092589b37a79 100644 --- a/src/mapleall/mpl2mpl/src/preme.cpp +++ b/src/mapleall/mpl2mpl/src/preme.cpp @@ -79,9 +79,6 @@ AnalysisResult *DoPreme::Run(MIRModule *mod, ModuleResultMgr *mrm) { if (MeOption::optLevel == 2) { CreateMIRTypeForLowerGlobalDreads(); } - if (MeOption::meVerify) { - VerifyGlobalTypeTable(); - } return nullptr; } } // namespace maple