On Fri, May 24, 2013 at 12:20 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">
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>
<br>
OK to commit?</blockquote><div><br></div><div>LGTM</div><div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Thanks.  Diego.<br>
<br>
---<br>
 lib/CodeGen/CodeGenModule.cpp | 5 +++--<br>
 test/CodeGen/attr-coldhot.c   | 2 +-<br>
 2 files changed, 4 insertions(+), 3 deletions(-)<br>
<br>
diff --git a/lib/CodeGen/CodeGenModule.cpp b/lib/CodeGen/CodeGenModule.cpp<br>
index e651288..7ad08e0 100644<br>
--- a/lib/CodeGen/CodeGenModule.cpp<br>
+++ b/lib/CodeGen/CodeGenModule.cpp<br>
@@ -620,9 +620,10 @@ void CodeGenModule::SetLLVMFunctionAttributesForDefinition(const Decl *D,<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>
diff --git a/test/CodeGen/attr-coldhot.c b/test/CodeGen/attr-coldhot.c<br>
index a277119..ec54edd 100644<br>
--- a/test/CodeGen/attr-coldhot.c<br>
+++ b/test/CodeGen/attr-coldhot.c<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>
<span class="HOEnZb"><font color="#888888">--<br>
1.8.2.1<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>
</font></span></blockquote></div><br>