<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 file format of sample profile is inconsistent with AutoFDO"
href="https://bugs.llvm.org/show_bug.cgi?id=41190">41190</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>The file format of sample profile is inconsistent with AutoFDO
</td>
</tr>
<tr>
<th>Product</th>
<td>libraries
</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>enhancement
</td>
</tr>
<tr>
<th>Priority</th>
<td>P
</td>
</tr>
<tr>
<th>Component</th>
<td>Scalar Optimizations
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>cszide@163.com
</td>
</tr>
<tr>
<th>CC</th>
<td>llvm-bugs@lists.llvm.org
</td>
</tr></table>
<p>
<div>
<pre>Created <span class=""><a href="attachment.cgi?id=21645" name="attach_21645" title="the source file">attachment 21645</a> <a href="attachment.cgi?id=21645&action=edit" title="the source file">[details]</a></span>
the source file
As described in documents, the file format of sample profile in llvm is as
follows.
// Sample profiles are written as ASCII text. The file is divided into
// sections, which correspond to each of the functions executed at runtime.
// Each section has the following format
//
// function1:total_samples:total_head_samples
// offset1[.discriminator]: number_of_samples [fn1:num fn2:num ... ]
// offset2[.discriminator]: number_of_samples [fn3:num fn4:num ... ]
// ...
// offsetN[.discriminator]: number_of_samples [fn5:num fn6:num ... ]
// offsetA[.discriminator]: fnA:num_of_total_samples
// offsetA1[.discriminator]: number_of_samples [fn7:num fn8:num ... ]
// ...
//
Source line offset represents the line number in the function where the sample
was collected. The line number is always relative to the line where symbol of
the function is defined. So, if the function has its header at line 280, the
offset 13 is at line 293 in the file.
However, when I use AutoFDO to generate the sample profile of a program, I find
the file format is inconsistent with llvm. For example, the following is the
text format of sample profile of a function generated by AutoFDO.
Bubble:307889687:0
145: 0
147: 0
148: 0
150: 826
152: 814
153: 3396010
155: 3386796
156: 1921076
157: 1921072
158: 1921072
160: 3396018
163: 826
165: 0
166: 0
168: 0
The source code of this function is as follows. The number before each line is
the line number in the source file.
145 void Bubble(int run) {
146 int i, j;
147 bInitarr();
148 top = sortelements;
149
150 while (top > 1) {
151
152 i = 1;
153 while (i < top) {
154
155 if (sortlist[i] > sortlist[i + 1]) {
156 j = sortlist[i];
157 sortlist[i] = sortlist[i + 1];
158 sortlist[i + 1] = j;
159 }
160 i = i + 1;
161 }
162
163 top = top - 1;
164 }
165 if ((sortlist[1] != littlest) || (sortlist[sortelements] != biggest))
166 printf("Error3 in Bubble.\n");
167 // printf("%d\n", sortlist[run + 1]);
168 }
Obviously, in AutoFDO, the source line offset is the line number in the source
file. Thus, when I use '-sample-profile' pass (or -fprofile-sample-use of
clang) to annotate the profile information in IR file, the result is not
correct.
The following are my steps.
$clang -gline-tables-only Bubblesort.c -o bubb
$perf record -b ./bubb
$create_llvm_prof --binary=./bubb --out=bubb.prof
$clang -gline-tables-only -fprofile-sample-use=bubb.prof -emit-llvm -c
Bubblesort.c -o bubb.bc
or
$clang -gline-tables-only -emit-llvm -c Bubblesort.c -o bubb1.bc
#opt -sample-profile -sample-profile-file=bubb.prof bubb1.bc -o bubb.bc</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>