diff options
| author | Diego Novillo <dnovillo@google.com> | 2013-05-24 20:18:15 +0000 |
|---|---|---|
| committer | Diego Novillo <dnovillo@google.com> | 2013-05-24 20:18:15 +0000 |
| commit | 5f2b1ce21ecdacdd5d16a63fd880199befe3d074 (patch) | |
| tree | f06917bc3f69a8cfe4691f7be128c9f8a9a3c0b2 /clang | |
| parent | 23bbd617e46ac1c12277ac073cc49a6b6290c684 (diff) | |
| download | bcm5719-llvm-5f2b1ce21ecdacdd5d16a63fd880199befe3d074.tar.gz bcm5719-llvm-5f2b1ce21ecdacdd5d16a63fd880199befe3d074.zip | |
[PATCH] Generate cold attribute for functions marked __atribute__((cold))
This removes a FIXME in CodeGenModule::SetLLVMFunctionAttributesForDefinition.
When a function is declared cold we can now generate the IR attribute in
addition to marking the function to be optimized for size.
I tried adding a separate CHECK in the existing test, but it was
failing. I suppose CHECK matches one line exactly once? This would be
a problem if the attributes are listed in a different order, though they
seem to be sorted.
llvm-svn: 182666
Diffstat (limited to 'clang')
| -rw-r--r-- | clang/lib/CodeGen/CodeGenModule.cpp | 5 | ||||
| -rw-r--r-- | clang/test/CodeGen/attr-coldhot.c | 2 |
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{{.*}} } |

