From 5f2b1ce21ecdacdd5d16a63fd880199befe3d074 Mon Sep 17 00:00:00 2001 From: Diego Novillo Date: Fri, 24 May 2013 20:18:15 +0000 Subject: [PATCH] Generate cold attribute for functions marked __atribute__((cold)) This removes a FIXME in CodeGenModule::SetLLVMFunctionAttributesForDefinition. When a function is declared cold we can now generate the IR attribute in addition to marking the function to be optimized for size. I tried adding a separate CHECK in the existing test, but it was failing. I suppose CHECK matches one line exactly once? This would be a problem if the attributes are listed in a different order, though they seem to be sorted. llvm-svn: 182666 --- clang/lib/CodeGen/CodeGenModule.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'clang/lib/CodeGen/CodeGenModule.cpp') diff --git a/clang/lib/CodeGen/CodeGenModule.cpp b/clang/lib/CodeGen/CodeGenModule.cpp index e65128813e1..7ad08e0e0a7 100644 --- a/clang/lib/CodeGen/CodeGenModule.cpp +++ b/clang/lib/CodeGen/CodeGenModule.cpp @@ -620,9 +620,10 @@ void CodeGenModule::SetLLVMFunctionAttributesForDefinition(const Decl *D, B.addAttribute(llvm::Attribute::AlwaysInline); } - // FIXME: Communicate hot and cold attributes to LLVM more directly. - if (D->hasAttr()) + if (D->hasAttr()) { B.addAttribute(llvm::Attribute::OptimizeForSize); + B.addAttribute(llvm::Attribute::Cold); + } if (D->hasAttr()) B.addAttribute(llvm::Attribute::MinSize); -- cgit v1.2.3