On Fri, May 24, 2013 at 1:18 PM, Diego Novillo <span dir="ltr"><<a href="mailto:dnovillo@google.com" target="_blank">dnovillo@google.com</a>></span> wrote:<br><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Author: dnovillo<br>
Date: Fri May 24 15:18:15 2013<br>
New Revision: 182666<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=182666&view=rev" target="_blank">http://llvm.org/viewvc/llvm-project?rev=182666&view=rev</a><br>
Log:<br>
[PATCH] Generate cold attribute for functions marked __atribute__((cold))<br>
<br>
This removes a FIXME in CodeGenModule::SetLLVMFunctionAttributesForDefinition.<br>
When a function is declared cold we can now generate the IR attribute in<br>
addition to marking the function to be optimized for size.<br>
<br>
I tried adding a separate CHECK in the existing test, but it was<br>
failing.  I suppose CHECK matches one line exactly once?  This would be<br>
a problem if the attributes are listed in a different order, though they<br>
seem to be sorted.<br></blockquote><div><br></div><div>Each CHECK only looks at the text after the end of the previous CHECK's match. I believe the order in which attributes are printed is stable.</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

Modified:<br>
    cfe/trunk/lib/CodeGen/CodeGenModule.cpp<br>
    cfe/trunk/test/CodeGen/attr-coldhot.c<br>
<br>
Modified: cfe/trunk/lib/CodeGen/CodeGenModule.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenModule.cpp?rev=182666&r1=182665&r2=182666&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenModule.cpp?rev=182666&r1=182665&r2=182666&view=diff</a><br>

==============================================================================<br>
--- cfe/trunk/lib/CodeGen/CodeGenModule.cpp (original)<br>
+++ cfe/trunk/lib/CodeGen/CodeGenModule.cpp Fri May 24 15:18:15 2013<br>
@@ -620,9 +620,10 @@ void CodeGenModule::SetLLVMFunctionAttri<br>
     B.addAttribute(llvm::Attribute::AlwaysInline);<br>
   }<br>
<br>
-  // FIXME: Communicate hot and cold attributes to LLVM more directly.<br>
-  if (D->hasAttr<ColdAttr>())<br>
+  if (D->hasAttr<ColdAttr>()) {<br>
     B.addAttribute(llvm::Attribute::OptimizeForSize);<br>
+    B.addAttribute(llvm::Attribute::Cold);<br>
+  }<br>
<br>
   if (D->hasAttr<MinSizeAttr>())<br>
     B.addAttribute(llvm::Attribute::MinSize);<br>
<br>
Modified: cfe/trunk/test/CodeGen/attr-coldhot.c<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/attr-coldhot.c?rev=182666&r1=182665&r2=182666&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/attr-coldhot.c?rev=182666&r1=182665&r2=182666&view=diff</a><br>

==============================================================================<br>
--- cfe/trunk/test/CodeGen/attr-coldhot.c (original)<br>
+++ cfe/trunk/test/CodeGen/attr-coldhot.c Fri May 24 15:18:15 2013<br>
@@ -8,4 +8,4 @@ int test1() __attribute__((__cold__)) {<br>
 // CHECK: ret<br>
 }<br>
<br>
-// CHECK: attributes [[ATTR]] = { {{.*}}optsize{{.*}} }<br>
+// CHECK: attributes [[ATTR]] = { {{.*}}cold{{.*}}optsize{{.*}} }<br>
<br>
<br>
_______________________________________________<br>
cfe-commits mailing list<br>
<a href="mailto:cfe-commits@cs.uiuc.edu">cfe-commits@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits</a><br>
</blockquote></div><br>