[all-commits] [llvm/llvm-project] fcffea: [XRay][X86] Handle conditional calls when lowering...

Ricky Zhou via All-commits all-commits at lists.llvm.org
Mon May 27 21:43:31 PDT 2024


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: fcffea06fdf3876dc48170d5577d7454d7303792
      https://github.com/llvm/llvm-project/commit/fcffea06fdf3876dc48170d5577d7454d7303792
  Author: Ricky Zhou <ricky at rzhou.org>
  Date:   2024-05-27 (Mon, 27 May 2024)

  Changed paths:
    M llvm/lib/Target/X86/X86MCInstLower.cpp
    M llvm/test/CodeGen/X86/xray-tail-call-sled.ll

  Log Message:
  -----------
  [XRay][X86] Handle conditional calls when lowering patchable tail calls (#89364)

xray instruments tail call function exits by inserting a nop sled before
the tail call. When tracing is enabled, the nop sled is replaced with a
call to `__xray_FunctionTailExit()`. This currently does not work for
conditional tail calls, as the instrumentation assumes that the tail
call will be unconditional. This causes two issues:
 - `__xray_FunctionTailExit()` is inappropately called even when the
   tail call is not taken.
 - `__xray_FunctionTailExit()`'s prologue/epilogue adjusts the stack
   pointer with add/sub instructions. This clobbers condition flags,
   which can flip the condition used for the tail call, leading to
   incorrect program behavior.

Fix this by rewriting conditional calls when lowering patchable tail
calls.

With this change, a conditional patchable tail call like:
```
  je target
```

Will be lowered to:
```
  jne .fallthrough
  .p2align 1, ..
.Lxray_sled_N:
  SLED_CODE
  jmp target
.fallthrough:
```



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list