https://llvm.org/bugs/show_bug.cgi?id=28660
Bug ID: 28660 Summary: mcount inlining bug when -pg and -O2 enabled Product: clang Version: trunk Hardware: PC OS: Linux Status: NEW Severity: normal Priority: P Component: LLVM Codegen Assignee: unassignedclangb...@nondot.org Reporter: hong.gyu....@lge.com CC: llvm-bugs@lists.llvm.org Classification: Unclassified See the simple example below. $ cat mcount-test.c int bar() { return 0; } int foo() { return bar(); } int main() { return foo(); } If the example is compiled with -pg and -O2 options. It generates the code as below: $ clang -pg -O2 -S mcount-test.c $ cat mcount-test.s (shows assembly code only ...) bar: pushq %rbp movq %rsp, %rbp callq mcount xorl %eax, %eax popq %rbp retq foo: pushq %rbp movq %rsp, %rbp callq mcount callq mcount @ (1) calling bar is inlined with mcount xorl %eax, %eax popq %rbp retq main: pushq %rbp movq %rsp, %rbp callq mcount callq mcount @ (2) calling foo is inlined with mcount callq mcount @ (3) calling bar is inlined with mcount xorl %eax, %eax popq %rbp retq As I put some comments, the problem is that function inlining is done with mcount call. bar() has a single mcount at the entry of function, but foo() has two mcount calls. It's because bar is inlined with its mcount call into foo's body. And also main() has three mcount calls because the foo() is inlined its own mcount and its body that has two mcount calls inside. This is tested on the current trunk. -- You are receiving this mail because: You are on the CC list for the bug.
_______________________________________________ llvm-bugs mailing list llvm-bugs@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs