File tree 3 files changed +18
-1
lines changed
Misc/NEWS.d/next/Core and Builtins
3 files changed +18
-1
lines changed Original file line number Diff line number Diff line change @@ -1278,6 +1278,11 @@ def f(x):
1278
1278
while x :
1279
1279
0 if 1 else 0
1280
1280
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
+
1281
1286
@requires_debug_ranges ()
1282
1287
class TestSourcePositions (unittest .TestCase ):
1283
1288
# 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) {
1017
1017
}
1018
1018
/* or if last instruction in BB and next BB has same line number */
1019
1019
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 ) {
1021
1031
continue ;
1022
1032
}
1023
1033
}
You can’t perform that action at this time.
0 commit comments