From 05d827a5f8678e76fd08d2c4329574c2b261b67b Mon Sep 17 00:00:00 2001 From: linma Date: Tue, 20 Apr 2021 22:45:43 -0700 Subject: [PATCH] OP_alloca Node verify: skip Compatible type check between return type and operand type constantfold: use uint32 to do arithmentic operation to avoid overflow exception --- src/mapleall/maple_ir/src/mir_nodes.cpp | 6 +++++- src/mapleall/mpl2mpl/src/constantfold.cpp | 6 +++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/mapleall/maple_ir/src/mir_nodes.cpp b/src/mapleall/maple_ir/src/mir_nodes.cpp index 2be22a775d..05b27f6795 100644 --- a/src/mapleall/maple_ir/src/mir_nodes.cpp +++ b/src/mapleall/maple_ir/src/mir_nodes.cpp @@ -1431,7 +1431,11 @@ bool UnaryNode::Verify() const { // When an opcode only specifies one type, check for compatibility // between the operands and the result-type. - bool compVerf = CompatibleTypeVerify(*uOpnd, *this); + bool compVerf = true; + // op_alloca : return type is not compatible with operand, skip + if (GetOpCode() != OP_alloca) { + compVerf = CompatibleTypeVerify(*uOpnd, *this); + } bool opndExprVerf = uOpnd->Verify(); return resTypeVerf && compVerf && opndExprVerf; } diff --git a/src/mapleall/mpl2mpl/src/constantfold.cpp b/src/mapleall/mpl2mpl/src/constantfold.cpp index 95e7aa1dd9..c5901c9038 100644 --- a/src/mapleall/mpl2mpl/src/constantfold.cpp +++ b/src/mapleall/mpl2mpl/src/constantfold.cpp @@ -449,7 +449,7 @@ MIRConst *ConstantFold::FoldIntConstBinaryMIRConst(Opcode opcode, PrimType resul if (useResult64) { result64 = intValueOfConst0 + intValueOfConst1; } else { - result32 = static_cast(static_cast(intValueOfConst0) + static_cast(intValueOfConst1)); + result32 = static_cast(intValueOfConst0) + static_cast(intValueOfConst1); } break; } @@ -457,7 +457,7 @@ MIRConst *ConstantFold::FoldIntConstBinaryMIRConst(Opcode opcode, PrimType resul if (useResult64) { result64 = static_cast(intValueOfConst0 - intValueOfConst1); } else { - result32 = static_cast(static_cast(intValueOfConst0) - static_cast(intValueOfConst1)); + result32 = static_cast(intValueOfConst0) - static_cast(intValueOfConst1); } break; } @@ -465,7 +465,7 @@ MIRConst *ConstantFold::FoldIntConstBinaryMIRConst(Opcode opcode, PrimType resul if (useResult64) { result64 = static_cast(intValueOfConst0 * intValueOfConst1); } else { - result32 = static_cast(static_cast(intValueOfConst0) * static_cast(intValueOfConst1)); + result32 = static_cast(intValueOfConst0) * static_cast(intValueOfConst1); } break; } -- Gitee