<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/121135>121135</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
ARM32: Missing gprof support
</td>
</tr>
<tr>
<th>Labels</th>
<td>
backend:ARM
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
wzssyqa
</td>
</tr>
</table>
<pre>
```
int fib(int n) {return n <=1 ? 1 : fib(n-1) + fib(n-2); }
int main() {fib(10); return 0;}
```
How to test native:
```
bin/clang -pg test.c && ./a.out && gprof -b a.out gmon.out
```
How to test cross with qemu-user
```
apt install gcc-arm-linux-gnueabi gcc-arm-linux-gnueabihf
bin/clang --target=arm-linux-gnueabi -pg test.c -static && ./a.out && gprof -b a.out gmon.out
bin/clang --target=arm-linux-gnueabihf -pg test.c -static && ./a.out && gprof -b a.out gmon.out
```
Known problem:
```
$ bin/clang --target=arm-linux-gnueabi -pg test.c -static && ./a.out && gprof -b a.out gmon.out
Flat profile:
Each sample counts as 0.01 seconds.
no time accumulated
% cumulative self self total
time seconds seconds calls Ts/call Ts/call name
Call graph
granularity: each sample hit covers 2 byte(s) no time propagated
index % time self children called name
1 main [130]
[130] 0.0 0.00 0.00 0+1 main [130]
1 main [130]
-----------------------------------------------
Index by function name
```
```
$ bin/clang --target=arm-linux-gnueabihf -pg test.c -static && ./a.out && gprof -b a.out gmon.out
/usr/bin/arm-linux-gnueabihf-ld: /tmp/n-9e8be5.o: in function `fib':
n.c:(.text+0xc): undefined reference to `mcount'
/usr/bin/arm-linux-gnueabihf-ld: /tmp/n-9e8be5.o: in function `main':
n.c:(.text+0x4c): undefined reference to `mcount'
clang: error: linker command failed with exit code 1 (use -v to see invocation)
```
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJy8Vl-PpDYM_zSZFwsUwsAMDzzM3Ba1qvbl1C8QgoH0QsLlz-xuP30VYPbP7F3bO60aIbBMbP9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