]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
tree-optimization/114274 - avoid stray BLOCK refrence from CSWTCH vars
authorRichard Biener <rguenther@suse.de>
Fri, 6 Feb 2026 08:26:37 +0000 (09:26 +0100)
committerRichard Biener <rguenther@suse.de>
Fri, 6 Feb 2026 10:50:26 +0000 (11:50 +0100)
The following removes the location from CSWTCH variables which are
DECL_IGNORED_P and have no DECL_CONTEXT.  The location is currently
taken from the gswitch statement and thus includes a BLOCK reference
which can eventually be elided and GCd, causing later ICEs when
ICF decides to merge the variable with some other.

PR tree-optimization/114274
* tree-switch-conversion.cc (switch_conversion::build_one_array):
Use UNKNOWN_LOCATION for the CSWTCH decl.

gcc/tree-switch-conversion.cc

index cc2b0a5ec30c40665a63384202eec69b35d5f6e8..5027ab559c0b8ddff6a825e82da0b804a4f0ad74 100644 (file)
@@ -971,7 +971,6 @@ switch_conversion::build_one_array (int num, tree arr_index_type,
   tree name;
   gimple *load;
   gimple_stmt_iterator gsi = gsi_for_stmt (m_switch);
-  location_t loc = gimple_location (m_switch);
 
   gcc_assert (m_default_values[num]);
 
@@ -1030,7 +1029,7 @@ switch_conversion::build_one_array (int num, tree arr_index_type,
       TREE_CONSTANT (ctor) = true;
       TREE_STATIC (ctor) = true;
 
-      decl = build_decl (loc, VAR_DECL, NULL_TREE, array_type);
+      decl = build_decl (UNKNOWN_LOCATION, VAR_DECL, NULL_TREE, array_type);
       TREE_STATIC (decl) = 1;
       DECL_INITIAL (decl) = ctor;