<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 - clang should not generate counting function for functions with no_instrument_function attribute."
   href="https://bugs.llvm.org/show_bug.cgi?id=33515">33515</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>clang should not  generate counting function for functions with no_instrument_function attribute.
          </td>
        </tr>

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

        <tr>
          <th>Version</th>
          <td>unspecified
          </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>enhancement
          </td>
        </tr>

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

        <tr>
          <th>Component</th>
          <td>LLVM Codegen
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>manojgupta@google.com
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>manojgupta@google.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>When -pg is used, clang generates counting functions even for functions with
no_instrument_function attribute.

This results in a Linux kernel crash when function tracing is enabled in Chrome
OS.

GCC behavior is to not generate any counting functions with
no_instrument_function attribute.
Apparently, this is also desired in clang according to the comment in
SemaDeclAttr.cpp but the implementation is broken.

llvm/tools/clang/lib/Sema/SemaDeclAttr.cpp:  case
AttributeList::AT_NoInstrumentFunction: // Interacts with -pg.

$ cat pg.c
__attribute__((no_instrument_function)) void foo()
{
}

$ clang pg.c -c -pg -target aarch64-unknown-linux-gnu
$ aarch64-linux-gnu-objdump -d pg.o
Disassembly of section .text:

00000000 <foo>:
   0:   e92d4800        push    {fp, lr}
   4:   e1a0b00d        mov     fp, sp
   8:   ebfffffe        bl      0 <_mcount> // _mcount should not be generated
   c:   e8bd8800        pop     {fp, pc}</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>