<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 - Implement __attribute__((noipa)) to make a function a black box for interprocedural optimizations"
   href="https://bugs.llvm.org/show_bug.cgi?id=41474">41474</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Implement __attribute__((noipa)) to make a function a black box for interprocedural optimizations
          </td>
        </tr>

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

        <tr>
          <th>Version</th>
          <td>trunk
          </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>unassignedclangbugs@nondot.org
          </td>
        </tr>

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

        <tr>
          <th>CC</th>
          <td>htmldeveloper@gmail.com, llvm-bugs@lists.llvm.org, neeilans@live.com, richard-llvm@metafoo.co.uk
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Currently, Clang will always optimize this to `return 3`:

static int inner(int a) {
    return a + 1;
}
int outer() {
    return inner(2);
}

Notably, this happens even if inner is marked `noinline`, because of the
Interprocedural Sparse Conditional Constant Propagation pass.

This is unhelpful for various use cases, including:
- testing the compiler's code generation
- defining a dummy function whose purpose is to be a place to break in a
debugger

GCC has a function attribute `noipa`, whose effect is (to quote the manual):

<span class="quote">> Disable interprocedural optimizations between the function with this attribute and its callers, as if the body of the function is not available when optimizing callers and the callers are unavailable when optimizing the body.</span >

It would be good to support this in LLVM/Clang as well.</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>