<html>
    <head>
      <base href="https://bugs.llvm.org/">
    </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 - ThinLTO missing optimization on Globals"
   href="https://bugs.llvm.org/show_bug.cgi?id=32752">32752</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>ThinLTO missing optimization on Globals
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>new-bugs
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>unspecified
          </td>
        </tr>

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

        <tr>
          <th>OS</th>
          <td>All
          </td>
        </tr>

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

        <tr>
          <th>Severity</th>
          <td>enhancement
          </td>
        </tr>

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

        <tr>
          <th>Component</th>
          <td>new bugs
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>mehdi.amini@apple.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>This examples shows some current limitations of ThinLTO with globals:

// globalopt0.c
int g0 = 0, g1 = 22, g2;
extern void foo1(void);
int main() {
  g0 = 1;
  g1 = 22;
  g2 = 1;
  foo1();
  return g0 + g1;
}

// globalopt1.c
extern int g0, g1, g2;
void __attribute__((noinline)) foo1(void) {
  g0 = 0;
  g1 = 22;
  g2 = 4;
}


Build with:

  $ clang globalopt0.c -c -flto=thin -O3
  $ clang globalopt1.c -c -flto=thin -O3
  $ clang globalopt0.o globalopt1.o -O3 -o globalopt -Wl,-save-temps


Some potential optimizations:

- g0’s type can be changed to i1 because only two values (0 or 1) are stored to
it.
- g1 should be optimized away because only one value (22) is stored.
- g2 should be optimized away because it’s store-only.</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>