Skip to content

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

Open
@quininer

Description

@quininer
__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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions