[llvm-commits] [PATCH] optsize attribute on top of -Oz gives bigger code

Patrik Hägglund H patrik.h.hagglund at ericsson.com
Thu Mar 22 00:56:48 PDT 2012


> Could you give some metrics to go along with the patch? You should be able to measure the impact on the LLVM test suite.

Well, the few times I have tried to execute the test suite, it have failed in one way or another. (On SLED 11 and Debian unstable). But maybe its time to give it another try.

BTW, what's the purpose of the metrics? My thinking was that this is more an issue about how you define the optsize attribute. In my opinion adding optisize should not make any impact  on the code size when using clang -Os or -Oz. At least the code should not be larger, but not smaller either. That is, the code should be identical. That is what this patch tries to fix (with the regard to the inliner). If the code shouldn't be identical, exactly what is the definiton of the optsize attribute, relative to clang -Os and -Oz (or other potential users of the LLVM libraries passing similar information)?

> A comment on the patch itself:

I like consistency. The logic mirrors the order in the comment, and InlineLimit.getNumOccurrences() > 0 is used because it is also used in the constructor. But I can change that part if you like.

/Patrik Hägglund

-----Original Message-----
From: Bill Wendling [mailto:wendling at apple.com] 
Sent: den 22 mars 2012 08:10
To: Patrik Hägglund H
Cc: llvm-commits at cs.uiuc.edu
Subject: Re: [llvm-commits] [PATCH] optsize attribute on top of -Oz gives bigger code

Hi Patrik,

The patch looks okay overall. Could you give some metrics to go along with the patch? You should be able to measure the impact on the LLVM test suite.

A comment on the patch itself:

+  if (!(InlineLimit.getNumOccurrences() > 0) && OptSize && OptSizeThreshold < thres)

The logic could be made better (and more readable). Please use this instead:

+  if (OptSize && OptSizeThreshold < thres && InlineLimit.getNumOccurrences() == 0)

-bw

On Mar 20, 2012, at 6:30 AM, Patrik Hägglund H wrote:

> Hi,
> 
> I found that using clang -Oz, used as a backend for .ll files, combined with using the optsize attribute, then optsize _increased_ the code size.
> 
> The base inline threshold was 25 with clang -Oz, but 75 when adding the optsize attribute.
> 
> This patch fix this to only change the inline threshold for a function with optsize if it lowers the base threshold.
> 
> /Patrik Hägglund
> 
> <optsize_inliner.diff>_______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits





More information about the llvm-commits mailing list