From ee409a916e9b97ed6bc2f48d8d6aac6b8b773d7b Mon Sep 17 00:00:00 2001 From: Benjamin Kramer Date: Sat, 12 May 2012 21:10:52 +0000 Subject: 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 --- lib/CodeGen/CodeGenModule.cpp | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'lib/CodeGen/CodeGenModule.cpp') 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()) + F->addFnAttr(llvm::Attribute::OptimizeForSize); + if (isa(D) || isa(D)) F->setUnnamedAddr(true); -- cgit v1.2.3-70-g09d2