https://gcc.gnu.org/bugzilla/show_bug.cgi?id=71529

--- Comment #1 from Ilya Enkovich <ienkovich at gcc dot gnu.org> ---
Arguments copied for instrumented functions with no body don't have their
context fixed.  It didn't trigger any problems before but does now because we
may inline into thunks.  I'm testing this patch now:

diff --git a/gcc/ipa-chkp.c b/gcc/ipa-chkp.c
index 5f5df64..86c48f1 100644
--- a/gcc/ipa-chkp.c
+++ b/gcc/ipa-chkp.c
@@ -207,7 +207,13 @@ chkp_build_instrumented_fndecl (tree fndecl)
   /* For functions with body versioning will make a copy of arguments.
      For functions with no body we need to do it here.  */
   if (!gimple_has_body_p (fndecl))
-    DECL_ARGUMENTS (new_decl) = copy_list (DECL_ARGUMENTS (fndecl));
+    {
+      tree arg;
+
+      DECL_ARGUMENTS (new_decl) = copy_list (DECL_ARGUMENTS (fndecl));
+      for (arg = DECL_ARGUMENTS (new_decl); arg; arg = DECL_CHAIN (arg))
+       DECL_CONTEXT (arg) = new_decl;
+    }

   /* We are going to modify attributes list and therefore should
      make own copy.  */

Reply via email to