aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/CodeGen/CodeGenModule.cpp
diff options
context:
space:
mode:
authorPaul Robinson <paul_robinson@playstation.sony.com>2014-03-31 22:29:15 +0000
committerPaul Robinson <paul_robinson@playstation.sony.com>2014-03-31 22:29:15 +0000
commitf067435026123765bcba8094676c813a69d28a88 (patch)
treeb75e5a1886f665e3016bce5a6adc0fc737a38147 /clang/lib/CodeGen/CodeGenModule.cpp
parente117992f00c4cf16929b6a65de8eeab15f8942ad (diff)
downloadllvm-f067435026123765bcba8094676c813a69d28a88.zip
llvm-f067435026123765bcba8094676c813a69d28a88.tar.gz
llvm-f067435026123765bcba8094676c813a69d28a88.tar.bz2
Implement the 'optnone' attribute, which suppresses most optimizations
on a function. llvm-svn: 205255
Diffstat (limited to 'clang/lib/CodeGen/CodeGenModule.cpp')
-rw-r--r--clang/lib/CodeGen/CodeGenModule.cpp10
1 files changed, 10 insertions, 0 deletions
diff --git a/clang/lib/CodeGen/CodeGenModule.cpp b/clang/lib/CodeGen/CodeGenModule.cpp
index a6a42f0..89d177f 100644
--- a/clang/lib/CodeGen/CodeGenModule.cpp
+++ b/clang/lib/CodeGen/CodeGenModule.cpp
@@ -660,6 +660,10 @@ void CodeGenModule::SetLLVMFunctionAttributesForDefinition(const Decl *D,
// Naked implies noinline: we should not be inlining such functions.
B.addAttribute(llvm::Attribute::Naked);
B.addAttribute(llvm::Attribute::NoInline);
+ } else if (D->hasAttr<OptimizeNoneAttr>()) {
+ // OptimizeNone implies noinline; we should not be inlining such functions.
+ B.addAttribute(llvm::Attribute::OptimizeNone);
+ B.addAttribute(llvm::Attribute::NoInline);
} else if (D->hasAttr<NoDuplicateAttr>()) {
B.addAttribute(llvm::Attribute::NoDuplicate);
} else if (D->hasAttr<NoInlineAttr>()) {
@@ -679,6 +683,12 @@ void CodeGenModule::SetLLVMFunctionAttributesForDefinition(const Decl *D,
if (D->hasAttr<MinSizeAttr>())
B.addAttribute(llvm::Attribute::MinSize);
+ if (D->hasAttr<OptimizeNoneAttr>()) {
+ // OptimizeNone wins over OptimizeForSize and MinSize.
+ B.removeAttribute(llvm::Attribute::OptimizeForSize);
+ B.removeAttribute(llvm::Attribute::MinSize);
+ }
+
if (LangOpts.getStackProtector() == LangOptions::SSPOn)
B.addAttribute(llvm::Attribute::StackProtect);
else if (LangOpts.getStackProtector() == LangOptions::SSPStrong)