With the code from PR 122564, the destinations of branches into the blocks of certain cases are mapping to the pattern as well, making them look like they go out of scope:
v=1matchv:
case1:
x=1case2:
x=2case3:
x=3x+=2
This code yields (branches listing below extracted from co_branches()):
Do we craete issues for unmerged PR? I thought issues are supposed to be about code that's already merged. For unmerged PRs, shouldn't we just discuss it in the PR itself?
I don't think there is any harm in creating a new issue. We often break down larger pieces of work into smaller issues.
We should make it clear that this is part of #122564, though.
I think we should tackle these issues of locations within match statement related issues as follows:
Generally, we want to be giving POP_TOPs and other cleanup code NO_LOCATION in the front-end.
When assigning locations to instructions with no locations we should prefer locations within the same basic block to those locations outside it.
We also want the compiler to prefer locations following the basic block, to those preceding it, which assigning locations to basic blocks with no locations.
We also want the compiler to prefer locations following the basic block, to those preceding it, which assigning locations to basic blocks with no locations.
I think it's doing the opposite now. Will need to experiment with this.
Given that we cannot reliably expected NOT_TAKEN to be followed by an instruction with a meaningful location (see #123050) we'll need a different approach to this.
We still need correct locations for actual expressions, but we should be fine with the compiler filling in locations as it does now for artificial instructions.
Activity
gaogaotiantian commented on Aug 16, 2024
Do we craete issues for unmerged PR? I thought issues are supposed to be about code that's already merged. For unmerged PRs, shouldn't we just discuss it in the PR itself?
markshannon commented on Aug 16, 2024
I don't think there is any harm in creating a new issue. We often break down larger pieces of work into smaller issues.
We should make it clear that this is part of #122564, though.
markshannon commented on Aug 16, 2024
I think we should tackle these issues of locations within match statement related issues as follows:
@iritkatriel does that make sense to you?
iritkatriel commented on Aug 16, 2024
I think it's doing the opposite now. Will need to experiment with this.
markshannon commented on Aug 20, 2024
Given that we cannot reliably expected NOT_TAKEN to be followed by an instruction with a meaningful location (see #123050) we'll need a different approach to this.
We still need correct locations for actual expressions, but we should be fine with the compiler filling in locations as it does now for artificial instructions.
GH-123044: Give the `POP_TOP` after a case test a location in the bod…