> > 
> > I tried to implement a workaround to match lost discriminator in cases
> > this is uniquely deterined, but it is not so easy to do.
> > My plan is to figure out how to upstream it and then drop the lost
> > discriminator workaround from match.
> > 
> > Do you see warnings with -Wauto-profile?
> 
> Adding -Wauto-profile gets it to work. Let me look into this.

I reproduced the problem on leela in cpu2017. Inded -Wauto-profile gets
it to work but also warns about real issue here.

We have

  <bb 25> :
  [simulator/csimplemodule.cc:379:85] _40 = 
std::__cxx11::basic_string<char>::c_str ([simulator/csimplemodule.cc:379:85] 
&D.80680);
  [simulator/csimplemodule.cc:379:85 discrim 13] _41 = 
[simulator/csimplemodule.cc:379:85] 
&this->D.78503.D.78106.D.72008.D.68585.D.67935.D.67879.D.67782;
  [simulator/csimplemodule.cc:379:85 discrim 13] _42 = 
&this->D.78503.D.78106.D.72008.D.68585.D.67935.D.67879.D.67782;
  [simulator/csimplemodule.cc:377:45] _43 = 
this->D.78503.D.78106.D.72008.D.68585.D.67935.D.67879.D.67782._vptr.cObject;
  [simulator/csimplemodule.cc:377:45] _44 = _43 + 40;
  [simulator/csimplemodule.cc:377:45] _45 = [simulator/csimplemodule.cc:377:45] 
*_44;
  [simulator/csimplemodule.cc:379:85] D.89001 = OBJ_TYPE_REF(_45;(const struct 
cObject)_42->5B) (_41);

Notice that both calls

  [simulator/csimplemodule.cc:379:85] _40 = 
std::__cxx11::basic_string<char>::c_str ([simulator/csimplemodule.cc:379:85] 
&D.80680);
  [simulator/csimplemodule.cc:379:85] D.89001 = OBJ_TYPE_REF(_45;(const struct 
cObject)_42->5B) (_41);

have same filename, line and discriminator. 

It seems to me that the assign-discriminator pass is simply broken by
design. I wonder if there any other consumers of discriminators or it is
auto-profile only thing?

The fix for match ICE is

diff --git a/gcc/auto-profile.cc b/gcc/auto-profile.cc
index 219676012e7..a2ad478aea9 100644
--- a/gcc/auto-profile.cc
+++ b/gcc/auto-profile.cc
@@ -1475,19 +1550,21 @@ function_instance::match (cgraph_node *node,
                    {
                      if (inlined_fn
                          && inlined_fn->get_call_location ()
-                                 != UNKNOWN_LOCATION
-                         && warning_at (gimple_location (stmt),
-                                        OPT_Wauto_profile,
-                                        "%q+F contains two calls of the same"
-                                        " relative location +%i,"
-                                        " discrimnator %i,"
-                                        " that leads to lost auto-profile",
-                                        node->decl,
-                                        loc << 16,
-                                        loc & 65535))
+                                 != UNKNOWN_LOCATION)
                        {
-                         inform (inlined_fn->get_call_location (),
-                                 "location of the earlier call");
+                         if (warning_at (gimple_location (stmt),
+                                         OPT_Wauto_profile,
+                                         "%q+F contains two calls of the same"
+                                         " relative location +%i,"
+                                         " discrimnator %i,"
+                                         " that leads to lost auto-profile",
+                                         node->decl,
+                                         loc << 16,
+                                         loc & 65535))
+                           {
+                             inform (inlined_fn->get_call_location (),
+                                     "location of the earlier call");
+                           }
                          inlined_fn = NULL;
                        }
                      if (inlined_fn)

I have some match improvements cumulated in my tree so I will test them
and commit.

Reply via email to