Skip to content

xray incorrectly generates tailcall sled kind as exit kind in aarch64 target #141051

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
quininer opened this issue May 22, 2025 · 0 comments
Open
Labels

Comments

@quininer
Copy link

__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

clang foo.c -shared -O2 -fxray-instrument -fxray-instruction-threshold=1 -fuse-ld=lld -nostdlib

output

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.

$ 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants