[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:
|
2017-09-04 13:34:58 +08:00
|
|
|
; CHECK: .ascii "\353\t"
|
[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-NEXT: nopw 512(%rax,%rax)
|
|
|
|
ret i32 0
|
|
|
|
; CHECK: .p2align 1, 0x90
|
|
|
|
; CHECK-LABEL: Lxray_sled_1:
|
2017-09-04 13:34:58 +08:00
|
|
|
; CHECK: retq
|
[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-NEXT: nopw %cs:512(%rax,%rax)
|
|
|
|
}
|
2017-09-04 13:34:58 +08:00
|
|
|
; CHECK-LABEL: xray_instr_map
|
2017-06-21 14:39:42 +08:00
|
|
|
; CHECK-LABEL: Lxray_sleds_start0:
|
2016-11-23 10:07:04 +08:00
|
|
|
; CHECK: .quad {{.*}}xray_sled_0
|
|
|
|
; CHECK: .quad {{.*}}xray_sled_1
|
2017-06-21 14:39:42 +08:00
|
|
|
; CHECK-LABEL: Lxray_sleds_end0:
|
2017-09-04 13:34:58 +08:00
|
|
|
; CHECK-LABEL: xray_fn_idx
|
2017-06-21 14:39:42 +08:00
|
|
|
; CHECK: .quad {{.*}}xray_sleds_start0
|
|
|
|
; CHECK-NEXT: .quad {{.*}}xray_sleds_end0
|
[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:
|
2017-09-04 13:34:58 +08:00
|
|
|
; CHECK: .ascii "\353\t"
|
[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-NEXT: nopw 512(%rax,%rax)
|
|
|
|
; CHECK: .p2align 1, 0x90
|
|
|
|
; CHECK-LABEL: Lxray_sled_3:
|
|
|
|
; CHECK-NEXT: .ascii "\353\t"
|
|
|
|
; CHECK-NEXT: nopw 512(%rax,%rax)
|
|
|
|
%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
|
|
|
|
}
|
2017-09-04 13:34:58 +08:00
|
|
|
; CHECK-LABEL: xray_instr_map
|
2017-06-21 14:39:42 +08:00
|
|
|
; CHECK-LABEL: Lxray_sleds_start1:
|
2016-11-23 10:07:04 +08:00
|
|
|
; CHECK: .quad {{.*}}xray_sled_2
|
|
|
|
; CHECK: .quad {{.*}}xray_sled_3
|
2017-06-21 14:39:42 +08:00
|
|
|
; CHECK-LABEL: Lxray_sleds_end1:
|
2017-09-04 13:34:58 +08:00
|
|
|
; CHECK-LABEL: xray_fn_idx
|
2017-06-21 14:39:42 +08:00
|
|
|
; CHECK: .quad {{.*}}xray_sleds_start1
|
|
|
|
; CHECK: .quad {{.*}}xray_sleds_end1
|