File tree Expand file tree Collapse file tree 3 files changed +18
-1
lines changed
Misc/NEWS.d/next/Core and Builtins Expand file tree Collapse file tree 3 files changed +18
-1
lines changed Original file line number Diff line number Diff line change @@ -1278,6 +1278,11 @@ def f(x):
12781278 while x :
12791279 0 if 1 else 0
12801280
1281+ def test_remove_redundant_nop_edge_case (self ):
1282+ # See gh-109889
1283+ def f ():
1284+ a if (1 if b else c ) else d
1285+
12811286@requires_debug_ranges ()
12821287class TestSourcePositions (unittest .TestCase ):
12831288 # Ensure that compiled code snippets have correct line and column numbers
Original file line number Diff line number Diff line change 1+ Fix the compiler's redundant NOP detection algorithm to skip over NOPs with
2+ no line number when looking for the next instruction's lineno.
Original file line number Diff line number Diff line change @@ -1017,7 +1017,17 @@ remove_redundant_nops(basicblock *bb) {
10171017 }
10181018 /* or if last instruction in BB and next BB has same line number */
10191019 if (next ) {
1020- if (lineno == next -> b_instr [0 ].i_loc .lineno ) {
1020+ location next_loc = NO_LOCATION ;
1021+ for (int next_i = 0 ; next_i < next -> b_iused ; next_i ++ ) {
1022+ cfg_instr * instr = & next -> b_instr [next_i ];
1023+ if (instr -> i_opcode == NOP && instr -> i_loc .lineno == NO_LOCATION .lineno ) {
1024+ /* Skip over NOPs without location, they will be removed */
1025+ continue ;
1026+ }
1027+ next_loc = instr -> i_loc ;
1028+ break ;
1029+ }
1030+ if (lineno == next_loc .lineno ) {
10211031 continue ;
10221032 }
10231033 }
You can’t perform that action at this time.
0 commit comments