aboutsummaryrefslogtreecommitdiff
path: root/lib/CodeGen/CodeGenModule.cpp
diff options
context:
space:
mode:
authorBenjamin Kramer <benny.kra@googlemail.com>2012-05-12 21:10:52 +0000
committerBenjamin Kramer <benny.kra@googlemail.com>2012-05-12 21:10:52 +0000
commitee409a916e9b97ed6bc2f48d8d6aac6b8b773d7b (patch)
tree12e368032b763331926a01290bffec6c87598e30 /lib/CodeGen/CodeGenModule.cpp
parent2283b4664b004aae034b08f305ad2bc1dff9868e (diff)
Add support for __attribute__((hot)) and __attribute__((cold)).
Currently cold functions are marked with the "optsize" attribute in CodeGen so they are always optimized for size. The hot attribute is just ignored, LLVM doesn't have a way to express hotness at the moment. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@156723 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/CodeGenModule.cpp')
-rw-r--r--lib/CodeGen/CodeGenModule.cpp4
1 files changed, 4 insertions, 0 deletions
diff --git a/lib/CodeGen/CodeGenModule.cpp b/lib/CodeGen/CodeGenModule.cpp
index 775f500fdb..f2dda5d658 100644
--- a/lib/CodeGen/CodeGenModule.cpp
+++ b/lib/CodeGen/CodeGenModule.cpp
@@ -523,6 +523,10 @@ void CodeGenModule::SetLLVMFunctionAttributesForDefinition(const Decl *D,
!F->hasFnAttr(llvm::Attribute::NoInline))
F->addFnAttr(llvm::Attribute::AlwaysInline);
+ // FIXME: Communicate hot and cold attributes to LLVM more directly.
+ if (D->hasAttr<ColdAttr>())
+ F->addFnAttr(llvm::Attribute::OptimizeForSize);
+
if (isa<CXXConstructorDecl>(D) || isa<CXXDestructorDecl>(D))
F->setUnnamedAddr(true);