8000 gh-93678: add _testinternalcapi.optimize_cfg() and test utils for compiler optimization unit tests by iritkatriel · Pull Request #96007 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

gh-93678: add _testinternalcapi.optimize_cfg() and test utils for compiler optimization unit tests #96007

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 11 commits into from
Aug 24, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Revert "long long --> uintptr_t, and added a comment clarifying that …
…the pointer is used as a unique ID"

This reverts commit 2818fd3.
  • Loading branch information
iritkatriel committed Aug 23, 2022
commit 4339460e5d6e7ef75ea0ea499a7da5a763439b12
5 changes: 2 additions & 3 deletions Python/compile.c
Original file line number Diff line number Diff line change
Expand Up @@ -9704,10 +9704,9 @@ cfg_to_instructions(cfg_builder *g)
for (int i = 0; i < b->b_iused; i++) {
struct instr *instr = &b->b_instr[i];
struct location loc = instr->i_loc;
uintptr_t arg = instr->i_oparg;
long long arg = instr->i_oparg;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why 64bit, not 32bit?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Two lines down, instr->i_target is a pointer, and I'm passing its address back to python as the label of the block. (It get normalised by the test harness).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If it is an address, it should be uintptr_t, and add a comment that it just an ID.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With uintptr_t the test fail on the Windows x86 buildbot.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I changed to (small) calculated block IDs, so we don't have the issue anymore.

if (HAS_TARGET(instr->i_opcode)) {
/* Use the address of the block as its unique ID (for the label) */
arg = (uintptr_t)instr->i_target;
arg = (long long)instr->i_target;
}

PyObject *inst_tuple = Py_BuildValue(
Expand Down
0