From 773306e4aea43e59d6c02034b72a25096f0b0739 Mon Sep 17 00:00:00 2001 From: Brandt Bucher Date: Tue, 2 Jan 2024 11:11:34 -0800 Subject: [PATCH 1/3] Fix incorrect macros used for trace optimization --- Python/optimizer_analysis.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Python/optimizer_analysis.c b/Python/optimizer_analysis.c index 8b471d70a10d7d..52d0217a7a3645 100644 --- a/Python/optimizer_analysis.c +++ b/Python/optimizer_analysis.c @@ -4,6 +4,7 @@ #include "pycore_opcode_metadata.h" #include "pycore_opcode_utils.h" #include "pycore_pystate.h" // _PyInterpreterState_GET() +#include "pycore_uop_metadata.h" #include "pycore_uops.h" #include "pycore_long.h" #include "cpython/optimizer.h" @@ -35,13 +36,13 @@ remove_unneeded_uops(_PyUOpInstruction *buffer, int buffer_size) break; } else { - if (OPCODE_HAS_ESCAPES(opcode)) { + if (_PyUop_Flags[opcode] & HAS_ESCAPES_FLAG) { maybe_invalid = true; if (last_set_ip >= 0) { buffer[last_set_ip].opcode = _SET_IP; } } - if (OPCODE_HAS_ERROR(opcode) || opcode == _PUSH_FRAME) { + if (_PyUop_Flags[opcode] & HAS_ERROR_FLAG || opcode == _PUSH_FRAME) { if (last_set_ip >= 0) { buffer[last_set_ip].opcode = _SET_IP; } From b53aff63ea80339d995561942ca10ceb0afedb09 Mon Sep 17 00:00:00 2001 From: Brandt Bucher Date: Tue, 2 Jan 2024 11:12:56 -0800 Subject: [PATCH 2/3] Clarify precedence --- Python/optimizer_analysis.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Python/optimizer_analysis.c b/Python/optimizer_analysis.c index 52d0217a7a3645..4eb2d9711f5e56 100644 --- a/Python/optimizer_analysis.c +++ b/Python/optimizer_analysis.c @@ -42,7 +42,7 @@ remove_unneeded_uops(_PyUOpInstruction *buffer, int buffer_size) buffer[last_set_ip].opcode = _SET_IP; } } - if (_PyUop_Flags[opcode] & HAS_ERROR_FLAG || opcode == _PUSH_FRAME) { + if ((_PyUop_Flags[opcode] & HAS_ERROR_FLAG) || opcode == _PUSH_FRAME) { if (last_set_ip >= 0) { buffer[last_set_ip].opcode = _SET_IP; } From f2a0c2cfdedcdfbbaa84180d730cb9bd7da0eff6 Mon Sep 17 00:00:00 2001 From: Brandt Bucher Date: Tue, 2 Jan 2024 11:14:37 -0800 Subject: [PATCH 3/3] blurb add --- .../2024-01-02-11-14-29.gh-issue-113657.CQo9vF.rst | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 Misc/NEWS.d/next/Core and Builtins/2024-01-02-11-14-29.gh-issue-113657.CQo9vF.rst diff --git a/Misc/NEWS.d/next/Core and Builtins/2024-01-02-11-14-29.gh-issue-113657.CQo9vF.rst b/Misc/NEWS.d/next/Core and Builtins/2024-01-02-11-14-29.gh-issue-113657.CQo9vF.rst new file mode 100644 index 00000000000000..b520b5c2529425 --- /dev/null +++ b/Misc/NEWS.d/next/Core and Builtins/2024-01-02-11-14-29.gh-issue-113657.CQo9vF.rst @@ -0,0 +1,2 @@ +Fix an issue that caused important instruction pointer updates to be +optimized out of tier two traces.