From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-lf1-x12a.google.com (mail-lf1-x12a.google.com [IPv6:2a00:1450:4864:20::12a]) by sourceware.org (Postfix) with ESMTPS id 4A1323882664 for ; Fri, 14 Jun 2024 07:36:57 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 4A1323882664 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 4A1323882664 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::12a ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1718350619; cv=none; b=Van9FOye4TqTRPpH9t55GzT/amuaYX7V2TZUXt9vak2hnHiw2wU8vDKhOXymC9XlBFgciM5XLuU/zWeBRB/ZhoqcdAgaKvxJS23loujkDIas2Y+A179rIgHQCnG4aLbskU5RlIFlIkxfnFYi48s3c+cakRiz+beD9HXMAHQ2xt0= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1718350619; c=relaxed/simple; bh=ofVuKmYAqkmPv/0LFUMocgHE6DWwVqkJ5donU1jSSSc=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=LXO9QC7TILNntFjiAuFViqd2ClAt35Qf8fHBObC5yuJfceFYG980gsM7mbNwCuIIQ5HYlFI8M6cXYhBeCOBEdkCPYaiinViGLnllGEGoiT3eW9Y5pK9xOUx2pKhdcC66recVEQOMO+iblpVhAbhMTL/M64SOdmu2HHn/QWDQGkc= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-lf1-x12a.google.com with SMTP id 2adb3069b0e04-52bd48cf36bso2307984e87.3 for ; Fri, 14 Jun 2024 00:36:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; t=1718350616; x=1718955416; 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=YGqi1E0m4WC9dslJz81B7ZgUliyPijFhsHmKXEW+tPU=; b=AuEXVzoMhZupNJ1Gf2+LaY7OWOBQ+hVsjXPUpf6CogVi4tWpvQirtpE1VsqLjHMVL5 ufg1s2rBkjKxSJP8UCMfw7xrVS1l9dBKcO0cjrWyOK2WPZRVR/lretFghcJK3Nkx3T4t I5B8FGUqKs25gF6q/b1A4g11K7ys2BUMKfuyuOtK8U6zO3tBrUYCf7DDNokbydNKJeUX G5wEbzXmaCqLMqkhiPmsIIr7m7cD/Xp5P2pBbMk7M400lEOZOWceBxgMLEsx8cWhhLK/ QwkiqAOiqNYxrB9aUd3ZJDpYFVo/tb95HckSCJw5yGcakdh1JFX8uagx1+PGq3ae4KR2 6koQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718350616; x=1718955416; 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=YGqi1E0m4WC9dslJz81B7ZgUliyPijFhsHmKXEW+tPU=; b=wEE15gOoJrdVwnc+8zJKja3NKGZkJ83iiVJEbo/wkawxycOLHQqJBgVsAF65Qnzz2D wwFG+oAK3HQgD8n0zu9hRfBrKXVkikQtiCnH3TuzJD7HP6kFtRoSJE5EFxPx6Yt7GXKG t1PZY/l1jLH5xvjYCv5sZFMhjVbTTdRTz2xifsI50rYSGQuciQ7LeEUhk9nFRub6rgrJ XInB9uwrJMIwmqXg2Ck0liUzxlaEhACDnb4wmHa+KIb5StEUxNdzwMkd/kJQbXlAGVSI /tuEyUFftr3KhNBbLVs5cppB3rLOlza6GyHuyyq4UXaEa8FRiJ44Kuyi55Gia/2cDOxm JNKg== X-Gm-Message-State: AOJu0Yz+IROboSwmDjfRUCSf3bPwcf8+fiLR82dpGXTWLrENBXo4E/qt 90Emo37URVU1kKUP10RdSEwOqP5g8ym4whzFnIW5UMc/4Qg81MWEDgjrLRpaK6tpda/TI0xTM5s = X-Google-Smtp-Source: AGHT+IEWVocMR0OSpXQjBov9EAVJTiEamQCDoOjURCCktQMQd9uv57LDp1EvOz2/ijUWWuWjR0Qe6g== X-Received: by 2002:ac2:5b4f:0:b0:52b:c222:5237 with SMTP id 2adb3069b0e04-52ca6e6597amr1337254e87.22.1718350615786; Fri, 14 Jun 2024 00:36:55 -0700 (PDT) Received: from localhost.localdomain ([2001:861:3382:1a90:cb5c:2e27:9d1c:5033]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-36075093636sm3558191f8f.14.2024.06.14.00.36.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 14 Jun 2024 00:36:55 -0700 (PDT) From: =?UTF-8?q?Marc=20Poulhi=C3=A8s?= To: gcc-patches@gcc.gnu.org Cc: Eric Botcazou Subject: [COMMITTED 13/16] ada: Do not create null GCC thunks Date: Fri, 14 Jun 2024 09:36:29 +0200 Message-ID: <20240614073633.2089692-13-poulhies@adacore.com> X-Mailer: git-send-email 2.45.1 In-Reply-To: <20240614073633.2089692-1-poulhies@adacore.com> References: <20240614073633.2089692-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,T_SCC_BODY_TEXT_LINE 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: Eric Botcazou This prevents Gigi from creating null GCC thunks, i.e. thunks that have all their internal parameters set to zero, replacing them with aliases. They can arise in degenerate cases and null thunks would trip on an assertion in former_thunk_p when they are later optimized. gcc/ada/ PR ada/109817 * gcc-interface/trans.cc (maybe_make_gnu_thunk): Create an alias instead of a null thunk. Tested on x86_64-pc-linux-gnu, committed on master. --- gcc/ada/gcc-interface/trans.cc | 29 +++++++++++++++++++---------- 1 file changed, 19 insertions(+), 10 deletions(-) diff --git a/gcc/ada/gcc-interface/trans.cc b/gcc/ada/gcc-interface/trans.cc index 93978c0f0ba..5256095dfeb 100644 --- a/gcc/ada/gcc-interface/trans.cc +++ b/gcc/ada/gcc-interface/trans.cc @@ -11093,6 +11093,16 @@ maybe_make_gnu_thunk (Entity_Id gnat_thunk, tree gnu_thunk) tree gnu_interface_offset = gnu_interface_tag ? byte_position (gnu_interface_tag) : NULL_TREE; + /* But we generate a call to the Thunk_Entity in the thunk. */ + tree gnu_target + = gnat_to_gnu_entity (Thunk_Entity (gnat_thunk), NULL_TREE, false); + + /* If the target is local, then thunk and target must have the same context + because cgraph_node::expand_thunk can only forward the static chain. */ + if (DECL_STATIC_CHAIN (gnu_target) + && DECL_CONTEXT (gnu_thunk) != DECL_CONTEXT (gnu_target)) + return false; + /* There are three ways to retrieve the offset between the interface view and the base object. Either the controlling type covers the interface type and the offset of the corresponding tag is fixed, in which case it @@ -11111,6 +11121,15 @@ maybe_make_gnu_thunk (Entity_Id gnat_thunk, tree gnu_thunk) virtual_value = 0; virtual_offset = NULL_TREE; indirect_offset = 0; + + /* Do not create a null thunk, instead make it an alias. */ + if (fixed_offset == 0) + { + SET_DECL_ASSEMBLER_NAME (gnu_thunk, DECL_ASSEMBLER_NAME (gnu_target)); + (void) cgraph_node::get_create (gnu_target); + (void) cgraph_node::create_alias (gnu_thunk, gnu_target); + return true; + } } else if (!gnu_interface_offset && !Is_Variable_Size_Record (gnat_controlling_type)) @@ -11132,16 +11151,6 @@ maybe_make_gnu_thunk (Entity_Id gnat_thunk, tree gnu_thunk) indirect_offset = (HOST_WIDE_INT) (POINTER_SIZE / BITS_PER_UNIT); } - /* But we generate a call to the Thunk_Entity in the thunk. */ - tree gnu_target - = gnat_to_gnu_entity (Thunk_Entity (gnat_thunk), NULL_TREE, false); - - /* If the target is local, then thunk and target must have the same context - because cgraph_node::expand_thunk can only forward the static chain. */ - if (DECL_STATIC_CHAIN (gnu_target) - && DECL_CONTEXT (gnu_thunk) != DECL_CONTEXT (gnu_target)) - return false; - /* If the target returns by invisible reference and is external, apply the same transformation as Subprogram_Body_to_gnu here. */ if (TREE_ADDRESSABLE (TREE_TYPE (gnu_target)) -- 2.45.1