aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/CodeGen/CodeGenModule.cpp
diff options
context:
space:
mode:
authorEli Friedman <eli.friedman@gmail.com>2011-08-22 23:55:33 +0000
committerEli Friedman <eli.friedman@gmail.com>2011-08-22 23:55:33 +0000
commitc55efe4fb2e2684b788ecd3d02fd80724d785cd7 (patch)
tree6057047425b62f7a939dfa0274980f6782936ca0 /clang/lib/CodeGen/CodeGenModule.cpp
parent5b31d7acf7c7eb4f7edefee31171d8daa3b07255 (diff)
downloadllvm-c55efe4fb2e2684b788ecd3d02fd80724d785cd7.zip
llvm-c55efe4fb2e2684b788ecd3d02fd80724d785cd7.tar.gz
llvm-c55efe4fb2e2684b788ecd3d02fd80724d785cd7.tar.bz2
Make sure we don't inline functions marked with __attribute__((naked)). <rdar://problem/9973228>
llvm-svn: 138310
Diffstat (limited to 'clang/lib/CodeGen/CodeGenModule.cpp')
-rw-r--r--clang/lib/CodeGen/CodeGenModule.cpp13
1 files changed, 9 insertions, 4 deletions
diff --git a/clang/lib/CodeGen/CodeGenModule.cpp b/clang/lib/CodeGen/CodeGenModule.cpp
index 0584a32..3e30c57 100644
--- a/clang/lib/CodeGen/CodeGenModule.cpp
+++ b/clang/lib/CodeGen/CodeGenModule.cpp
@@ -472,15 +472,20 @@ void CodeGenModule::SetLLVMFunctionAttributesForDefinition(const Decl *D,
if (!Features.Exceptions && !Features.ObjCNonFragileABI)
F->addFnAttr(llvm::Attribute::NoUnwind);
- if (D->hasAttr<AlwaysInlineAttr>())
- F->addFnAttr(llvm::Attribute::AlwaysInline);
-
- if (D->hasAttr<NakedAttr>())
+ if (D->hasAttr<NakedAttr>()) {
+ // Naked implies noinline: we should not be inlining such functions.
F->addFnAttr(llvm::Attribute::Naked);
+ F->addFnAttr(llvm::Attribute::NoInline);
+ }
if (D->hasAttr<NoInlineAttr>())
F->addFnAttr(llvm::Attribute::NoInline);
+ // (noinline wins over always_inline, and we can't specify both in IR)
+ if (D->hasAttr<AlwaysInlineAttr>() &&
+ !F->hasFnAttr(llvm::Attribute::NoInline))
+ F->addFnAttr(llvm::Attribute::AlwaysInline);
+
if (isa<CXXConstructorDecl>(D) || isa<CXXDestructorDecl>(D))
F->setUnnamedAddr(true);