]> granicus.if.org Git - clang/commitdiff
Pass inline keyword to optimizer as the new InlineHint function attribute.
authorJakob Stoklund Olesen <stoklund@2pi.dk>
Tue, 9 Feb 2010 00:10:00 +0000 (00:10 +0000)
committerJakob Stoklund Olesen <stoklund@2pi.dk>
Tue, 9 Feb 2010 00:10:00 +0000 (00:10 +0000)
At the moment the inlinehint attribute is ignored by the Inliner unless you
pass a -respect-inlinehint option.  This will soon be the default.

The inlinehint attribute is set if the inline keyword is explicitly specified
on any declaration.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@95623 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/CodeGenFunction.cpp

index 4eeea8eea79dcbc385f7598fded2c99ab8b54062..5a4f94e3e092c61a4bcab31ff8ab77d399d48eb4 100644 (file)
@@ -171,6 +171,16 @@ void CodeGenFunction::StartFunction(GlobalDecl GD, QualType RetTy,
   CurFn = Fn;
   assert(CurFn->isDeclaration() && "Function already has body?");
 
+  // Pass inline keyword to optimizer if it appears explicitly on any
+  // declaration.
+  if (const FunctionDecl *FD = dyn_cast_or_null<FunctionDecl>(D))
+    for (FunctionDecl::redecl_iterator RI = FD->redecls_begin(),
+           RE = FD->redecls_end(); RI != RE; ++RI)
+      if (RI->isInlineSpecified()) {
+        Fn->addFnAttr(llvm::Attribute::InlineHint);
+        break;
+      }
+
   llvm::BasicBlock *EntryBB = createBasicBlock("entry", CurFn);
 
   // Create a marker to make it easy to insert allocas into the entryblock