Hello, I've been playing with a cross-compiler built with ASAN for target=xtensa-linux-uclibc and I was consistently getting a report for out-of-bound heap access inside IRA. I was able to get the same report for target=microblazeel-linux-gnu so it does not look entirely target-specific. I also tried earlier gcc releases and the issue can be reproduced as early as with gcc-7.1.0 (I had build issues with earlier versions). AFAICS inside the functions update_costs_from_allocno and assign_hard_reg the macro ALLOCNO_COLOR_DATA may be applied to objects of type 'struct ira_allocno' whose add_data field wasn't changed in the function color_pass to point to a memory area sized for struct allocno_color_data. The following change helps exhibit this issue without ASAN: diff --git a/gcc/ira-color.cc b/gcc/ira-color.cc index 4a1a325e8e31..8feacf91ff81 100644 --- a/gcc/ira-color.cc +++ b/gcc/ira-color.cc @@ -167,7 +167,7 @@ typedef struct allocno_color_data *allocno_color_data_t; static allocno_color_data_t allocno_color_data; /* Macro to access the data concerning coloring. */ -#define ALLOCNO_COLOR_DATA(a) ((allocno_color_data_t) ALLOCNO_ADD_DATA (a)) +#define ALLOCNO_COLOR_DATA(a) (ira_assert (a->data_is_color), (allocno_color_data_t) ALLOCNO_ADD_DATA (a)) /* Used for finding allocno colorability to exclude repeated allocno processing and for updating preferencing to exclude repeated @@ -3621,6 +3621,7 @@ color_pass (ira_loop_tree_node_t loop_tree_node) { a = ira_allocnos[j]; ALLOCNO_ADD_DATA (a) = allocno_color_data + n; + a->data_is_color = true; n++; } init_allocno_threads (); @@ -3749,6 +3750,7 @@ color_pass (ira_loop_tree_node_t loop_tree_node) { a = ira_allocnos[j]; ALLOCNO_ADD_DATA (a) = NULL; + a->data_is_color = false; } } diff --git a/gcc/ira-int.h b/gcc/ira-int.h index f42a314fa7f4..a5d8d70f368c 100644 --- a/gcc/ira-int.h +++ b/gcc/ira-int.h @@ -416,6 +416,7 @@ struct ira_allocno /* Different additional data. It is used to decrease size of allocno data footprint. */ void *add_data; + bool data_is_color; }; The attached source triggers the above assertion in a compiler built from revision gcc-13-3563-gf36bba013361 for target=microblazeel-linux-gnu: $ gcc/cc1 -O2 _gcov.i ../../../../gcc/libgcc/libgcov-driver.c: In function ‘gcov_do_dump.constprop’: ../../../../gcc/libgcc/libgcov-driver.c:704:1: internal compiler error: in assign_hard_reg, at ira-color.cc:2006 -- Thanks. -- Max