From de3be0d8caa7438422a0f08230d0855a73f046d9 Mon Sep 17 00:00:00 2001 From: David Majnemer Date: Tue, 25 Feb 2014 09:53:29 +0000 Subject: [PATCH] Attr: Remove ForceInline The __forceinline keyword's semantics are now recast as AlwaysInline and the kw___forceinline token has its language mode set for KEYMS. This preserves the semantics of the previous implementation but with less duplication of code. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@202131 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/clang/Basic/Attr.td | 8 +------- include/clang/Basic/TokenKinds.def | 2 +- lib/CodeGen/CodeGenFunction.cpp | 3 +-- lib/CodeGen/CodeGenModule.cpp | 6 ++---- lib/Sema/SemaDeclAttr.cpp | 2 -- 5 files changed, 5 insertions(+), 16 deletions(-) diff --git a/include/clang/Basic/Attr.td b/include/clang/Basic/Attr.td index 2daa8f1763..b04aa46191 100644 --- a/include/clang/Basic/Attr.td +++ b/include/clang/Basic/Attr.td @@ -357,7 +357,7 @@ def AlignMac68k : InheritableAttr { } def AlwaysInline : InheritableAttr { - let Spellings = [GCC<"always_inline">]; + let Spellings = [GCC<"always_inline">, Keyword<"__forceinline">]; let Subjects = SubjectList<[Function]>; let Documentation = [Undocumented]; } @@ -1676,12 +1676,6 @@ def DLLImport : InheritableAttr, TargetSpecificAttr { let Documentation = [Undocumented]; } -def ForceInline : InheritableAttr { - let Spellings = [Keyword<"__forceinline">]; - let LangOpts = [MicrosoftExt]; - let Documentation = [Undocumented]; -} - def SelectAny : InheritableAttr { let Spellings = [Declspec<"selectany">]; let LangOpts = [MicrosoftExt]; diff --git a/include/clang/Basic/TokenKinds.def b/include/clang/Basic/TokenKinds.def index eddfd7e4af..b64ad05cd0 100644 --- a/include/clang/Basic/TokenKinds.def +++ b/include/clang/Basic/TokenKinds.def @@ -455,7 +455,7 @@ KEYWORD(__cdecl , KEYALL) KEYWORD(__stdcall , KEYALL) KEYWORD(__fastcall , KEYALL) KEYWORD(__thiscall , KEYALL) -KEYWORD(__forceinline , KEYALL) +KEYWORD(__forceinline , KEYMS) KEYWORD(__unaligned , KEYMS) // OpenCL address space qualifiers diff --git a/lib/CodeGen/CodeGenFunction.cpp b/lib/CodeGen/CodeGenFunction.cpp index 409d1141b8..e81b1bccb1 100644 --- a/lib/CodeGen/CodeGenFunction.cpp +++ b/lib/CodeGen/CodeGenFunction.cpp @@ -527,8 +527,7 @@ void CodeGenFunction::StartFunction(GlobalDecl GD, Fn->addFnAttr(llvm::Attribute::InlineHint); break; } - } else if (!FD->hasAttr() && - !FD->hasAttr()) + } else if (!FD->hasAttr()) Fn->addFnAttr(llvm::Attribute::NoInline); } diff --git a/lib/CodeGen/CodeGenModule.cpp b/lib/CodeGen/CodeGenModule.cpp index e6798e49a8..f7b518abc5 100644 --- a/lib/CodeGen/CodeGenModule.cpp +++ b/lib/CodeGen/CodeGenModule.cpp @@ -635,8 +635,7 @@ void CodeGenModule::SetLLVMFunctionAttributesForDefinition(const Decl *D, B.addAttribute(llvm::Attribute::NoDuplicate); } else if (D->hasAttr()) { B.addAttribute(llvm::Attribute::NoInline); - } else if ((D->hasAttr() || - D->hasAttr()) && + } else if (D->hasAttr() && !F->getAttributes().hasAttribute(llvm::AttributeSet::FunctionIndex, llvm::Attribute::NoInline)) { // (noinline wins over always_inline, and we can't specify both in IR) @@ -1245,8 +1244,7 @@ CodeGenModule::shouldEmitFunction(GlobalDecl GD) { if (getFunctionLinkage(GD) != llvm::Function::AvailableExternallyLinkage) return true; const FunctionDecl *F = cast(GD.getDecl()); - if (CodeGenOpts.OptimizationLevel == 0 && - !F->hasAttr() && !F->hasAttr()) + if (CodeGenOpts.OptimizationLevel == 0 && !F->hasAttr()) return false; // PR9614. Avoid cases where the source code is lying to us. An available // externally function should have an equivalent function somewhere else, diff --git a/lib/Sema/SemaDeclAttr.cpp b/lib/Sema/SemaDeclAttr.cpp index 7679fdb789..d61d63a9b9 100644 --- a/lib/Sema/SemaDeclAttr.cpp +++ b/lib/Sema/SemaDeclAttr.cpp @@ -4269,8 +4269,6 @@ static void ProcessDeclAttribute(Sema &S, Scope *scope, Decl *D, break; case AttributeList::AT_MSInheritance: handleMSInheritanceAttr(S, D, Attr); break; - case AttributeList::AT_ForceInline: - handleSimpleAttribute(S, D, Attr); break; case AttributeList::AT_SelectAny: handleSimpleAttribute(S, D, Attr); break; -- 2.40.0