summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--clang/lib/CodeGen/CodeGenModule.cpp5
-rw-r--r--clang/test/CodeGen/attr-coldhot.c2
2 files changed, 4 insertions, 3 deletions
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<ColdAttr>())
+ if (D->hasAttr<ColdAttr>()) {
B.addAttribute(llvm::Attribute::OptimizeForSize);
+ B.addAttribute(llvm::Attribute::Cold);
+ }
if (D->hasAttr<MinSizeAttr>())
B.addAttribute(llvm::Attribute::MinSize);
diff --git a/clang/test/CodeGen/attr-coldhot.c b/clang/test/CodeGen/attr-coldhot.c
index a2771197084..ec54edde9d7 100644
--- a/clang/test/CodeGen/attr-coldhot.c
+++ b/clang/test/CodeGen/attr-coldhot.c
@@ -8,4 +8,4 @@ int test1() __attribute__((__cold__)) {
// CHECK: ret
}
-// CHECK: attributes [[ATTR]] = { {{.*}}optsize{{.*}} }
+// CHECK: attributes [[ATTR]] = { {{.*}}cold{{.*}}optsize{{.*}} }
OpenPOWER on IntegriCloud