[llvm] r182638 - Add a new function attribute 'cold' to functions.

Chandler Carruth chandlerc at google.com
Tue Jul 9 18:12:02 PDT 2013


On Tue, Jul 9, 2013 at 5:59 PM, Tobias Grosser <tobias at grosser.es> wrote:

> On 05/24/2013 05:26 AM, Diego Novillo wrote:
>
>> Author: dnovillo
>> Date: Fri May 24 07:26:52 2013
>> New Revision: 182638
>>
>> URL: http://llvm.org/viewvc/llvm-**project?rev=182638&view=rev<http://llvm.org/viewvc/llvm-project?rev=182638&view=rev>
>> Log:
>> Add a new function attribute 'cold' to functions.
>>
>> Other than recognizing the attribute, the patch does little else.
>> It changes the branch probability analyzer so that edges into
>> blocks postdominated by a cold function are given low weight.
>>
>> Added analysis and code generation tests.  Added documentation for the
>> new attribute.
>>
>
> It seems this commit broke bitcode compatibility with LLVM 3.3, but
> surprisingly not with LLVM 3.2. This suggests that 3.2 did not yet
> depend on the order of the attribute enum whereas 3.3 somehow seems
> to depend on it. This may be related to Bill's attribute refactoring.
>

The bitcode representation is supposed to be fixed via the stable masks
here:

Modified: llvm/trunk/lib/IR/Attributes.cpp
URL:
http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/Attributes.cpp?rev=182638&r1=182637&r2=182638&view=diff
============================================================
==================
--- llvm/trunk/lib/IR/Attributes.cpp (original)
+++ llvm/trunk/lib/IR/Attributes.cpp Fri May 24 07:26:52 2013
@@ -396,6 +398,7 @@ uint64_t AttributeImpl::getAttrMask(Attr
   case Attribute::SanitizeMemory:  return 1ULL << 37;
   case Attribute::NoBuiltin:       return 1ULL << 38;
   case Attribute::Returned:        return 1ULL << 39;
+  case Attribute::Cold:            return 1ULL << 40;
   }
   llvm_unreachable("Unsupported attribute type");
 }

Where we append in order to not change the existing values. If bitcode
isn't serializing using these, and instead using the enum in Attributes.h
that doesn't specify specific values, that seems like a bug in the new
attribute code which we should fix. This is likely just the first attribute
to tickle it.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20130709/9995575d/attachment.html>


More information about the llvm-commits mailing list