From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-lj1-x231.google.com (mail-lj1-x231.google.com [IPv6:2a00:1450:4864:20::231]) by sourceware.org (Postfix) with ESMTPS id 2BC0F3849AD3 for ; Thu, 16 May 2024 09:26:30 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 2BC0F3849AD3 Authentication-Results: sourceware.org; dmarc=pass (p=quarantine dis=none) header.from=adacore.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=adacore.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 2BC0F3849AD3 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::231 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1715851599; cv=none; b=AI05L9gxjrpVGlcahlJCFvGW8V7vagfvKNYFMGY6+v34gNEJ1pGwcJdgPD5K8rVQEZDh4uvbHjCJHwo+1n9TNnSXz/5cHdIgyboldHPtw05+eWC93tEpnkcxoBf/ZZOldLE7i07OnMYd2fvee1pww8ftr7AEhGJeSRJnmXAXNTw= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1715851599; c=relaxed/simple; bh=mjzQi3OIGbwguG/dODVYioz77KLt7WuQM8xmsebENek=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=gL652a85XqQnxs5BdJojhTVaDXXnfZYfaOafRLK+tZ07CKpmXWq/GtXEJkwSvBIrSKegLcdV0/FAlmkdFHKfVUtHJjgBRE1uk65bO/wjsxfOATMub7lAILJGQGhHVFZFYf/Hrh/pqBMWovok1EHtctZfvpyDU0GTWQhyQkaGzCk= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-lj1-x231.google.com with SMTP id 38308e7fff4ca-2dfb4ea2bbfso5833781fa.2 for ; Thu, 16 May 2024 02:26:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; t=1715851589; x=1716456389; darn=gcc.gnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=t1u0HCWn4haLV7BR/CknKs4j/5whze3TUEy2F5t0+Vw=; b=W2lYwH9Hdk4cJ/oZkwZdIWn8TXhMx7h/YiMZrCJ6ODmm/MhkedbYKgKk06cz2O0TK2 DSkzOPrayZjpJBtGfUy7t9pjBg03Kig7QXgu/EHm9JtzgbZ8JwNqpz0YYh7GpNhYh5a/ zBYd8A6GzILXx4fCNu1DHAuIKNUw5BtEX5IzfARzKGlJdxIbOXrTl7qYR/YXVNrHCq7a gDbL7i1q0ekyLbq1vg7vXjl+p+zlt0Sx4AsrDr+lUoWYGSIOYEURKl4FIT7f3qbxx2jW Fpe/eTVP8Y5VrktKPvNJK5Rb7nORRBKmAWrjULV8S7A59ddCGXYKmy/SRhdLDHfzYvhd 1Pow== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1715851589; x=1716456389; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=t1u0HCWn4haLV7BR/CknKs4j/5whze3TUEy2F5t0+Vw=; b=NncHVxqY9VkU27+A2D6A8rbhh+jtXLrwbtv3KRTrxMoJ469mJmQ2EY0AKBDwt8kF10 xWwotaCLrpPDf4sAVgTAqTW+FZ4UPNJYMuxkvtBIPEMr6KZBLOpI+9YVh7kx1NwcLPGs EawvSWAvFj1GtEivcacUflytbq5nf1IcwkYWaNiCkTFhltb6U4jC1OBmXNEjmOrO1S5Q plVEuBk30Ir7g15ww9WLf7IHrmDBdzOEPQOIrd8Id+5IKtDWOF3CbAFY8vxr7XR4Q9v7 skeWYD7wokA50g2/41W513rgij8gKo89h0JA1B9HNV70iBmEMabFWv7dACSxO643T0Ht cjTA== X-Gm-Message-State: AOJu0YzcBYLYp2u41YnCY1ZJ51BLFmk29ZeU9sbOEYI+Y1vfm36L/jmI JT6Qklb3Ym0wIXOHUGCAQrVP3OeStLOLSJvSykcra4N3/gurjKCzYd+gitArCZabTz7Yhy5hTPE = X-Google-Smtp-Source: AGHT+IHpCiKrfSZ699IkRbGLndLADF5SDNJ1BxdJRaGOvGanaWctL8h3YBC8soDrwAKEb/C0kek3rg== X-Received: by 2002:a2e:8ec4:0:b0:2dd:97e:3481 with SMTP id 38308e7fff4ca-2e5205f6f3amr113695371fa.51.1715851588703; Thu, 16 May 2024 02:26:28 -0700 (PDT) Received: from poulhies-Precision-5550.telnowedge.local (lmontsouris-659-1-24-67.w81-250.abo.wanadoo.fr. [81.250.175.67]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-41fd10cf8besm135802635e9.1.2024.05.16.02.26.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 16 May 2024 02:26:28 -0700 (PDT) From: =?UTF-8?q?Marc=20Poulhi=C3=A8s?= To: gcc-patches@gcc.gnu.org Cc: Piotr Trojanek Subject: [COMMITTED 26/35] ada: Ignore ghost nodes in call graph information for dispatching calls Date: Thu, 16 May 2024 11:25:55 +0200 Message-ID: <20240516092606.41242-26-poulhies@adacore.com> X-Mailer: git-send-email 2.43.2 In-Reply-To: <20240516092606.41242-1-poulhies@adacore.com> References: <20240516092606.41242-1-poulhies@adacore.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-13.7 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: From: Piotr Trojanek When emitting call graph information, we already skipped calls to ignored ghost entities, but this code was causing crashes (in production builds) and assertion failures (in development builds), because the ignored ghost entities are not fully decorated, e.g. when they come from instances of generic units with default subprograms. With this patch we skip call graph information for ignored ghost entities when they are registered, both as explicit calls and as tagged types that will come with internally generated dispatching subprograms. gcc/ada/ * exp_cg.adb (Generate_CG_Output): Remove code for ignored ghost entities that applied to subprogram calls. (Register_CG_Node): Skip ignored ghost entities, both calls and tagged types, when they are registered. Tested on x86_64-pc-linux-gnu, committed on master. --- gcc/ada/exp_cg.adb | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/gcc/ada/exp_cg.adb b/gcc/ada/exp_cg.adb index addf1cae32a..91a6d40a6fa 100644 --- a/gcc/ada/exp_cg.adb +++ b/gcc/ada/exp_cg.adb @@ -125,14 +125,7 @@ package body Exp_CG is for J in Call_Graph_Nodes.First .. Call_Graph_Nodes.Last loop N := Call_Graph_Nodes.Table (J); - -- No action needed for subprogram calls removed by the expander - -- (for example, calls to ignored ghost entities). - - if Nkind (N) = N_Null_Statement then - pragma Assert (Nkind (Original_Node (N)) in N_Subprogram_Call); - null; - - elsif Nkind (N) in N_Subprogram_Call then + if Nkind (N) in N_Subprogram_Call then Write_Call_Info (N); else pragma Assert (Nkind (N) = N_Defining_Identifier); @@ -358,7 +351,13 @@ package body Exp_CG is procedure Register_CG_Node (N : Node_Id) is begin - if Nkind (N) in N_Subprogram_Call then + -- Skip ignored ghost calls that will be removed by the expander + + if Is_Ignored_Ghost_Node (N) then + null; + + elsif Nkind (N) in N_Subprogram_Call then + if Current_Scope = Main_Unit_Entity or else Entity_Is_In_Main_Unit (Current_Scope) then -- 2.43.2