re PR debug/66691 (ICE on valid code at -O3 with -g enabled in simplify_subreg, at...
[gcc.git] / gcc / ipa-chkp.c
index c7102915cbf36601f81f1d8e378cf1b60db9f8c5..acb89bed65f7a3467613bf75ff22fc56d50f7321 100644 (file)
@@ -21,16 +21,9 @@ along with GCC; see the file COPYING3.  If not see
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
-#include "hash-set.h"
-#include "machmode.h"
-#include "vec.h"
-#include "double-int.h"
-#include "input.h"
 #include "alias.h"
 #include "symtab.h"
 #include "options.h"
-#include "wide-int.h"
-#include "inchash.h"
 #include "tree.h"
 #include "fold-const.h"
 #include "stor-layout.h"
@@ -41,12 +34,11 @@ along with GCC; see the file COPYING3.  If not see
 #include "tm.h"
 #include "hard-reg-set.h"
 #include "function.h"
-#include "is-a.h"
+#include "calls.h"
 #include "tree-ssa-alias.h"
 #include "predict.h"
 #include "basic-block.h"
 #include "gimple.h"
-#include "ipa-ref.h"
 #include "lto-streamer.h"
 #include "cgraph.h"
 #include "tree-chkp.h"
@@ -571,25 +563,10 @@ chkp_maybe_create_clone (tree fndecl)
 
       if (gimple_has_body_p (fndecl))
        {
-         /* If function will not be instrumented, then it's instrumented
-            version is a thunk for the original.  */
-         if (!chkp_instrumentable_p (fndecl))
-           {
-             clone->remove_callees ();
-             clone->remove_all_references ();
-             clone->thunk.thunk_p = true;
-             clone->thunk.add_pointer_bounds_args = true;
-             clone->create_edge (node, NULL, 0, CGRAPH_FREQ_BASE);
-             /* Thunk shouldn't be a cdtor.  */
-             DECL_STATIC_CONSTRUCTOR (clone->decl) = 0;
-             DECL_STATIC_DESTRUCTOR (clone->decl) = 0;
-           }
-         else
-           {
-             tree_function_versioning (fndecl, new_decl, NULL, false,
-                                       NULL, false, NULL, NULL);
-             clone->lowered = true;
-           }
+         gcc_assert (chkp_instrumentable_p (fndecl));
+         tree_function_versioning (fndecl, new_decl, NULL, false,
+                                   NULL, false, NULL, NULL);
+         clone->lowered = true;
        }
 
       /* New params are inserted after versioning because it
@@ -616,12 +593,7 @@ chkp_maybe_create_clone (tree fndecl)
 
       /* Clone all aliases.  */
       for (i = 0; node->iterate_direct_aliases (i, ref); i++)
-       {
-         struct cgraph_node *alias = dyn_cast <cgraph_node *> (ref->referring);
-         struct cgraph_node *chkp_alias
-           = chkp_maybe_create_clone (alias->decl);
-         chkp_alias->create_reference (clone, IPA_REF_ALIAS, NULL);
-       }
+       chkp_maybe_create_clone (ref->referring->decl);
 
       /* Clone all thunks.  */
       for (e = node->callers; e; e = e->next_caller)
@@ -645,7 +617,10 @@ chkp_maybe_create_clone (tree fndecl)
 
          ref = node->ref_list.first_reference ();
          if (ref)
-           chkp_maybe_create_clone (ref->referred->decl);
+           {
+             target = chkp_maybe_create_clone (ref->referred->decl);
+             clone->create_reference (target, IPA_REF_ALIAS);
+           }
 
          if (node->alias_target)
            {