<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 - -ftime-trace Frontend timer misses Codegen Function for template functions"
href="https://bugs.llvm.org/show_bug.cgi?id=41969">41969</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>-ftime-trace Frontend timer misses Codegen Function for template functions
</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>russell_gallop@sn.scee.net
</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>Created <span class=""><a href="attachment.cgi?id=21982" name="attach_21982" title="Screenshot of chrome://tracing">attachment 21982</a> <a href="attachment.cgi?id=21982&action=edit" title="Screenshot of chrome://tracing">[details]</a></span>
Screenshot of chrome://tracing
Clang "CodeGen Function" timers from -ftime-trace for some functions falls
outside of the "Frontend" timer and thus between Frontend and Backend (see
attached screenshot). I think this should be counted under Frontend. In the
original motivating example the time between "Frontend" and "Backend" was 11%
of the overall execution time so fairly significant.
e.g. at r361164
# Apply patch to trace ALL durations however small (to allow small
reproducible)
diff --git a/llvm/lib/Support/TimeProfiler.cpp
b/llvm/lib/Support/TimeProfiler.cpp
index bc234081564..f63847a8a28 100644
--- a/llvm/lib/Support/TimeProfiler.cpp
+++ b/llvm/lib/Support/TimeProfiler.cpp
@@ -65,8 +65,8 @@ struct TimeTraceProfiler {
E.Duration = steady_clock::now() - E.Start;
// Only include sections longer than TimeTraceGranularity msec.
- if (duration_cast<microseconds>(E.Duration).count() >
TimeTraceGranularity)
- Entries.emplace_back(E);
+ //if (duration_cast<microseconds>(E.Duration).count() >
TimeTraceGranularity)
+ Entries.emplace_back(E);
// Track total time taken by each "name", but only the topmost levels of
// them; e.g. if there's a template instantiation that instantiates other
$ cat test.cpp
template <typename T> void foo(T) {}
void bar() { foo(0); }
$ clang -c -ftime-trace test.cpp
# test.json now has CodeGen Function for foo<int> between "Frontend" and
"Backend"
{
"traceEvents": [
...
{
"args": {
"detail": ""
},
"dur": 1451,
"name": "Frontend",
"ph": "X",
"pid": 1,
"tid": 0,
"ts": 3722
},
{
"args": {
"detail": "foo<int>"
},
"dur": 66,
"name": "CodeGen Function",
"ph": "X",
"pid": 1,
"tid": 0,
"ts": 5177
},
...
{
"args": {
"detail": ""
},
"dur": 2866,
"name": "Backend",
"ph": "X",
"pid": 1,
"tid": 0,
"ts": 5287
},
...
}</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>