- 
          
- 
                Notifications
    You must be signed in to change notification settings 
- Fork 33.3k
          GH-123044: Give the POP_TOP after a case test a location in the body, not the pattern.
          #130627
        
          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
      
      
            markshannon
  merged 10 commits into
  python:main
from
faster-cpython:location-pop-top-after-case
  
      
      
   
  Mar 10, 2025 
      
    
  
     Merged
                    Changes from all commits
      Commits
    
    
            Show all changes
          
          
            10 commits
          
        
        Select commit
          Hold shift + click to select a range
      
      fd5d1e7
              
                Use case body location for POP_TOP after case test, to give better lo…
              
              
                markshannon 1ce7f7f
              
                Add news
              
              
                markshannon f98fe7a
              
                Include a default case in test
              
              
                markshannon 7084af0
              
                Fix copy and paste
              
              
                markshannon 9332b19
              
                Fix formatting in NEWS file for match cases
              
              
                markshannon 0d82f1b
              
                Use pseudo location to mark instruction as having the location of the…
              
              
                markshannon ab6fa4c
              
                Use -2s for NEXT_LOCATION. Modify basicblock_remove_redundant_nops an…
              
              
                markshannon 1229037
              
                Add a couple of asserts for NEXT_LOCATION
              
              
                markshannon a077433
              
                Replace NEXT_LOCATION with NO_LOCATION if there is no meaningful loca…
              
              
                markshannon 00380b3
              
                Merge branch 'main' into location-pop-top-after-case
              
              
                markshannon File filter
Filter by extension
Conversations
          Failed to load comments.   
        
        
          
      Loading
        
  Jump to
        
          Jump to file
        
      
      
          Failed to load files.   
        
        
          
      Loading
        
  Diff view
Diff view
There are no files selected for viewing
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
        
          
          
            2 changes: 2 additions & 0 deletions
          
          2 
        
  Misc/NEWS.d/next/Core_and_Builtins/2025-02-27-10-47-09.gh-issue-123044.8182Un.rst
  
  
      
      
   
        
      
      
    
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              | Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| Make sure that the location of branch targets in ``match`` cases is in the | ||
| body, not the pattern. | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
      
      Oops, something went wrong.
        
    
  
  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.
  
    
  
    
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.
I think this transformation should be in
propagate_line_numbersin flowgraph.c. Otherwise the last instruction may remain without location, when it could have received a location from an earlier instruction in its block.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.
Wouldn't it be too early in
propagate_line_numbers?If the
NEXT_LOCATIONinstruction is at the end of the block where would it get the location information from?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.
From the next block (fall through or jump). If there is more than one successor, then we have a problem anyway, right, so what do we do?
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.
We should only use
NEXT_LOCATIONif instruction is not the last instruction in the block. I'll add an assert for that.