Date: Wed, 24 Oct 2012 16:39:49 +0000 (UTC) From: Dimitry Andric <dim@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r242007 - head/contrib/llvm/lib/Analysis Message-ID: <201210241639.q9OGdnSZ053419@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: dim Date: Wed Oct 24 16:39:49 2012 New Revision: 242007 URL: http://svn.freebsd.org/changeset/base/242007 Log: Pull in r165367 from upstream llvm trunk: Make sure always-inline functions get inlined. <rdar://problem/12423986> 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 <jbeich@tormail.org> MFC after: 1 week Modified: head/contrib/llvm/lib/Analysis/InlineCost.cpp Modified: head/contrib/llvm/lib/Analysis/InlineCost.cpp ============================================================================== --- head/contrib/llvm/lib/Analysis/InlineCost.cpp Wed Oct 24 16:37:53 2012 (r242006) +++ head/contrib/llvm/lib/Analysis/InlineCost.cpp Wed Oct 24 16:39:49 2012 (r242007) @@ -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. @@ -1011,7 +1012,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());
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201210241639.q9OGdnSZ053419>