Skip to content

Commit b8f117d

Browse files
committed
py: For optimization level -O3 and higher, remove lineno info from bytecode.
1 parent d3439d0 commit b8f117d

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

py/emitbc.c

+4
Original file line numberDiff line numberDiff line change
@@ -352,6 +352,10 @@ STATIC void emit_bc_adjust_stack_size(emit_t *emit, int delta) {
352352
STATIC void emit_bc_set_source_line(emit_t *emit, int source_line) {
353353
//printf("source: line %d -> %d offset %d -> %d\n", emit->last_source_line, source_line, emit->last_source_line_offset, emit->bytecode_offset);
354354
#if MICROPY_ENABLE_SOURCE_LINE
355+
if (mp_optimise_value >= 3) {
356+
// If we compile with -O3, don't store line numbers.
357+
return;
358+
}
355359
if (source_line > emit->last_source_line) {
356360
uint bytes_to_skip = emit->bytecode_offset - emit->last_source_line_offset;
357361
uint lines_to_skip = source_line - emit->last_source_line;

0 commit comments

Comments
 (0)