@@ -159,7 +159,7 @@ struct location {
159
159
#define LOCATION (LNO , END_LNO , COL , END_COL ) \
160
160
((const struct location){(LNO), (END_LNO), (COL), (END_COL)})
161
161
162
- static struct location NO_LOCATION = (LOCATION (-1 , -1 , -1 , -1 ));
162
+ #define NO_LOCATION (LOCATION(-1, -1, -1, -1))
163
163
164
164
struct instr {
165
165
int i_opcode ;
@@ -1283,6 +1283,8 @@ basicblock_addop(basicblock *b, int opcode, int oparg,
1283
1283
IS_BLOCK_PUSH_OPCODE (opcode ));
1284
1284
assert (oparg == 0 || target == NULL );
1285
1285
1286
+ static struct location no_location = NO_LOCATION ;
1287
+
1286
1288
int off = basicblock_next_instr (b );
1287
1289
if (off < 0 ) {
1288
1290
return 0 ;
@@ -1291,7 +1293,7 @@ basicblock_addop(basicblock *b, int opcode, int oparg,
1291
1293
i -> i_opcode = opcode ;
1292
1294
i -> i_oparg = oparg ;
1293
1295
i -> i_target = target ;
1294
- i -> i_loc = * loc ;
1296
+ i -> i_loc = loc ? * loc : no_location ;
1295
1297
1296
1298
return 1 ;
1297
1299
}
@@ -1304,7 +1306,7 @@ compiler_addop(struct compiler *c, int opcode, bool line)
1304
1306
return -1 ;
1305
1307
}
1306
1308
1307
- const struct location * loc = line ? & c -> u -> u_loc : & NO_LOCATION ;
1309
+ const struct location * loc = line ? & c -> u -> u_loc : NULL ;
1308
1310
return basicblock_addop (c -> u -> u_curblock , opcode , 0 , NULL , loc );
1309
1311
}
1310
1312
@@ -1512,7 +1514,7 @@ compiler_addop_i(struct compiler *c, int opcode, Py_ssize_t oparg, bool line)
1512
1514
1513
1515
int oparg_ = Py_SAFE_DOWNCAST (oparg , Py_ssize_t , int );
1514
1516
1515
- const struct location * loc = line ? & c -> u -> u_loc : & NO_LOCATION ;
1517
+ const struct location * loc = line ? & c -> u -> u_loc : NULL ;
1516
1518
return basicblock_addop (c -> u -> u_curblock , opcode , oparg_ , NULL , loc );
1517
1519
}
1518
1520
@@ -1522,7 +1524,7 @@ compiler_addop_j(struct compiler *c, int opcode, basicblock *target, bool line)
1522
1524
if (compiler_use_new_implicit_block_if_needed (c ) < 0 ) {
1523
1525
return -1 ;
1524
1526
}
1525
- const struct location * loc = line ? & c -> u -> u_loc : & NO_LOCATION ;
1527
+ const struct location * loc = line ? & c -> u -> u_loc : NULL ;
1526
1528
assert (target != NULL );
1527
1529
assert (IS_JUMP_OPCODE (opcode ) || IS_BLOCK_PUSH_OPCODE (opcode ));
1528
1530
return basicblock_addop (c -> u -> u_curblock , opcode , 0 , target , loc );
@@ -7386,7 +7388,8 @@ push_cold_blocks_to_end(struct compiler *c, basicblock *entry, int code_flags) {
7386
7388
if (explicit_jump == NULL ) {
7387
7389
return -1 ;
7388
7390
}
7389
- basicblock_addop (explicit_jump , JUMP , 0 , b -> b_next , & NO_LOCATION );
7391
+ static struct location no_location = NO_LOCATION ;
7392
+ basicblock_addop (explicit_jump , JUMP , 0 , b -> b_next , & no_location );
7390
7393
7391
7394
explicit_jump -> b_cold = 1 ;
7392
7395
explicit_jump -> b_next = b -> b_next ;
@@ -8289,9 +8292,10 @@ static int
8289
8292
insert_prefix_instructions (struct compiler * c , basicblock * entryblock ,
8290
8293
int * fixed , int nfreevars , int code_flags )
8291
8294
{
8292
-
8293
8295
assert (c -> u -> u_firstlineno > 0 );
8294
8296
8297
+ static struct location no_location = NO_LOCATION ;
8298
+
8295
8299
/* Add the generator prefix instructions. */
8296
8300
if (code_flags & (CO_GENERATOR | CO_COROUTINE | CO_ASYNC_GENERATOR )) {
8297
8301
struct instr make_gen = {
@@ -8306,7 +8310,7 @@ insert_prefix_instructions(struct compiler *c, basicblock *entryblock,
8306
8310
struct instr pop_top = {
8307
8311
.i_opcode = POP_TOP ,
8308
8312
.i_oparg = 0 ,
8309
- .i_loc = NO_LOCATION ,
8313
+ .i_loc = no_location ,
8310
8314
.i_target = NULL ,
8311
8315
};
8312
8316
if (insert_instruction (entryblock , 1 , & pop_top ) < 0 ) {
@@ -8338,7 +8342,7 @@ insert_prefix_instructions(struct compiler *c, basicblock *entryblock,
8338
8342
.i_opcode = MAKE_CELL ,
8339
8343
// This will get fixed in offset_derefs().
8340
8344
.i_oparg = oldindex ,
8341
- .i_loc = NO_LOCATION ,
8345
+ .i_loc = no_location ,
8342
8346
.i_target = NULL ,
8343
8347
};
8344
8348
if (insert_instruction (entryblock , ncellsused , & make_cell ) < 0 ) {
@@ -8353,7 +8357,7 @@ insert_prefix_instructions(struct compiler *c, basicblock *entryblock,
8353
8357
struct instr copy_frees = {
8354
8358
.i_opcode = COPY_FREE_VARS ,
8355
8359
.i_oparg = nfreevars ,
8356
- .i_loc = NO_LOCATION ,
8360
+ .i_loc = no_location ,
8357
8361
.i_target = NULL ,
8358
8362
};
8359
8363
if (insert_instruction (entryblock , 0 , & copy_frees ) < 0 ) {
@@ -9359,7 +9363,8 @@ propagate_line_numbers(struct assembler *a) {
9359
9363
continue ;
9360
9364
}
9361
9365
9362
- struct location prev_location = NO_LOCATION ;
9366
+ static struct location no_location = NO_LOCATION ;
9367
+ struct location prev_location = no_location ;
9363
9368
for (int i = 0 ; i < b -> b_iused ; i ++ ) {
9364
9369
if (b -> b_instr [i ].i_loc .lineno < 0 ) {
9365
9370
b -> b_instr [i ].i_loc = prev_location ;
0 commit comments