[cfe-commits] r166946 - in /cfe/trunk: include/clang/Basic/Attr.td lib/CodeGen/CodeGenModule.cpp lib/Sema/SemaDeclAttr.cpp test/CodeGen/attr-forcesizeopt.c

Quentin Colombet qcolombet at apple.com
Mon Oct 29 11:08:34 PDT 2012


Hi Eli,

I have send the patch last Friday.
Since I did not have any answers, I though it was ok.
Sorry, if it was not.
Should I revert it and wait more?


Thank you,

Quentin


On Oct 29, 2012, at 10:56 AM, Quentin Colombet <qcolombet at apple.com> wrote:

> Author: qcolombet
> Date: Mon Oct 29 12:56:23 2012
> New Revision: 166946
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=166946&view=rev
> Log:
> Make forcesizeopt attribute available to the end user
> 
> Modified:
>    cfe/trunk/include/clang/Basic/Attr.td
>    cfe/trunk/lib/CodeGen/CodeGenModule.cpp
>    cfe/trunk/lib/Sema/SemaDeclAttr.cpp
>    cfe/trunk/test/CodeGen/attr-forcesizeopt.c
> 
> Modified: cfe/trunk/include/clang/Basic/Attr.td
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Attr.td?rev=166946&r1=166945&r2=166946&view=diff
> ==============================================================================
> --- cfe/trunk/include/clang/Basic/Attr.td (original)
> +++ cfe/trunk/include/clang/Basic/Attr.td Mon Oct 29 12:56:23 2012
> @@ -341,6 +341,11 @@
>   let SemaHandler = 0;
> }
> 
> +def ForceSizeOpt : InheritableAttr {
> +  let Spellings = [GNU<"forcesizeopt">];
> +  let Subjects = [Function];
> +}
> +
> def Format : InheritableAttr {
>   let Spellings = [GNU<"format">];
>   let Args = [StringArgument<"Type">, IntArgument<"FormatIdx">,
> 
> Modified: cfe/trunk/lib/CodeGen/CodeGenModule.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenModule.cpp?rev=166946&r1=166945&r2=166946&view=diff
> ==============================================================================
> --- cfe/trunk/lib/CodeGen/CodeGenModule.cpp (original)
> +++ cfe/trunk/lib/CodeGen/CodeGenModule.cpp Mon Oct 29 12:56:23 2012
> @@ -583,6 +583,9 @@
>   if (D->hasAttr<ColdAttr>())
>     F->addFnAttr(llvm::Attributes::OptimizeForSize);
> 
> +  if (D->hasAttr<ForceSizeOptAttr>())
> +    F->addFnAttr(llvm::Attributes::ForceSizeOpt);
> +
>   if (isa<CXXConstructorDecl>(D) || isa<CXXDestructorDecl>(D))
>     F->setUnnamedAddr(true);
> 
> 
> Modified: cfe/trunk/lib/Sema/SemaDeclAttr.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclAttr.cpp?rev=166946&r1=166945&r2=166946&view=diff
> ==============================================================================
> --- cfe/trunk/lib/Sema/SemaDeclAttr.cpp (original)
> +++ cfe/trunk/lib/Sema/SemaDeclAttr.cpp Mon Oct 29 12:56:23 2012
> @@ -1523,6 +1523,20 @@
>                                          Str->getString()));
> }
> 
> +static void handleForceSizeOptAttr(Sema &S, Decl *D, const AttributeList &Attr) {
> +  // Check the attribute arguments.
> +  if (!checkAttributeNumArgs(S, Attr, 0))
> +    return;
> +
> +  if (!isa<FunctionDecl>(D)) {
> +    S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type)
> +      << Attr.getName() << ExpectedFunction;
> +    return;
> +  }
> +
> +  D->addAttr(::new (S.Context) ForceSizeOptAttr(Attr.getRange(), S.Context));
> +}
> +
> static void handleColdAttr(Sema &S, Decl *D, const AttributeList &Attr) {
>   // Check the attribute arguments.
>   if (!checkAttributeNumArgs(S, Attr, 0))
> @@ -4285,6 +4299,9 @@
>   case AttributeList::AT_ExtVectorType:
>     handleExtVectorTypeAttr(S, scope, D, Attr);
>     break;
> +  case AttributeList::AT_ForceSizeOpt:
> +    handleForceSizeOptAttr(S, D, Attr);
> +    break;
>   case AttributeList::AT_Format:      handleFormatAttr      (S, D, Attr); break;
>   case AttributeList::AT_FormatArg:   handleFormatArgAttr   (S, D, Attr); break;
>   case AttributeList::AT_CUDAGlobal:  handleGlobalAttr      (S, D, Attr); break;
> 
> Modified: cfe/trunk/test/CodeGen/attr-forcesizeopt.c
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/attr-forcesizeopt.c?rev=166946&r1=166945&r2=166946&view=diff
> ==============================================================================
> --- cfe/trunk/test/CodeGen/attr-forcesizeopt.c (original)
> +++ cfe/trunk/test/CodeGen/attr-forcesizeopt.c Mon Oct 29 12:56:23 2012
> @@ -24,3 +24,8 @@
> // OTHER-NOT: forcesizeopt
> // OTHER: ret
> }
> +
> +int test3() __attribute__((forcesizeopt)) {
> +// Oz: @test3{{.*}}forcesizeopt
> +// OTHER: @test3{{.*}}forcesizeopt
> +}
> 
> 
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits




More information about the cfe-commits mailing list