diff options
| author | Xinliang David Li <davidxl@google.com> | 2017-06-13 21:14:07 +0000 |
|---|---|---|
| committer | Xinliang David Li <davidxl@google.com> | 2017-06-13 21:14:07 +0000 |
| commit | 4ec360683539f0b9ca68d6b2e2935965a2b25665 (patch) | |
| tree | 61ffad4ecdd0e0246b9578c29daae53c2cc99dab /clang | |
| parent | 0096d78bf9781ec7e0232b49d6cf895e6cfd3a0e (diff) | |
| download | bcm5719-llvm-4ec360683539f0b9ca68d6b2e2935965a2b25665.tar.gz bcm5719-llvm-4ec360683539f0b9ca68d6b2e2935965a2b25665.zip | |
Preserve cold attribute for function decls
Differential Revision: http://reviews.llvm.org/D34133
llvm-svn: 305325
Diffstat (limited to 'clang')
| -rw-r--r-- | clang/lib/CodeGen/CGCall.cpp | 2 | ||||
| -rw-r--r-- | clang/test/CodeGen/attributes.c | 10 |
2 files changed, 12 insertions, 0 deletions
diff --git a/clang/lib/CodeGen/CGCall.cpp b/clang/lib/CodeGen/CGCall.cpp index 07906473358..c65dc18be30 100644 --- a/clang/lib/CodeGen/CGCall.cpp +++ b/clang/lib/CodeGen/CGCall.cpp @@ -1795,6 +1795,8 @@ void CodeGenModule::ConstructAttributeList( FuncAttrs.addAttribute(llvm::Attribute::NoUnwind); if (TargetDecl->hasAttr<NoReturnAttr>()) FuncAttrs.addAttribute(llvm::Attribute::NoReturn); + if (TargetDecl->hasAttr<ColdAttr>()) + FuncAttrs.addAttribute(llvm::Attribute::Cold); if (TargetDecl->hasAttr<NoDuplicateAttr>()) FuncAttrs.addAttribute(llvm::Attribute::NoDuplicate); if (TargetDecl->hasAttr<ConvergentAttr>()) diff --git a/clang/test/CodeGen/attributes.c b/clang/test/CodeGen/attributes.c index 9e5fa9f9065..34833a24692 100644 --- a/clang/test/CodeGen/attributes.c +++ b/clang/test/CodeGen/attributes.c @@ -56,6 +56,13 @@ void t4() {} void t7() __attribute__((noreturn, nothrow)); void t7() { while (1) {} } +// CHECK: define void @t72() [[COLDDEF:#[0-9]+]] { +void t71(void) __attribute__((cold)); +void t72() __attribute__((cold)); +void t72() { t71(); } +// CHECK: call void @t71() [[COLDSITE:#[0-9]+]] +// CHECK: declare void @t71() [[COLDDECL:#[0-9]+]] + // CHECK: define void @t10() [[NUW]] section "SECT" { void t10(void) __attribute__((section("SECT"))); void t10(void) {} @@ -92,3 +99,6 @@ void __attribute__((section(".bar"))) t22(void) {} // CHECK: attributes [[NUW]] = { noinline nounwind{{.*}} } // CHECK: attributes [[NR]] = { noinline noreturn nounwind{{.*}} } +// CHECK: attributes [[COLDDEF]] = { cold {{.*}}} +// CHECK: attributes [[COLDDECL]] = { cold {{.*}}} +// CHECK: attributes [[COLDSITE]] = { cold {{.*}}} |

