2021-01-25 16:26:54 +08:00
; RUN: llc -verify-machineinstrs -mtriple=x86_64 < %s | FileCheck %s
; RUN: llc -verify-machineinstrs -mtriple=x86_64 -relocation-model=pic < %s | FileCheck %s --check-prefix=PIC
[XRay] Custom event logging intrinsic
This patch introduces an LLVM intrinsic and a target opcode for custom event
logging in XRay. Initially, its use case will be to allow users of XRay to log
some type of string ("poor man's printf"). The target opcode compiles to a noop
sled large enough to enable calling through to a runtime-determined relative
function call. At runtime, when X-Ray is enabled, the sled is replaced by
compiler-rt with a trampoline to the logic for creating the custom log entries.
Future patches will implement the compiler-rt parts and clang-side support for
emitting the IR corresponding to this intrinsic.
Reviewers: timshen, dberris
Subscribers: igorb, pelikan, rSerge, timshen, echristo, dberris, llvm-commits
Differential Revision: https://reviews.llvm.org/D27503
llvm-svn: 302405
2017-05-08 13:45:21 +08:00
2021-01-25 16:49:18 +08:00
; RUN: llc -mtriple=x86_64 -filetype=obj %s -o %t
; RUN: llvm-dwarfdump %t | FileCheck %s --check-prefix=DBG
define i32 @customevent ( ) nounwind "function-instrument" = "xray-always" !dbg !1 {
[XRay] Custom event logging intrinsic
This patch introduces an LLVM intrinsic and a target opcode for custom event
logging in XRay. Initially, its use case will be to allow users of XRay to log
some type of string ("poor man's printf"). The target opcode compiles to a noop
sled large enough to enable calling through to a runtime-determined relative
function call. At runtime, when X-Ray is enabled, the sled is replaced by
compiler-rt with a trampoline to the logic for creating the custom log entries.
Future patches will implement the compiler-rt parts and clang-side support for
emitting the IR corresponding to this intrinsic.
Reviewers: timshen, dberris
Subscribers: igorb, pelikan, rSerge, timshen, echristo, dberris, llvm-commits
Differential Revision: https://reviews.llvm.org/D27503
llvm-svn: 302405
2017-05-08 13:45:21 +08:00
%eventptr = alloca i8
%eventsize = alloca i32
store i32 3 , i32 * %eventsize
%val = load i32 , i32 * %eventsize
2021-01-25 16:49:18 +08:00
call void @llvm.xray.customevent ( i8 * %eventptr , i32 %val ) , !dbg !8
[XRay] Custom event logging intrinsic
This patch introduces an LLVM intrinsic and a target opcode for custom event
logging in XRay. Initially, its use case will be to allow users of XRay to log
some type of string ("poor man's printf"). The target opcode compiles to a noop
sled large enough to enable calling through to a runtime-determined relative
function call. At runtime, when X-Ray is enabled, the sled is replaced by
compiler-rt with a trampoline to the logic for creating the custom log entries.
Future patches will implement the compiler-rt parts and clang-side support for
emitting the IR corresponding to this intrinsic.
Reviewers: timshen, dberris
Subscribers: igorb, pelikan, rSerge, timshen, echristo, dberris, llvm-commits
Differential Revision: https://reviews.llvm.org/D27503
llvm-svn: 302405
2017-05-08 13:45:21 +08:00
; CHECK-LABEL: Lxray_event_sled_0:
2017-09-04 13:34:58 +08:00
; CHECK: .byte 0xeb, 0x0f
; CHECK-NEXT: pushq %rdi
; CHECK-NEXT: pushq %rsi
2019-10-24 14:04:35 +08:00
; CHECK-NEXT: movq %rcx, %rdi
2019-10-28 08:13:50 +08:00
; CHECK-NEXT: movq %rax, %rsi
2017-09-04 13:34:58 +08:00
; CHECK-NEXT: callq __xray_CustomEvent
; CHECK-NEXT: popq %rsi
; CHECK-NEXT: popq %rdi
; PIC-LABEL: Lxray_event_sled_0:
; PIC: .byte 0xeb, 0x0f
; PIC-NEXT: pushq %rdi
; PIC-NEXT: pushq %rsi
2019-10-24 14:04:35 +08:00
; PIC-NEXT: movq %rcx, %rdi
2019-10-28 08:13:50 +08:00
; PIC-NEXT: movq %rax, %rsi
2017-09-04 13:34:58 +08:00
; PIC-NEXT: callq __xray_CustomEvent@PLT
; PIC-NEXT: popq %rsi
; PIC-NEXT: popq %rdi
[XRay] Custom event logging intrinsic
This patch introduces an LLVM intrinsic and a target opcode for custom event
logging in XRay. Initially, its use case will be to allow users of XRay to log
some type of string ("poor man's printf"). The target opcode compiles to a noop
sled large enough to enable calling through to a runtime-determined relative
function call. At runtime, when X-Ray is enabled, the sled is replaced by
compiler-rt with a trampoline to the logic for creating the custom log entries.
Future patches will implement the compiler-rt parts and clang-side support for
emitting the IR corresponding to this intrinsic.
Reviewers: timshen, dberris
Subscribers: igorb, pelikan, rSerge, timshen, echristo, dberris, llvm-commits
Differential Revision: https://reviews.llvm.org/D27503
llvm-svn: 302405
2017-05-08 13:45:21 +08:00
ret i32 0
}
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:
[XRay] Custom event logging intrinsic
This patch introduces an LLVM intrinsic and a target opcode for custom event
logging in XRay. Initially, its use case will be to allow users of XRay to log
some type of string ("poor man's printf"). The target opcode compiles to a noop
sled large enough to enable calling through to a runtime-determined relative
function call. At runtime, when X-Ray is enabled, the sled is replaced by
compiler-rt with a trampoline to the logic for creating the custom log entries.
Future patches will implement the compiler-rt parts and clang-side support for
emitting the IR corresponding to this intrinsic.
Reviewers: timshen, dberris
Subscribers: igorb, pelikan, rSerge, timshen, echristo, dberris, llvm-commits
Differential Revision: https://reviews.llvm.org/D27503
llvm-svn: 302405
2017-05-08 13:45:21 +08:00
; CHECK: .quad {{.*}}xray_event_sled_0
2021-01-25 16:49:18 +08:00
define i32 @typedevent ( ) nounwind "function-instrument" = "xray-always" !dbg !2 {
2021-01-25 16:26:54 +08:00
%eventptr = alloca i8
%eventsize = alloca i32
%eventtype = alloca i16
store i16 6 , i16 * %eventtype
%type = load i16 , i16 * %eventtype
store i32 3 , i32 * %eventsize
%val = load i32 , i32 * %eventsize
2021-01-25 16:49:18 +08:00
call void @llvm.xray.typedevent ( i16 %type , i8 * %eventptr , i32 %val ) , !dbg !9
2021-01-25 16:26:54 +08:00
; CHECK-LABEL: Lxray_typed_event_sled_0:
; CHECK: .byte 0xeb, 0x14
; CHECK-NEXT: pushq %rdi
; CHECK-NEXT: pushq %rsi
; CHECK-NEXT: pushq %rdx
; CHECK-NEXT: movq %rdx, %rdi
; CHECK-NEXT: movq %rcx, %rsi
; CHECK-NEXT: movq %rax, %rdx
; CHECK-NEXT: callq __xray_TypedEvent
; CHECK-NEXT: popq %rdx
; CHECK-NEXT: popq %rsi
; CHECK-NEXT: popq %rdi
; PIC-LABEL: Lxray_typed_event_sled_0:
; PIC: .byte 0xeb, 0x14
; PIC-NEXT: pushq %rdi
; PIC-NEXT: pushq %rsi
; PIC-NEXT: pushq %rdx
; PIC-NEXT: movq %rdx, %rdi
; PIC-NEXT: movq %rcx, %rsi
; PIC-NEXT: movq %rax, %rdx
; PIC-NEXT: callq __xray_TypedEvent@PLT
; PIC-NEXT: popq %rdx
; PIC-NEXT: popq %rsi
; PIC-NEXT: popq %rdi
ret i32 0
}
; CHECK-LABEL: xray_instr_map
; CHECK-LABEL: Lxray_sleds_start1:
; CHECK: .quad {{.*}}xray_typed_event_sled_0
[XRay] Custom event logging intrinsic
This patch introduces an LLVM intrinsic and a target opcode for custom event
logging in XRay. Initially, its use case will be to allow users of XRay to log
some type of string ("poor man's printf"). The target opcode compiles to a noop
sled large enough to enable calling through to a runtime-determined relative
function call. At runtime, when X-Ray is enabled, the sled is replaced by
compiler-rt with a trampoline to the logic for creating the custom log entries.
Future patches will implement the compiler-rt parts and clang-side support for
emitting the IR corresponding to this intrinsic.
Reviewers: timshen, dberris
Subscribers: igorb, pelikan, rSerge, timshen, echristo, dberris, llvm-commits
Differential Revision: https://reviews.llvm.org/D27503
llvm-svn: 302405
2017-05-08 13:45:21 +08:00
declare void @llvm.xray.customevent ( i8 * , i32 )
2021-01-25 16:26:54 +08:00
declare void @llvm.xray.typedevent ( i16 , i8 * , i32 )
2021-01-25 16:49:18 +08:00
;; Construct call site entries for PATCHABLE_EVENT_CALL.
; DBG: DW_TAG_subprogram
; DBG: DW_TAG_call_site
; DBG-NEXT: DW_AT_call_target (DW_OP_reg{{.*}})
; DBG-NEXT: DW_AT_call_return_pc
; DBG: DW_TAG_subprogram
; DBG: DW_TAG_call_site
; DBG-NEXT: DW_AT_call_target (DW_OP_reg{{.*}})
; DBG-NEXT: DW_AT_call_return_pc
!llvm.dbg.cu = ! { !7 }
!llvm.module.flags = ! { !10 , !11 }
!1 = distinct !DISubprogram ( name: "customevent" , scope: !3 , file: !3 , line: 1 , type: !4 , scopeLine: 1 , flags: D I F l a g P r o t o t y p e d | D I F l a g A l l C a l l s D e s c r i b e d , spFlags: D I S P F l a g D e f i n i t i o n | D I S P F l a g O p t i m i z e d , unit: !7 )
!2 = distinct !DISubprogram ( name: "typedevent" , scope: !3 , file: !3 , line: 3 , type: !4 , scopeLine: 3 , flags: D I F l a g P r o t o t y p e d | D I F l a g A l l C a l l s D e s c r i b e d , spFlags: D I S P F l a g D e f i n i t i o n | D I S P F l a g O p t i m i z e d , unit: !7 )
!3 = !DIFile ( filename: "a.c" , directory: "/tmp" )
!4 = !DISubroutineType ( types: !5 )
!5 = ! { !6 }
!6 = !DIBasicType ( name: "int" , size: 32 , encoding: D W _ A T E _ s i g n e d )
!7 = distinct !DICompileUnit ( language: D W _ L A N G _ C _ p l u s _ p l u s _ 14 , file: !3 , producer: "clang version 12.0.0" , isOptimized: true , runtimeVersion: 0 , emissionKind: F u l l D e b u g )
!8 = !DILocation ( line: 2 , column: 3 , scope: !1 )
!9 = !DILocation ( line: 4 , column: 3 , scope: !2 )
!10 = ! { i32 7 , !"Dwarf Version" , i32 5 }
!11 = ! { i32 2 , !"Debug Info Version" , i32 3 }