From 5d393aeee1e4e60bbbbf381b7c8f94a7d2dd4064 Mon Sep 17 00:00:00 2001 From: zhangyukun Date: Thu, 24 Feb 2022 15:53:56 +0800 Subject: [PATCH] Fix kinds of operands of HandleCmp dismatch MachineType::ARCH is equal to MachineType::I32 on 32 bits platform and MachineType::I64 on 64 bits platform Signed-off-by: zhangyukun Change-Id: I41dfc96c5dacc0b2108dc90730500f2bc51ecd24 --- ecmascript/compiler/interpreter_stub.cpp | 4 ++-- ecmascript/compiler/llvm_ir_builder.cpp | 6 +++++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/ecmascript/compiler/interpreter_stub.cpp b/ecmascript/compiler/interpreter_stub.cpp index e34f244c..06ac40a3 100644 --- a/ecmascript/compiler/interpreter_stub.cpp +++ b/ecmascript/compiler/interpreter_stub.cpp @@ -1049,7 +1049,7 @@ DECLARE_ASM_HANDLER(SingleStepDebugging) Label shouldReturn(env); Label shouldContinue(env); - Branch(IntPtrEqual(ChangeTaggedPointerToInt64(*varPc), GetInt64Constant(0)), &shouldReturn, &shouldContinue); + Branch(IntPtrEqual(*varPc, GetIntPtrConstant(0)), &shouldReturn, &shouldContinue); Bind(&shouldReturn); { Return(); @@ -3948,7 +3948,7 @@ DECLARE_ASM_HANDLER(ExceptionHandler) GateRef exception = Load(StubMachineType::TAGGED, glue, GetIntPtrConstant(0)); StubDescriptor *upFrame = GET_STUBDESCRIPTOR(UpFrame); varPc = CallRuntime(upFrame, glue, GetInt64Constant(FAST_STUB_ID(UpFrame)), { glue, sp }); - Branch(IntPtrEqual(ChangeTaggedPointerToInt64(*varPc), GetInt64Constant(0)), &pcIsInvalid, &pcNotInvalid); + Branch(IntPtrEqual(*varPc, GetIntPtrConstant(0)), &pcIsInvalid, &pcNotInvalid); Bind(&pcIsInvalid); { Return(); diff --git a/ecmascript/compiler/llvm_ir_builder.cpp b/ecmascript/compiler/llvm_ir_builder.cpp index fccf4c7e..2a2624e8 100644 --- a/ecmascript/compiler/llvm_ir_builder.cpp +++ b/ecmascript/compiler/llvm_ir_builder.cpp @@ -1412,7 +1412,11 @@ void LLVMIRBuilder::VisitCmp(GateRef gate, GateRef e1, GateRef e2) LLVMValueRef result = nullptr; auto e1ValCode = circuit_->LoadGatePtrConst(e1)->GetMachineType(); [[maybe_unused]]auto e2ValCode = circuit_->LoadGatePtrConst(e2)->GetMachineType(); - ASSERT(e1ValCode == e2ValCode); + ASSERT((e1ValCode == e2ValCode) || + (compCfg_->Is32Bit() && (e1ValCode == MachineType::ARCH) && (e2ValCode == MachineType::I32)) || + (compCfg_->Is64Bit() && (e1ValCode == MachineType::ARCH) && (e2ValCode == MachineType::I64)) || + (compCfg_->Is32Bit() && (e2ValCode == MachineType::ARCH) && (e1ValCode == MachineType::I32)) || + (compCfg_->Is64Bit() && (e2ValCode == MachineType::ARCH) && (e1ValCode == MachineType::I64))); LLVMIntPredicate intOpcode = LLVMIntEQ; LLVMRealPredicate realOpcode = LLVMRealPredicateFalse; switch (circuit_->GetOpCode(gate)) {