mirror of
https://github.com/RPCS3/llvm.git
synced 2025-02-25 05:10:56 +00:00
[XRay] Allow logging the first argument of a function call.
Summary: Functions with the "xray-log-args" attribute will have a special XRay sled kind emitted, for compiler-rt to copy any call arguments to your logging handler. For practical and performance reasons, only the first argument is supported, and only up to 64 bits. Reviewers: dberris Reviewed By: dberris Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D29702 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@296998 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
9eb5f1b207
commit
8c95619c81
@ -222,6 +222,7 @@ public:
|
||||
FUNCTION_ENTER = 0,
|
||||
FUNCTION_EXIT = 1,
|
||||
TAIL_CALL = 2,
|
||||
LOG_ARGS_ENTER = 3,
|
||||
};
|
||||
|
||||
// The table will contain these structs that point to the sled, the function
|
||||
|
@ -2756,8 +2756,11 @@ void AsmPrinter::recordSled(MCSymbol *Sled, const MachineInstr &MI,
|
||||
SledKind Kind) {
|
||||
auto Fn = MI.getParent()->getParent()->getFunction();
|
||||
auto Attr = Fn->getFnAttribute("function-instrument");
|
||||
bool LogArgs = Fn->hasFnAttribute("xray-log-args");
|
||||
bool AlwaysInstrument =
|
||||
Attr.isStringAttribute() && Attr.getValueAsString() == "xray-always";
|
||||
if (Kind == SledKind::FUNCTION_ENTER && LogArgs)
|
||||
Kind = SledKind::LOG_ARGS_ENTER;
|
||||
Sleds.emplace_back(
|
||||
XRayFunctionEntry{ Sled, CurrentFnSym, Kind, AlwaysInstrument, Fn });
|
||||
}
|
||||
|
35
test/CodeGen/X86/xray-log-args.ll
Normal file
35
test/CodeGen/X86/xray-log-args.ll
Normal file
@ -0,0 +1,35 @@
|
||||
; When logging arguments is specified, emit the entry sled accordingly.
|
||||
|
||||
; RUN: llc -filetype=asm -o - -mtriple=x86_64-unknown-linux-gnu < %s | FileCheck %s
|
||||
; RUN: llc -filetype=asm -o - -mtriple=x86_64-darwin-unknown < %s | FileCheck %s
|
||||
|
||||
define i32 @callee(i32 %arg) nounwind noinline uwtable "function-instrument"="xray-always" "xray-log-args"="1" {
|
||||
ret i32 %arg
|
||||
}
|
||||
; CHECK-LABEL: Lxray_synthetic_0:
|
||||
; CHECK: .quad {{\.?}}Lxray_sled_0
|
||||
; CHECK: .quad {{_?}}callee
|
||||
; CHECK: .byte 3
|
||||
; CHECK: .byte 1
|
||||
; CHECK: .{{(zero|space)}} 14
|
||||
; CHECK: .quad {{\.?}}Lxray_sled_1
|
||||
; CHECK: .quad {{_?}}callee
|
||||
; CHECK: .byte 1
|
||||
; CHECK: .byte 1
|
||||
; CHECK: .{{(zero|space)}} 14
|
||||
|
||||
define i32 @caller(i32 %arg) nounwind noinline uwtable "function-instrument"="xray-always" "xray-log-args"="1" {
|
||||
%retval = tail call i32 @callee(i32 %arg)
|
||||
ret i32 %retval
|
||||
}
|
||||
; CHECK-LABEL: Lxray_synthetic_1:
|
||||
; CHECK: .quad {{\.?}}Lxray_sled_2
|
||||
; CHECK: .quad {{_?}}caller
|
||||
; CHECK: .byte 3
|
||||
; CHECK: .byte 1
|
||||
; CHECK: .{{(zero|space)}} 14
|
||||
; CHECK: .quad {{\.?}}Lxray_sled_3
|
||||
; CHECK: .quad {{_?}}caller
|
||||
; CHECK: .byte 2
|
||||
; CHECK: .byte 1
|
||||
; CHECK: .{{(zero|space)}} 14
|
Loading…
x
Reference in New Issue
Block a user