GeezerVison is showing github.com — gh-107901: make compiler inline basic blocks with no line number and no fallthrough by iritkatriel · Pull Request #114750 · python/cpython
Conversation
iritkatriel
commented
Jan 30, 2024
•
edited
Loading
Uh oh!
There was an error while loading. Please reload this page.
This pattern shows up in code like this:
def f():
for e in seq:
try:
X = 3
except OSError:
try:
if C3:
X = 4
except OSError:
pass
return 42
We have a block with no line number, and two predecessors, which contains a jump to another block that has no line number. The two-predecessor block is not an exit block so it is not duplicated. As a result, the end block remains with no line number, even if it needs one. This change inlines the first block to each of its predecessors, so that the jump can get a line number.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
|
Two questions.
- Does this fix handle triply nested try-excepts?
- Is it feasible to add a test for this?
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
- Does this fix handle triply nested try-excepts?
It does. The issue is not the nesting, but the multiple paths leading to the end of the except block. It needs to be nested in another except because otherwise the blocks get reordered and this impacts the situation. But with nesting all the blocks are cold, so they remain in this order. More nesting doesn't make a difference.
- Is it feasible to add a test for this?
I'll try to add a unit test.
This PR makes the build pass with the assertion that all eval break checks have line numbers (there are 3 more test failures then, but at least we get through the build).
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
aisk
pushed a commit
to aisk/cpython
that referenced
this pull request
Feb 11, 2024
Uh oh!
There was an error while loading. Please reload this page.
Assignees
No one assigned
Milestone
No milestone
Development
Successfully merging this pull request may close these issues.
Uh oh!
There was an error while loading. Please reload this page.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.