<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 - The -finstrument-functions is not enabled with -O0"
href="https://bugs.llvm.org/show_bug.cgi?id=49143">49143</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>The -finstrument-functions is not enabled with -O0
</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>Linux
</td>
</tr>
<tr>
<th>Status</th>
<td>NEW
</td>
</tr>
<tr>
<th>Severity</th>
<td>normal
</td>
</tr>
<tr>
<th>Priority</th>
<td>P
</td>
</tr>
<tr>
<th>Component</th>
<td>Driver
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedclangbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>adhemerval.zanella@linaro.org
</td>
</tr>
<tr>
<th>CC</th>
<td>llvm-bugs@lists.llvm.org, neeilans@live.com, richard-llvm@metafoo.co.uk
</td>
</tr></table>
<p>
<div>
<pre>The 'foo' function below is not instrumented when built with -O0, only when
using higher optimization options (such as -O1):
---
$ ./bin/clang -v 2>&1 | head -n2
clang version 13.0.0 (<a href="https://github.com/llvm/llvm-project.git">https://github.com/llvm/llvm-project.git</a>
90081f3020e38727eb30506d052cbb4e3a489eb6)
Target: aarch64-unknown-linux-gnu
$ cat test.c
void foo ()
{
}
static int count;
__attribute__ ((noinline)) __attribute__ ((no_instrument_function))
void __cyg_profile_func_enter (void *fn, void *parent)
{
count++;
}
__attribute__ ((noinline)) __attribute__ ((no_instrument_function))
void __cyg_profile_func_exit (void *fn, void *parent)
{
count++;
}
$ ./bin/clang -O0 -finstrument-functions -S -emit-llvm test.c -S -o - | head -n
12
$ ./bin/clang -O1 -finstrument-functions -S -emit-llvm test.c -S -o - | head -n
14
; ModuleID = 'test.c'
source_filename = "test.c"
target datalayout = "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128"
target triple = "aarch64-unknown-linux-gnu"
@count = internal unnamed_addr global i32 0, align 4
; Function Attrs: nofree norecurse nounwind uwtable willreturn
define dso_local void @foo() local_unnamed_addr #0 {
entry:
call void @__cyg_profile_func_enter(i8* undef, i8* undef)
call void @__cyg_profile_func_exit(i8* undef, i8* undef)
ret void
}</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>