From 439c6bb3c01763ddb50d85bb48eaa66f8fe8810f Mon Sep 17 00:00:00 2001 From: Tony Wasserka Date: Tue, 19 Aug 2025 22:28:04 +0200 Subject: [PATCH] OpcodeDispatcher: Simplify convoluted logic for computing call offsets --- FEXCore/Source/Interface/Core/OpcodeDispatcher.cpp | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/FEXCore/Source/Interface/Core/OpcodeDispatcher.cpp b/FEXCore/Source/Interface/Core/OpcodeDispatcher.cpp index 1802508a3..9334f8a25 100644 --- a/FEXCore/Source/Interface/Core/OpcodeDispatcher.cpp +++ b/FEXCore/Source/Interface/Core/OpcodeDispatcher.cpp @@ -514,18 +514,17 @@ void OpDispatchBuilder::CALLOp(OpcodeArgs) { BlockSetRIP = true; // Call instruction only uses up to 32-bit signed displacement - int64_t TargetOffset = Op->Src[0].Literal(); + const int64_t TargetOffset = Op->Src[0].Literal(); - auto ConstantPC = GetRelocatedPC(Op); + const auto ConstantPC = GetRelocatedPC(Op); // Push the return address. Push(GPRSize, ConstantPC); - const uint64_t NextRIP = Op->PC + Op->InstSize; - uint64_t TargetRIP = NextRIP + TargetOffset; - - if (NextRIP != TargetRIP) { + if (TargetOffset != 0) { // Store the RIP + const uint64_t NextRIP = Op->PC + Op->InstSize; + ExitRelocatedPC(Op, TargetOffset, BranchHint::Call, ConstantPC, [&]() { auto CallReturnJumpTarget = JumpTargets.find(NextRIP); if (CallReturnJumpTarget != JumpTargets.end() && CallReturnJumpTarget->second.IsEntryPoint) {