r182666 - [PATCH] Generate cold attribute for functions marked __atribute__((cold))

Richard Smith richard at metafoo.co.uk
Fri May 24 13:31:47 PDT 2013


On Fri, May 24, 2013 at 1:18 PM, Diego Novillo <dnovillo at google.com> wrote:

> Author: dnovillo
> Date: Fri May 24 15:18:15 2013
> New Revision: 182666
>
> URL: http://llvm.org/viewvc/llvm-project?rev=182666&view=rev
> Log:
> [PATCH] Generate cold attribute for functions marked __atribute__((cold))
>
> This removes a FIXME in
> CodeGenModule::SetLLVMFunctionAttributesForDefinition.
> When a function is declared cold we can now generate the IR attribute in
> addition to marking the function to be optimized for size.
>
> I tried adding a separate CHECK in the existing test, but it was
> failing.  I suppose CHECK matches one line exactly once?  This would be
> a problem if the attributes are listed in a different order, though they
> seem to be sorted.
>

Each CHECK only looks at the text after the end of the previous CHECK's
match. I believe the order in which attributes are printed is stable.


> Modified:
>     cfe/trunk/lib/CodeGen/CodeGenModule.cpp
>     cfe/trunk/test/CodeGen/attr-coldhot.c
>
> Modified: cfe/trunk/lib/CodeGen/CodeGenModule.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenModule.cpp?rev=182666&r1=182665&r2=182666&view=diff
>
> ==============================================================================
> --- cfe/trunk/lib/CodeGen/CodeGenModule.cpp (original)
> +++ cfe/trunk/lib/CodeGen/CodeGenModule.cpp Fri May 24 15:18:15 2013
> @@ -620,9 +620,10 @@ void CodeGenModule::SetLLVMFunctionAttri
>      B.addAttribute(llvm::Attribute::AlwaysInline);
>    }
>
> -  // FIXME: Communicate hot and cold attributes to LLVM more directly.
> -  if (D->hasAttr<ColdAttr>())
> +  if (D->hasAttr<ColdAttr>()) {
>      B.addAttribute(llvm::Attribute::OptimizeForSize);
> +    B.addAttribute(llvm::Attribute::Cold);
> +  }
>
>    if (D->hasAttr<MinSizeAttr>())
>      B.addAttribute(llvm::Attribute::MinSize);
>
> Modified: cfe/trunk/test/CodeGen/attr-coldhot.c
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/attr-coldhot.c?rev=182666&r1=182665&r2=182666&view=diff
>
> ==============================================================================
> --- cfe/trunk/test/CodeGen/attr-coldhot.c (original)
> +++ cfe/trunk/test/CodeGen/attr-coldhot.c Fri May 24 15:18:15 2013
> @@ -8,4 +8,4 @@ int test1() __attribute__((__cold__)) {
>  // CHECK: ret
>  }
>
> -// CHECK: attributes [[ATTR]] = { {{.*}}optsize{{.*}} }
> +// CHECK: attributes [[ATTR]] = { {{.*}}cold{{.*}}optsize{{.*}} }
>
>
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20130524/bc37f7a5/attachment.html>


More information about the cfe-commits mailing list