<html>
    <head>
      <base href="http://llvm.org/bugs/" />
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW --- - -Os increases size because it includes -inline"
   href="http://llvm.org/bugs/show_bug.cgi?id=15561">15561</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>-Os increases size because it includes -inline
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>clang
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>3.2
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>PC
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>Linux
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>normal
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>Driver
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedclangbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>antoinep92@gmail.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvmbugs@cs.uiuc.edu
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Created <span class=""><a href="attachment.cgi?id=10218" name="attach_10218" title="Generates huge binary with -Os">attachment 10218</a> <a href="attachment.cgi?id=10218&action=edit" title="Generates huge binary with -Os">[details]</a></span>
Generates huge binary with -Os

Optimization levels -Os and -Oz are supposed to optimize for size, but they are
exactly equivalent to -O2 (as from llvm-as < /dev/null | opt -O...
-disable-output -debug-pass=Arguments)

The problem is that these optimization levels include the -inline optimization
pass which increases the executable size.

For instance, the attached file produces 40x *bigger* binary when compiled with
-Os than with -O0.

clang -Wall -std=c++11 -fconstexpr-depth=65536 -ftemplate-depth=65536 -g0 -s
-O0
<span class="quote">> 96408 bytes (96K)</span >

clang -Wall -std=c++11 -fconstexpr-depth=65536 -ftemplate-depth=65536 -g0 -s
-Os
<span class="quote">> 4024472 bytes (4M)</span >

Trying different optimization options, I found that the origin of the increased
size is (excessive?) inlining from (-inilne). Although this test-case is
extreme, I don't think -inline should be included in -Os.</pre>
        </div>
      </p>
      <hr>
      <span>You are receiving this mail because:</span>
      
      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>