From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from nikam.ms.mff.cuni.cz (nikam.ms.mff.cuni.cz [195.113.20.16]) by sourceware.org (Postfix) with ESMTPS id 8F4B1384AB45 for ; Wed, 17 Apr 2024 13:26:54 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 8F4B1384AB45 Authentication-Results: sourceware.org; dmarc=fail (p=none dis=none) header.from=ucw.cz Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=kam.mff.cuni.cz ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 8F4B1384AB45 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=195.113.20.16 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1713360416; cv=none; b=dW5+2/vCBDallWSHgUl15Lwofc/wCUCW/5jzAxksmQFmKwacZGhh1Fx+mDujfWZy7ANUgKimQIAcLaebSIN+OZfcI5ztu+90wTQ+wSHZ4SahvLw/oGzNf/LeC7g4NDRD21qngzBRax/T8VNjwuWu6XC0JZA0JvyrjzBm+HxpA1k= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1713360416; c=relaxed/simple; bh=VwPI8tSm6xPKtRr6XotWhJYGgrMRScB0T61+BT+IUXU=; h=DKIM-Signature:Date:From:To:Subject:Message-ID:MIME-Version; b=x5lspucMBh78UTvauw+sD0eQBk18+RIiPB4yBxiZteV9qtEqAFLa4Or74Uz3v3jv5MYpZsW+spewPBtKNfgdlzhS3H7kpmuHy0c/P6RVBNgzLnS1ivCnlcsFTB+L0UPDMgx6Nu2ozwAG65vsWEeOZ0DZN5Y68GvYo6RWD5f5gO8= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by nikam.ms.mff.cuni.cz (Postfix, from userid 16202) id 51B7C283837; Wed, 17 Apr 2024 15:26:53 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ucw.cz; s=gen1; t=1713360413; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=WgFd5lzyk7o6WpuscmhgBoiYgLKGQdhy1pZ9rF2R9l8=; b=WBjZ/gn/3C1EVRyl7hYYjHDegxOMZziSiSAHDZ6q7t3MqSWsb1qe1V97MZaL4CyCY27f3u Vjfm9Ob+goo4J91INsxAhNDJ+c9MtfvWxAYNnWwP2kCzrJBUKMoTUUxp/LYj1nOWkKCNTo UmKwPjHsQn7fBY7NaIPttpNUy++txxA= Date: Wed, 17 Apr 2024 15:26:53 +0200 From: Jan Hubicka To: Jakub Jelinek Cc: Jason Merrill , Richard Biener , Patrick Palka , gcc-patches@gcc.gnu.org Subject: Re: [PATCH] c++: Retry the aliasing of base/complete cdtor optimization at import_export_decl time [PR113208] Message-ID: References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-4.6 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,JMQ_SPF_NEUTRAL,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_PASS,TXREP autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: > > I've tried to see what actually happens during linking without LTO, so compiled > pr113208_0.C with -O1 -fkeep-inline-functions -std=c++20 with vanilla trunk > (so it has those 2 separate comdats, one for C2 and one for C1), though I've > changed the > void m(k); > line to > __attribute__((noipa)) void m(k) {} > in the testcase, then compiled > pr113208_1.C with -O2 -fkeep-inline-functions -std=c++20 -fno-omit-frame-pointer > so that one can clearly differentiate from where the implementation was > picked and finally added > template struct _Vector_base { > int g() const; > _Vector_base(int, int); > }; > > struct QualityValue; > template <> > _Vector_base::_Vector_base(int, int) {} > template <> > int _Vector_base::g() const { return 0; } > int main () {} > If I link this, I see _ZN6vectorI12QualityValueEC2ERKS1_ and > _ZN6vectorI12QualityValueEC1ERKS1_ as separate functions with the > omitted frame pointer bodies, so clearly the pr113208_0.C versions prevailed > in both cases. It is unclear why that isn't the case for LTO. I think it is because of -fkeep-inline-functions which makes the first object file to define both symbols, while with LTO we optimize out one of them. So to reproduce same behaviour with non-LTO we would probably need use -O1 and arrange the contructor to be unilinable instead of using -fkeep-inline-functions. Honza