<p dir="ltr">LGTM. </p>
<br><div class="gmail_quote"><div dir="ltr">On Fri, Jan 22, 2016, 4:56 PM Easwaran Raman via llvm-commits <<a href="mailto:llvm-commits@lists.llvm.org">llvm-commits@lists.llvm.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">eraman created this revision.<br>
eraman added a reviewer: hfinkel.<br>
eraman added a subscriber: llvm-commits.<br>
<br>
When the caller has optsize attribute, we reduce the inlinining threshold to OptSizeThreshold (=75) if it is not already lower than that. We don't do the same for minsize and I suspect it was not intentional. This also addresses a FIXME regarding checking optsize attribute explicitly instead of using the right wrapper.<br>
<br>
<br>
<br>
<a href="http://reviews.llvm.org/D16493" rel="noreferrer" target="_blank">http://reviews.llvm.org/D16493</a><br>
<br>
Files:<br>
  lib/Analysis/InlineCost.cpp<br>
  test/Transforms/Inline/inline-optsize.ll<br>
<br>
Index: test/Transforms/Inline/inline-optsize.ll<br>
===================================================================<br>
--- test/Transforms/Inline/inline-optsize.ll<br>
+++ test/Transforms/Inline/inline-optsize.ll<br>
@@ -1,5 +1,6 @@<br>
 ; RUN: opt -S -Oz < %s | FileCheck %s -check-prefix=OZ<br>
 ; RUN: opt -S -O2 < %s | FileCheck %s -check-prefix=O2<br>
+; RUN: opt -S -Os < %s | FileCheck %s -check-prefix=OS<br>
<br>
 ; The inline threshold for a function with the optsize attribute is currently<br>
 ; the same as the global inline threshold for -Os. Check that the optsize<br>
@@ -24,10 +25,20 @@<br>
   ret i32 %x5<br>
 }<br>
<br>
-; @inner() should be inlined for -O2 but not for -Oz.<br>
+; @inner() should be inlined for -O2 and -Os but not for -Oz.<br>
 ; OZ: call<br>
 ; O2-NOT: call<br>
+; OS-NOT: call<br>
 define i32 @outer() optsize {<br>
    %r = call i32 @inner()<br>
    ret i32 %r<br>
 }<br>
+<br>
+; @inner() should not be inlined for -O2, -Os and -Oz.<br>
+; OZ: call<br>
+; O2: call<br>
+; OS: call<br>
+define i32 @outer2() minsize {<br>
+   %r = call i32 @inner()<br>
+   ret i32 %r<br>
+}<br>
Index: lib/Analysis/InlineCost.cpp<br>
===================================================================<br>
--- lib/Analysis/InlineCost.cpp<br>
+++ lib/Analysis/InlineCost.cpp<br>
@@ -573,16 +573,16 @@<br>
 }<br>
<br>
 void CallAnalyzer::updateThreshold(CallSite CS, Function &Callee) {<br>
-  // If -inline-threshold is not given, listen to the optsize attribute when it<br>
-  // would decrease the threshold.<br>
+  // If -inline-threshold is not given, listen to the optsize and minsize<br>
+  // attributes when they would decrease the threshold.<br>
   Function *Caller = CS.getCaller();<br>
<br>
-  // FIXME: Use Function::optForSize()<br>
-  bool OptSize = Caller->hasFnAttribute(Attribute::OptimizeForSize);<br>
-<br>
-  if (!(DefaultInlineThreshold.getNumOccurrences() > 0) && OptSize &&<br>
-      OptSizeThreshold < Threshold)<br>
-    Threshold = OptSizeThreshold;<br>
+  if (!(DefaultInlineThreshold.getNumOccurrences() > 0)) {<br>
+    if (Caller->optForMinSize() && OptMinSizeThreshold < Threshold)<br>
+      Threshold = OptMinSizeThreshold;<br>
+    else if (Caller->optForSize() && OptSizeThreshold < Threshold)<br>
+      Threshold = OptSizeThreshold;<br>
+  }<br>
<br>
   // If profile information is available, use that to adjust threshold of hot<br>
   // and cold functions.<br>
<br>
<br>
_______________________________________________<br>
llvm-commits mailing list<br>
<a href="mailto:llvm-commits@lists.llvm.org" target="_blank">llvm-commits@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits</a><br>
</blockquote></div>