summaryrefslogtreecommitdiffstats
path: root/clang/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
commit29c2b4330ce07a7af7452cf3ad2528d0e31952b0 (patch)
treef5699efd7c32a0f611d2e216c5ea9194407df768 /clang/lib/CodeGen/CodeGenModule.cpp
parentc4b649d50a08730ffd0869c849c8dbc215faf527 (diff)
downloadbcm5719-llvm-29c2b4330ce07a7af7452cf3ad2528d0e31952b0.tar.gz
bcm5719-llvm-29c2b4330ce07a7af7452cf3ad2528d0e31952b0.zip
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. llvm-svn: 156723
Diffstat (limited to 'clang/lib/CodeGen/CodeGenModule.cpp')
-rw-r--r--clang/lib/CodeGen/CodeGenModule.cpp4
1 files changed, 4 insertions, 0 deletions
diff --git a/clang/lib/CodeGen/CodeGenModule.cpp b/clang/lib/CodeGen/CodeGenModule.cpp
index 775f500fdb1..f2dda5d658f 100644
--- a/clang/lib/CodeGen/CodeGenModule.cpp
+++ b/clang/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);
OpenPOWER on IntegriCloud