From patchwork Wed Nov 13 09:07:26 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Hubicka X-Patchwork-Id: 1194129 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-513208-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=ucw.cz Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="OjP59ria"; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 47Cdzv5XxRz9sNx for ; Wed, 13 Nov 2019 20:07:37 +1100 (AEDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:subject:message-id:mime-version:content-type; q=dns; s= default; b=KrfzN8fFBC8bTFmNSu+fAqBExuZW+/SkFLjom7HP7f3SHtq6mOLSH JmMp59Nf6t4xgvMUqRzjJw79Ptqpuhlm51U4uJEKqPGXEzk3D1XJceVtiFfvQGtg z4QTEd3rP9bAepXqFSPn1hg+CiyPEgNkEzG6tZzDxPrgjsHfhfI/M8= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:subject:message-id:mime-version:content-type; s= default; bh=OlfNUe5XZW6VdcRuSkP1tA5Msys=; b=OjP59riaDZgLvipklayk UFW1nt4gcWazEUumL2LaZcGwIP9yoOBANLVYwjkPe9d5oYTrv0BitBB/1lV+48Jd 1wgGD9NTpgJnoa5VGU+5xv/ztcWh55vHkhrrv2n21HW1ZmdDInkI7js6fgx0dC3/ VweBeLcGCLaUkF78hfvn7Vc= Received: (qmail 16258 invoked by alias); 13 Nov 2019 09:07:30 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 16249 invoked by uid 89); 13 Nov 2019 09:07:30 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-10.4 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_2, GIT_PATCH_3 autolearn=ham version=3.3.1 spammy= X-HELO: nikam.ms.mff.cuni.cz Received: from nikam.ms.mff.cuni.cz (HELO nikam.ms.mff.cuni.cz) (195.113.20.16) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 13 Nov 2019 09:07:28 +0000 Received: by nikam.ms.mff.cuni.cz (Postfix, from userid 16202) id C74F12805F0; Wed, 13 Nov 2019 10:07:26 +0100 (CET) Date: Wed, 13 Nov 2019 10:07:26 +0100 From: Jan Hubicka To: gcc-patches@gcc.gnu.org Subject: Fix optimization options for -fprofile-generate ctors Message-ID: <20191113090726.o2m3m6xit4y2fspu@kam.mff.cuni.cz> MIME-Version: 1.0 Content-Disposition: inline User-Agent: NeoMutt/20170113 (1.7.2) Hi, this patch fixes another ada lto profiledbootstrap issue uncovered by the summary allocation changes. -fprofile-generate produces cdtors after free_lang_data and those gets streamed without optimization/target option nodes which ends up in the options silently changing from compile time to link-time eventually triggering ice in ipa-cp due to missing summary when -O0 -fprofile-genereate unit is built (which is bit pointless anyway). Testing this I also noticed another problem with asan as described in FIXME comment. Bootstrapped/regtested x86_64-linux, comitted. * ipa.c (cgraph_build_static_cdtor): Pass optimization_default_node and target_option_default_node to get -fprofile-generate ctors working right with LTO. Index: ipa.c =================================================================== --- ipa.c (revision 278094) +++ ipa.c (working copy) @@ -914,7 +914,14 @@ cgraph_build_static_cdtor_1 (char which, void cgraph_build_static_cdtor (char which, tree body, int priority) { - cgraph_build_static_cdtor_1 (which, body, priority, false, NULL, NULL); + /* FIXME: We should be able to + gcc_assert (!in_lto_p); + because at LTO time the global options are not safe to use. + Unfortunately ASAN finish_file will produce constructors late and they + may lead to surprises. */ + cgraph_build_static_cdtor_1 (which, body, priority, false, + optimization_default_node, + target_option_default_node); } /* When target does not have ctors and dtors, we call all constructor