From 29c2b4330ce07a7af7452cf3ad2528d0e31952b0 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. llvm-svn: 156723 --- clang/lib/CodeGen/CodeGenModule.cpp | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'clang/lib/CodeGen/CodeGenModule.cpp') diff --git a/clang/lib/CodeGen/CodeGenModule.cpp b/clang/lib/CodeGen/CodeGenModule.cpp index 775f500..f2dda5d 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()) + F->addFnAttr(llvm::Attribute::OptimizeForSize); + if (isa(D) || isa(D)) F->setUnnamedAddr(true); -- cgit v1.1