{"id":814834,"url":"http://patchwork.ozlabs.org/api/1.2/patches/814834/?format=json","web_url":"http://patchwork.ozlabs.org/project/gcc/patch/3690602f9779a8e66f5744ff22eb2bbd@ispras.ru/","project":{"id":17,"url":"http://patchwork.ozlabs.org/api/1.2/projects/17/?format=json","name":"GNU Compiler Collection","link_name":"gcc","list_id":"gcc-patches.gcc.gnu.org","list_email":"gcc-patches@gcc.gnu.org","web_url":null,"scm_url":null,"webscm_url":null,"list_archive_url":"","list_archive_url_format":"","commit_url_format":""},"msgid":"<3690602f9779a8e66f5744ff22eb2bbd@ispras.ru>","list_archive_url":null,"date":"2017-09-18T09:08:10","name":"[RFC] ipa: fix dumping with deleted multiversioning nodes","commit_ref":null,"pull_url":null,"state":"new","archived":false,"hash":"04c2537e42d95955151d45c871894055aea4216e","submitter":{"id":70324,"url":"http://patchwork.ozlabs.org/api/1.2/people/70324/?format=json","name":"Evgeny Kudryashov","email":"kudryashov@ispras.ru"},"delegate":null,"mbox":"http://patchwork.ozlabs.org/project/gcc/patch/3690602f9779a8e66f5744ff22eb2bbd@ispras.ru/mbox/","series":[{"id":3594,"url":"http://patchwork.ozlabs.org/api/1.2/series/3594/?format=json","web_url":"http://patchwork.ozlabs.org/project/gcc/list/?series=3594","date":"2017-09-18T09:08:10","name":"[RFC] ipa: fix dumping with deleted multiversioning nodes","version":1,"mbox":"http://patchwork.ozlabs.org/series/3594/mbox/"}],"comments":"http://patchwork.ozlabs.org/api/patches/814834/comments/","check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/814834/checks/","tags":{},"related":[],"headers":{"Return-Path":"<gcc-patches-return-462360-incoming=patchwork.ozlabs.org@gcc.gnu.org>","X-Original-To":"incoming@patchwork.ozlabs.org","Delivered-To":["patchwork-incoming@bilbo.ozlabs.org","mailing list gcc-patches@gcc.gnu.org"],"Authentication-Results":["ozlabs.org;\n\tspf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org\n\t(client-ip=209.132.180.131; helo=sourceware.org;\n\tenvelope-from=gcc-patches-return-462360-incoming=patchwork.ozlabs.org@gcc.gnu.org;\n\treceiver=<UNKNOWN>)","ozlabs.org; dkim=pass (1024-bit key;\n\tunprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org\n\theader.b=\"Jy3YI4hg\"; dkim-atps=neutral","sourceware.org; auth=none"],"Received":["from sourceware.org (server1.sourceware.org [209.132.180.131])\n\t(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256\n\tbits)) (No client certificate requested)\n\tby ozlabs.org (Postfix) with ESMTPS id 3xwgCd5Dl1z9s7c\n\tfor <incoming@patchwork.ozlabs.org>;\n\tMon, 18 Sep 2017 19:08:27 +1000 (AEST)","(qmail 68679 invoked by alias); 18 Sep 2017 09:08:18 -0000","(qmail 66672 invoked by uid 89); 18 Sep 2017 09:08:16 -0000","from mail.ispras.ru (HELO mail.ispras.ru) (83.149.199.45) by\n\tsourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP;\n\tMon, 18 Sep 2017 09:08:13 +0000","from mail.ispras.ru (localhost [127.0.0.1])\tby mail.ispras.ru\n\t(Postfix) with ESMTPSA id 839A454006C;\n\tMon, 18 Sep 2017 12:08:10 +0300 (MSK)"],"DomainKey-Signature":"a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id\n\t:list-unsubscribe:list-archive:list-post:list-help:sender\n\t:mime-version:content-type:date:from:to:cc:subject:message-id;\n\tq=dns; s=default; b=nt42Qs2LuxqTk7eN3lmIpJK/O+00zWx8Vd6ZLr2rvAG\n\tiSaRbLPrSOcoS9xoAcKCk5cbOphfWdsQEZFMBn1qioaI9zEsbUjiqf0zEznlxlSq\n\tjMqtMMtQJcp/2S6t26d7Shdqie5DfdZGCv6qD1tsByhCFjSo82bqecP0Uil0THTk\n\t=","DKIM-Signature":"v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id\n\t:list-unsubscribe:list-archive:list-post:list-help:sender\n\t:mime-version:content-type:date:from:to:cc:subject:message-id;\n\ts=default; bh=Sj32UlGATMeWgxgp/wOBug2a+qo=; b=Jy3YI4hgHiT/SvJES\n\tLXWXNBiZbaBt05RyB+cAtFlpQzPWdoXrKH4dfBtd+CJbtsoVNR7ecf/JmQKeV6Hy\n\tIXmjRt7vwDuAoxgxauv8wwldMnhNMgsF4rPxvw/2EM8FBU7RaYByw9OLxBMe1GcG\n\tn6VZk9tHEZeiXIt2LITGwb5uoc=","Mailing-List":"contact gcc-patches-help@gcc.gnu.org; run by ezmlm","Precedence":"bulk","List-Id":"<gcc-patches.gcc.gnu.org>","List-Unsubscribe":"<mailto:gcc-patches-unsubscribe-incoming=patchwork.ozlabs.org@gcc.gnu.org>","List-Archive":"<http://gcc.gnu.org/ml/gcc-patches/>","List-Post":"<mailto:gcc-patches@gcc.gnu.org>","List-Help":"<mailto:gcc-patches-help@gcc.gnu.org>","Sender":"gcc-patches-owner@gcc.gnu.org","X-Virus-Found":"No","X-Spam-SWARE-Status":"No, score=-24.6 required=5.0 tests=AWL, BAYES_00,\n\tGIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3,\n\tRP_MATCHES_RCVD,\n\tSPF_PASS autolearn=ham version=3.3.2 spammy=2065, dispatcher","X-HELO":"mail.ispras.ru","MIME-Version":"1.0","Content-Type":"multipart/mixed; boundary=\"=_fd14918a31aee7b5407d9152e9a112d9\"","Date":"Mon, 18 Sep 2017 12:08:10 +0300","From":"Evgeny Kudryashov <kudryashov@ispras.ru>","To":"gcc-patches@gcc.gnu.org","Cc":"=?utf-8?q?Martin_Li=C5=A1ka?= <mliska@suse.cz>","Subject":"[RFC][PATCH] ipa: fix dumping with deleted multiversioning nodes","Message-ID":"<3690602f9779a8e66f5744ff22eb2bbd@ispras.ru>","X-Sender":"kudryashov@ispras.ru","User-Agent":"Roundcube Webmail/1.1.2","X-IsSubscribed":"yes"},"content":"Hello,\n\nThe code below causes an internal compiler error in cc1plus (trunk on \nx86-64) if it is compiled with -fdump-ipa-cgraph.\n\nint foo () __attribute__ ((target (\"default\")));\nint foo () __attribute__ ((target (\"sse4.2\")));\n\n__attribute__ ((target (\"sse4.2\")))\nint foo ()\n{\n   return 1;\n}\n\nThe error occurs in cgraph_node::dump (gcc/cgraph.c:2065), particularly, \nin the following fragment:\n\ncgraph_function_version_info *vi = function_version ();\nif (vi != NULL)\n   {\n     fprintf (f, \"  Version info: \");\n     if (vi->prev != NULL)\n       {\n         fprintf (f, \"prev: \");\n         fprintf (f, \"%s \", vi->prev->this_node->dump_asm_name ());\n       }\n     if (vi->next != NULL)\n       {\n         fprintf (f, \"next: \");\n         fprintf (f, \"%s \", vi->next->this_node->dump_asm_name ());\n       }\n     if (vi->dispatcher_resolver != NULL_TREE)\n       fprintf (f, \"dispatcher: %s\",\n                lang_hooks.decl_printable_name (vi->dispatcher_resolver, \n2));\n\n     fprintf (f, \"\\n\");\n   }\n\n\nThe expression \"vi->{prev,next}->this_node\" can be null if it is a \nversion of an unused symbol that was removed.\n\nIs it intentional that removing a cgraph node does not also remove \nversions?\n\nAs a solution I suggest to delete the version of the node too during \nnode removal.\n\nRegards,\nEvgeny.\n\n     * cgraph.c (delete_function_version): New, broken out from...\n     (cgraph_node::delete_function_version): ...here.  Rename to\n     cgraph_node::delete_function_version_by_decl.  Update all uses.\n     (cgraph_node::remove): Call delete_function_version.","diff":"diff --git a/gcc/cgraph.c b/gcc/cgraph.c\nindex 8bffdec..3d0cefb 100644\n--- a/gcc/cgraph.c\n+++ b/gcc/cgraph.c\n@@ -190,30 +190,34 @@ cgraph_node::insert_new_function_version (void)\n   return version_info_node;\n }\n \n-/* Remove the cgraph_function_version_info and cgraph_node for DECL.  This\n-   DECL is a duplicate declaration.  */\n-void\n-cgraph_node::delete_function_version (tree decl)\n+/* Remove the cgraph_function_version_info node given by DECL_V.  */\n+static void\n+delete_function_version (cgraph_function_version_info *decl_v)\n {\n-  cgraph_node *decl_node = cgraph_node::get (decl);\n-  cgraph_function_version_info *decl_v = NULL;\n-\n-  if (decl_node == NULL)\n-    return;\n-\n-  decl_v = decl_node->function_version ();\n-\n   if (decl_v == NULL)\n     return;\n \n   if (decl_v->prev != NULL)\n-   decl_v->prev->next = decl_v->next;\n+    decl_v->prev->next = decl_v->next;\n \n   if (decl_v->next != NULL)\n     decl_v->next->prev = decl_v->prev;\n \n   if (cgraph_fnver_htab != NULL)\n     cgraph_fnver_htab->remove_elt (decl_v);\n+}\n+\n+/* Remove the cgraph_function_version_info and cgraph_node for DECL.  This\n+   DECL is a duplicate declaration.  */\n+void\n+cgraph_node::delete_function_version_by_decl (tree decl)\n+{\n+  cgraph_node *decl_node = cgraph_node::get (decl);\n+\n+  if (decl_node == NULL)\n+    return;\n+\n+  delete_function_version (decl_node->function_version ());\n \n   decl_node->remove ();\n }\n@@ -1844,6 +1848,7 @@ cgraph_node::remove (void)\n   remove_callers ();\n   remove_callees ();\n   ipa_transforms_to_apply.release ();\n+  delete_function_version (function_version ());\n \n   /* Incremental inlining access removed nodes stored in the postorder list.\n      */\ndiff --git a/gcc/cgraph.h b/gcc/cgraph.h\nindex c668b37..1303db0 100644\n--- a/gcc/cgraph.h\n+++ b/gcc/cgraph.h\n@@ -1272,7 +1272,7 @@ public:\n \n   /* Remove the cgraph_function_version_info and cgraph_node for DECL.  This\n      DECL is a duplicate declaration.  */\n-  static void delete_function_version (tree decl);\n+  static void delete_function_version_by_decl (tree decl);\n \n   /* Add the function FNDECL to the call graph.\n      Unlike finalize_function, this function is intended to be used\ndiff --git a/gcc/cp/decl.c b/gcc/cp/decl.c\nindex 858747e..50fa1ba 100644\n--- a/gcc/cp/decl.c\n+++ b/gcc/cp/decl.c\n@@ -2566,7 +2566,7 @@ next_arg:;\n       DECL_FUNCTION_VERSIONED (newdecl) = 1;\n       /* newdecl will be purged after copying to olddecl and is no longer\n          a version.  */\n-      cgraph_node::delete_function_version (newdecl);\n+      cgraph_node::delete_function_version_by_decl (newdecl);\n     }\n \n   if (TREE_CODE (newdecl) == FUNCTION_DECL)\n","prefixes":["RFC"]}