<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/141051>141051</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
xray incorrectly generates tailcall sled kind as exit kind in aarch64 target
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
quininer
</td>
</tr>
</table>
<pre>
```c
__attribute__ ((noinline))
int fx(unsigned int a) {
return a + 1;
}
int foo(unsigned int a) {
return fx(a);
}
```
Compile the above code using the command
```shell
clang foo.c -shared -O2 -fxray-instrument -fxray-instruction-threshold=1 -fuse-ld=lld -nostdlib
```
output
```asm
000000000001047c <foo>:
1047c: 14000008 b 0x1049c <foo+0x20>
10480: d503201f nop
10484: d503201f nop
10488: d503201f nop
1048c: d503201f nop
10490: d503201f nop
10494: d503201f nop
10498: d503201f nop
1049c: 14000008 b 0x104bc <foo+0x40>
104a0: d503201f nop
104a4: d503201f nop
104a8: d503201f nop
104ac: d503201f nop
104b0: d503201f nop
104b4: d503201f nop
104b8: d503201f nop
104bc: 14000009 b 0x104e0 <fx@plt>
```
You can see that this generates a tail call from function `foo` to function `fx`, but it is reported as exit kind in `xray_instr_map`.
```shell
$ llvm-xray extract a.out --output=-
---
- { id: 1, address: 0x10434, function: 0x10434, kind: function-enter, always-instrument: false, function-name: '', version: 2 }
- { id: 1, address: 0x10458, function: 0x10434, kind: function-exit, always-instrument: false, function-name: '', version: 2 }
- { id: 2, address: 0x1047C, function: 0x1047C, kind: function-enter, always-instrument: false, function-name: '', version: 2 }
- { id: 2, address: 0x1049C, function: 0x1047C, kind: function-exit, always-instrument: false, function-name: '', version: 2 }
...
```
The same code and compiler arguments will correctly generate and report as tailcall kind on x86_64 linux.
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJy8ls9yq7gSxp9G3nRBCfF_wcJJbrZ3M5tZuSRojGaE5JFEQt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