diff options
author | Eric Botcazou <ebotcazou@adacore.com> | 2024-09-30 21:04:18 +0200 |
---|---|---|
committer | Eric Botcazou <ebotcazou@adacore.com> | 2024-09-30 21:07:38 +0200 |
commit | 65073a5b90c00a1c47efae8a67b9c754e2287ee0 (patch) | |
tree | 02e93d3e999482afc0eedc7dff1914d2381d598e /gcc | |
parent | 9c14f9a9c19957d9a45a7df97701bad475c80eea (diff) | |
download | gcc-65073a5b90c00a1c47efae8a67b9c754e2287ee0.zip gcc-65073a5b90c00a1c47efae8a67b9c754e2287ee0.tar.gz gcc-65073a5b90c00a1c47efae8a67b9c754e2287ee0.tar.bz2 |
Fix internal error during inlining after ICF pass
The problem is that the ICF pass identifies two functions, one of which has
a static chain while the other does not. The fix is simply to prevent this
identification from occurring.
gcc/
PR ipa/113996
* ipa-icf.cc (sem_function::get_hash): Hash DECL_STATIC_CHAIN.
(sem_function::equals_wpa): Compare it.
(sem_function::equals_private): Likewise.
gcc/testsuite/
* gnat.dg/lto27.adb: New test.
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/ipa-icf.cc | 11 | ||||
-rw-r--r-- | gcc/testsuite/gnat.dg/lto27.adb | 18 |
2 files changed, 27 insertions, 2 deletions
diff --git a/gcc/ipa-icf.cc b/gcc/ipa-icf.cc index e84922c..6f99415 100644 --- a/gcc/ipa-icf.cc +++ b/gcc/ipa-icf.cc @@ -304,6 +304,7 @@ sem_function::get_hash (void) (TREE_OPTIMIZATION (DECL_FUNCTION_SPECIFIC_OPTIMIZATION (decl)))); hstate.add_flag (DECL_CXX_CONSTRUCTOR_P (decl)); hstate.add_flag (DECL_CXX_DESTRUCTOR_P (decl)); + hstate.add_flag (DECL_STATIC_CHAIN (decl)); set_hash (hstate.end ()); } @@ -655,7 +656,10 @@ sem_function::equals_wpa (sem_item *item, } if (list1 || list2) - return return_false_with_msg ("Mismatched number of parameters"); + return return_false_with_msg ("mismatched number of parameters"); + + if (DECL_STATIC_CHAIN (decl) != DECL_STATIC_CHAIN (item->decl)) + return return_false_with_msg ("static chain mismatch"); if (node->num_references () != item->node->num_references ()) return return_false_with_msg ("different number of references"); @@ -876,7 +880,10 @@ sem_function::equals_private (sem_item *item) return return_false (); } if (arg1 || arg2) - return return_false_with_msg ("Mismatched number of arguments"); + return return_false_with_msg ("mismatched number of arguments"); + + if (DECL_STATIC_CHAIN (decl) != DECL_STATIC_CHAIN (m_compared_func->decl)) + return return_false_with_msg ("static chain mismatch"); if (!dyn_cast <cgraph_node *> (node)->has_gimple_body_p ()) return true; diff --git a/gcc/testsuite/gnat.dg/lto27.adb b/gcc/testsuite/gnat.dg/lto27.adb new file mode 100644 index 0000000..41049f7 --- /dev/null +++ b/gcc/testsuite/gnat.dg/lto27.adb @@ -0,0 +1,18 @@ +-- { dg-do link } +-- { dg-options "-O2 -gnatp -flto" { target lto } } + +with Ada.Containers.Hashed_Maps; +with Ada.Strings.Hash; + +procedure Lto27 is + subtype Node_Name is String (1 .. 4); + + package Node_Maps is new Ada.Containers.Hashed_Maps + (Key_Type => Node_Name, + Element_Type => Integer, + Hash => Ada.Strings.Hash, + Equivalent_Keys => "="); + +begin + null; +end; |