diff --git a/lib/CodeGen/CodeGenModule.cpp b/lib/CodeGen/CodeGenModule.cpp index e65128813e..7ad08e0e0a 100644 --- a/lib/CodeGen/CodeGenModule.cpp +++ b/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); diff --git a/test/CodeGen/attr-coldhot.c b/test/CodeGen/attr-coldhot.c index a277119708..ec54edde9d 100644 --- a/test/CodeGen/attr-coldhot.c +++ b/test/CodeGen/attr-coldhot.c @@ -8,4 +8,4 @@ int test1() __attribute__((__cold__)) { // CHECK: ret } -// CHECK: attributes [[ATTR]] = { {{.*}}optsize{{.*}} } +// CHECK: attributes [[ATTR]] = { {{.*}}cold{{.*}}optsize{{.*}} }