[XRay] Detect and emit sleds for sibling/tail calls
Summary:
This change promotes the 'isTailCall(...)' member function to
TargetInstrInfo as a query interface for determining on a per-target
basis whether a given MachineInstr is a tail call instruction. We build
upon this in the XRay instrumentation pass to emit special sleds for
tail call optimisations, where we emit the correct kind of sled.
The tail call sleds look like a mix between the function entry and
function exit sleds. Form-wise, the sled comes before the "jmp"
instruction that implements the tail call similar to how we do it for
the function entry sled. Functionally, because we know this is a tail
call, it behaves much like an exit sled -- i.e. at runtime we may use
the exit trampolines instead of a different kind of trampoline.
A follow-up change to recognise these sleds will be done in compiler-rt,
so that we can start intercepting these initially as exits, but also
have the option to have different log entries to more accurately reflect
that this is actually a tail call.
Reviewers: echristo, rSerge, majnemer
Subscribers: mehdi_amini, dberris, llvm-commits
Differential Revision: https://reviews.llvm.org/D23986
llvm-svn: 280334
2016-09-01 09:29:13 +08:00
|
|
|
; RUN: llc -filetype=asm -o - -mtriple=x86_64-unknown-linux-gnu < %s | FileCheck %s
|
2016-11-23 10:07:04 +08:00
|
|
|
; RUN: llc -filetype=asm -o - -mtriple=x86_64-darwin-unknown < %s | FileCheck %s
|
[XRay] Detect and emit sleds for sibling/tail calls
Summary:
This change promotes the 'isTailCall(...)' member function to
TargetInstrInfo as a query interface for determining on a per-target
basis whether a given MachineInstr is a tail call instruction. We build
upon this in the XRay instrumentation pass to emit special sleds for
tail call optimisations, where we emit the correct kind of sled.
The tail call sleds look like a mix between the function entry and
function exit sleds. Form-wise, the sled comes before the "jmp"
instruction that implements the tail call similar to how we do it for
the function entry sled. Functionally, because we know this is a tail
call, it behaves much like an exit sled -- i.e. at runtime we may use
the exit trampolines instead of a different kind of trampoline.
A follow-up change to recognise these sleds will be done in compiler-rt,
so that we can start intercepting these initially as exits, but also
have the option to have different log entries to more accurately reflect
that this is actually a tail call.
Reviewers: echristo, rSerge, majnemer
Subscribers: mehdi_amini, dberris, llvm-commits
Differential Revision: https://reviews.llvm.org/D23986
llvm-svn: 280334
2016-09-01 09:29:13 +08:00
|
|
|
|
|
|
|
define i32 @callee() nounwind noinline uwtable "function-instrument"="xray-always" {
|
|
|
|
; CHECK: .p2align 1, 0x90
|
|
|
|
; CHECK-LABEL: Lxray_sled_0:
|
|
|
|
; CHECK-NEXT: .ascii "\353\t"
|
|
|
|
; CHECK-NEXT: nopw 512(%rax,%rax)
|
|
|
|
; CHECK-LABEL: Ltmp0:
|
|
|
|
ret i32 0
|
|
|
|
; CHECK: .p2align 1, 0x90
|
|
|
|
; CHECK-LABEL: Lxray_sled_1:
|
|
|
|
; CHECK-NEXT: retq
|
|
|
|
; CHECK-NEXT: nopw %cs:512(%rax,%rax)
|
|
|
|
}
|
|
|
|
; CHECK: .p2align 4, 0x90
|
2016-11-23 10:07:04 +08:00
|
|
|
; CHECK-NEXT: .quad {{.*}}xray_synthetic_0
|
|
|
|
; CHECK-NEXT: .section {{.*}}xray_instr_map
|
[XRay] Detect and emit sleds for sibling/tail calls
Summary:
This change promotes the 'isTailCall(...)' member function to
TargetInstrInfo as a query interface for determining on a per-target
basis whether a given MachineInstr is a tail call instruction. We build
upon this in the XRay instrumentation pass to emit special sleds for
tail call optimisations, where we emit the correct kind of sled.
The tail call sleds look like a mix between the function entry and
function exit sleds. Form-wise, the sled comes before the "jmp"
instruction that implements the tail call similar to how we do it for
the function entry sled. Functionally, because we know this is a tail
call, it behaves much like an exit sled -- i.e. at runtime we may use
the exit trampolines instead of a different kind of trampoline.
A follow-up change to recognise these sleds will be done in compiler-rt,
so that we can start intercepting these initially as exits, but also
have the option to have different log entries to more accurately reflect
that this is actually a tail call.
Reviewers: echristo, rSerge, majnemer
Subscribers: mehdi_amini, dberris, llvm-commits
Differential Revision: https://reviews.llvm.org/D23986
llvm-svn: 280334
2016-09-01 09:29:13 +08:00
|
|
|
; CHECK-LABEL: Lxray_synthetic_0:
|
2016-11-23 10:07:04 +08:00
|
|
|
; CHECK: .quad {{.*}}xray_sled_0
|
|
|
|
; CHECK: .quad {{.*}}xray_sled_1
|
[XRay] Detect and emit sleds for sibling/tail calls
Summary:
This change promotes the 'isTailCall(...)' member function to
TargetInstrInfo as a query interface for determining on a per-target
basis whether a given MachineInstr is a tail call instruction. We build
upon this in the XRay instrumentation pass to emit special sleds for
tail call optimisations, where we emit the correct kind of sled.
The tail call sleds look like a mix between the function entry and
function exit sleds. Form-wise, the sled comes before the "jmp"
instruction that implements the tail call similar to how we do it for
the function entry sled. Functionally, because we know this is a tail
call, it behaves much like an exit sled -- i.e. at runtime we may use
the exit trampolines instead of a different kind of trampoline.
A follow-up change to recognise these sleds will be done in compiler-rt,
so that we can start intercepting these initially as exits, but also
have the option to have different log entries to more accurately reflect
that this is actually a tail call.
Reviewers: echristo, rSerge, majnemer
Subscribers: mehdi_amini, dberris, llvm-commits
Differential Revision: https://reviews.llvm.org/D23986
llvm-svn: 280334
2016-09-01 09:29:13 +08:00
|
|
|
|
|
|
|
define i32 @caller() nounwind noinline uwtable "function-instrument"="xray-always" {
|
|
|
|
; CHECK: .p2align 1, 0x90
|
|
|
|
; CHECK-LABEL: Lxray_sled_2:
|
|
|
|
; CHECK-NEXT: .ascii "\353\t"
|
|
|
|
; CHECK-NEXT: nopw 512(%rax,%rax)
|
|
|
|
; CHECK-LABEL: Ltmp1:
|
|
|
|
; CHECK: .p2align 1, 0x90
|
|
|
|
; CHECK-LABEL: Lxray_sled_3:
|
|
|
|
; CHECK-NEXT: .ascii "\353\t"
|
|
|
|
; CHECK-NEXT: nopw 512(%rax,%rax)
|
|
|
|
; CHECK-LABEL: Ltmp2:
|
|
|
|
%retval = tail call i32 @callee()
|
2016-11-23 10:07:04 +08:00
|
|
|
; CHECK: jmp {{.*}}callee {{.*}}# TAILCALL
|
[XRay] Detect and emit sleds for sibling/tail calls
Summary:
This change promotes the 'isTailCall(...)' member function to
TargetInstrInfo as a query interface for determining on a per-target
basis whether a given MachineInstr is a tail call instruction. We build
upon this in the XRay instrumentation pass to emit special sleds for
tail call optimisations, where we emit the correct kind of sled.
The tail call sleds look like a mix between the function entry and
function exit sleds. Form-wise, the sled comes before the "jmp"
instruction that implements the tail call similar to how we do it for
the function entry sled. Functionally, because we know this is a tail
call, it behaves much like an exit sled -- i.e. at runtime we may use
the exit trampolines instead of a different kind of trampoline.
A follow-up change to recognise these sleds will be done in compiler-rt,
so that we can start intercepting these initially as exits, but also
have the option to have different log entries to more accurately reflect
that this is actually a tail call.
Reviewers: echristo, rSerge, majnemer
Subscribers: mehdi_amini, dberris, llvm-commits
Differential Revision: https://reviews.llvm.org/D23986
llvm-svn: 280334
2016-09-01 09:29:13 +08:00
|
|
|
ret i32 %retval
|
|
|
|
}
|
|
|
|
; CHECK: .p2align 4, 0x90
|
2016-11-23 10:07:04 +08:00
|
|
|
; CHECK-NEXT: .quad {{.*}}xray_synthetic_1
|
[XRay] Detect and emit sleds for sibling/tail calls
Summary:
This change promotes the 'isTailCall(...)' member function to
TargetInstrInfo as a query interface for determining on a per-target
basis whether a given MachineInstr is a tail call instruction. We build
upon this in the XRay instrumentation pass to emit special sleds for
tail call optimisations, where we emit the correct kind of sled.
The tail call sleds look like a mix between the function entry and
function exit sleds. Form-wise, the sled comes before the "jmp"
instruction that implements the tail call similar to how we do it for
the function entry sled. Functionally, because we know this is a tail
call, it behaves much like an exit sled -- i.e. at runtime we may use
the exit trampolines instead of a different kind of trampoline.
A follow-up change to recognise these sleds will be done in compiler-rt,
so that we can start intercepting these initially as exits, but also
have the option to have different log entries to more accurately reflect
that this is actually a tail call.
Reviewers: echristo, rSerge, majnemer
Subscribers: mehdi_amini, dberris, llvm-commits
Differential Revision: https://reviews.llvm.org/D23986
llvm-svn: 280334
2016-09-01 09:29:13 +08:00
|
|
|
; CHECK-LABEL: Lxray_synthetic_1:
|
2016-11-23 10:07:04 +08:00
|
|
|
; CHECK: .quad {{.*}}xray_sled_2
|
|
|
|
; CHECK: .quad {{.*}}xray_sled_3
|