[llvm-bugs] [Bug 33515] New: clang should not generate counting function for functions with no_instrument_function attribute.

via llvm-bugs llvm-bugs at lists.llvm.org
Mon Jun 19 11:28:44 PDT 2017


https://bugs.llvm.org/show_bug.cgi?id=33515

            Bug ID: 33515
           Summary: clang should not  generate counting function for
                    functions with no_instrument_function attribute.
           Product: clang
           Version: unspecified
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: LLVM Codegen
          Assignee: manojgupta at google.com
          Reporter: manojgupta at google.com
                CC: llvm-bugs at lists.llvm.org

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}

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20170619/be0a3e11/attachment.html>


More information about the llvm-bugs mailing list