From owner-svn-src-all@FreeBSD.ORG Wed Oct 31 07:57:49 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id C8F43482; Wed, 31 Oct 2012 07:57:49 +0000 (UTC) (envelope-from dim@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 933168FC15; Wed, 31 Oct 2012 07:57:49 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q9V7vnSA084555; Wed, 31 Oct 2012 07:57:49 GMT (envelope-from dim@svn.freebsd.org) Received: (from dim@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q9V7vnY7084552; Wed, 31 Oct 2012 07:57:49 GMT (envelope-from dim@svn.freebsd.org) Message-Id: <201210310757.q9V7vnY7084552@svn.freebsd.org> From: Dimitry Andric Date: Wed, 31 Oct 2012 07:57:49 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org Subject: svn commit: r242393 - stable/9/contrib/llvm/lib/Analysis X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 31 Oct 2012 07:57:50 -0000 Author: dim Date: Wed Oct 31 07:57:49 2012 New Revision: 242393 URL: http://svn.freebsd.org/changeset/base/242393 Log: MFC r242007: Pull in r165367 from upstream llvm trunk: Make sure always-inline functions get inlined. Without this change, when the estimated cost for inlining a function with an "alwaysinline" attribute was lower than the inlining threshold, the getInlineCost function was returning that estimated cost rather than the special InlineCost::AlwaysInlineCost value. That is fine in the normal inlining case, but it can fail when the inliner considers the opportunity cost of inlining into an internal or linkonce-odr function. It may decide not to inline the always-inline function in that case. The fix here is just to make getInlineCost always return the special value for always-inline functions. I ran into this building clang with libc++. Tablegen failed to link because of an always-inline function that was not inlined. I have been unable to reduce the testcase down to a reasonable size. This should fix the link errors that were reported when atf-run was compiled with clang -stdlib=libc++. In this case, at -O3 optimization, some calls to basic_ios::clear() were not inlined, even when the function was marked __always_inline__. Reported by: Jan Beich Modified: stable/9/contrib/llvm/lib/Analysis/InlineCost.cpp Directory Properties: stable/9/contrib/llvm/ (props changed) Modified: stable/9/contrib/llvm/lib/Analysis/InlineCost.cpp ============================================================================== --- stable/9/contrib/llvm/lib/Analysis/InlineCost.cpp Wed Oct 31 06:35:50 2012 (r242392) +++ stable/9/contrib/llvm/lib/Analysis/InlineCost.cpp Wed Oct 31 07:57:49 2012 (r242393) @@ -138,6 +138,7 @@ public: int getThreshold() { return Threshold; } int getCost() { return Cost; } + bool isAlwaysInline() { return AlwaysInline; } // Keep a bunch of stats about the cost savings found so we can print them // out when debugging. @@ -1015,7 +1016,8 @@ InlineCost InlineCostAnalyzer::getInline // Check if there was a reason to force inlining or no inlining. if (!ShouldInline && CA.getCost() < CA.getThreshold()) return InlineCost::getNever(); - if (ShouldInline && CA.getCost() >= CA.getThreshold()) + if (ShouldInline && (CA.isAlwaysInline() || + CA.getCost() >= CA.getThreshold())) return InlineCost::getAlways(); return llvm::InlineCost::get(CA.getCost(), CA.getThreshold());