1; RUN: llc -mtriple=x86_64 < %s | FileCheck %s 2; RUN: llc -mtriple=x86_64 -relocation-model=pic < %s | FileCheck %s --check-prefix=PIC 3 4; RUN: llc -mtriple=x86_64 -filetype=obj %s -o %t 5; RUN: llvm-dwarfdump %t | FileCheck %s --check-prefix=DBG 6 7define i32 @customevent() nounwind "function-instrument"="xray-always" !dbg !1 { 8 %eventptr = alloca i8 9 %eventsize = alloca i64 10 store i64 3, ptr %eventsize 11 %val = load i64, ptr %eventsize 12 call void @llvm.xray.customevent(ptr %eventptr, i64 %val), !dbg !8 13 ; CHECK-LABEL: Lxray_event_sled_0: 14 ; CHECK: .byte 0xeb, 0x0f 15 ; CHECK-NEXT: pushq %rdi 16 ; CHECK-NEXT: pushq %rsi 17 ; CHECK-NEXT: movq %rcx, %rdi 18 ; CHECK-NEXT: movq %rax, %rsi 19 ; CHECK-NEXT: callq __xray_CustomEvent 20 ; CHECK-NEXT: popq %rsi 21 ; CHECK-NEXT: popq %rdi 22 23 ; PIC-LABEL: Lxray_event_sled_0: 24 ; PIC: .byte 0xeb, 0x0f 25 ; PIC-NEXT: pushq %rdi 26 ; PIC-NEXT: pushq %rsi 27 ; PIC-NEXT: movq %rcx, %rdi 28 ; PIC-NEXT: movq %rax, %rsi 29 ; PIC-NEXT: callq __xray_CustomEvent@PLT 30 ; PIC-NEXT: popq %rsi 31 ; PIC-NEXT: popq %rdi 32 ret i32 0 33} 34; CHECK-LABEL: xray_instr_map 35; CHECK-LABEL: Lxray_sleds_start0: 36; CHECK: .quad {{.*}}xray_event_sled_0 37 38define i32 @typedevent() nounwind "function-instrument"="xray-always" !dbg !2 { 39 %eventptr = alloca i8 40 %eventsize = alloca i64 41 %eventtype = alloca i64 42 store i64 6, ptr %eventtype 43 %type = load i64, ptr %eventtype 44 store i64 3, ptr %eventsize 45 %val = load i64, ptr %eventsize 46 call void @llvm.xray.typedevent(i64 %type, ptr %eventptr, i64 %val), !dbg !9 47 ; CHECK-LABEL: Lxray_typed_event_sled_0: 48 ; CHECK: .byte 0xeb, 0x14 49 ; CHECK-NEXT: pushq %rdi 50 ; CHECK-NEXT: pushq %rsi 51 ; CHECK-NEXT: pushq %rdx 52 ; CHECK-NEXT: movq %rdx, %rdi 53 ; CHECK-NEXT: movq %rcx, %rsi 54 ; CHECK-NEXT: movq %rax, %rdx 55 ; CHECK-NEXT: callq __xray_TypedEvent 56 ; CHECK-NEXT: popq %rdx 57 ; CHECK-NEXT: popq %rsi 58 ; CHECK-NEXT: popq %rdi 59 60 ; PIC-LABEL: Lxray_typed_event_sled_0: 61 ; PIC: .byte 0xeb, 0x14 62 ; PIC-NEXT: pushq %rdi 63 ; PIC-NEXT: pushq %rsi 64 ; PIC-NEXT: pushq %rdx 65 ; PIC-NEXT: movq %rdx, %rdi 66 ; PIC-NEXT: movq %rcx, %rsi 67 ; PIC-NEXT: movq %rax, %rdx 68 ; PIC-NEXT: callq __xray_TypedEvent@PLT 69 ; PIC-NEXT: popq %rdx 70 ; PIC-NEXT: popq %rsi 71 ; PIC-NEXT: popq %rdi 72 ret i32 0 73} 74; CHECK-LABEL: xray_instr_map 75; CHECK-LABEL: Lxray_sleds_start1: 76; CHECK: .quad {{.*}}xray_typed_event_sled_0 77 78; Verify that custom event calls are done with proper stack alignment, 79; even in leaf functions. 80@leaf_func.event_id = internal constant i32 1, align 4 81define void @leaf_func() "function-instrument"="xray-always" "frame-pointer"="none" nounwind { 82 ; CHECK-LABEL: leaf_func: 83 ; CHECK-NEXT: .Lfunc_begin2: 84 ; CHECK: pushq %rax 85 ; CHECK: movl $leaf_func.event_id, %eax 86 ; CHECK-NEXT: movl $4, %ecx 87 ; CHECK-NEXT: .p2align 1 88 ; CHECK-NEXT: .Lxray_event_sled_1: 89 call void @llvm.xray.customevent(ptr @leaf_func.event_id, i64 4) 90 ret void 91} 92 93declare void @llvm.xray.customevent(ptr, i64) 94declare void @llvm.xray.typedevent(i64, ptr, i64) 95 96;; Construct call site entries for PATCHABLE_EVENT_CALL. 97; DBG: DW_TAG_subprogram 98; DBG: DW_TAG_call_site 99; DBG-NEXT: DW_AT_call_target (DW_OP_reg{{.*}}) 100; DBG-NEXT: DW_AT_call_return_pc 101 102; DBG: DW_TAG_subprogram 103; DBG: DW_TAG_call_site 104; DBG-NEXT: DW_AT_call_target (DW_OP_reg{{.*}}) 105; DBG-NEXT: DW_AT_call_return_pc 106 107!llvm.dbg.cu = !{!7} 108!llvm.module.flags = !{!10, !11} 109 110!1 = distinct !DISubprogram(name: "customevent", scope: !3, file: !3, line: 1, type: !4, scopeLine: 1, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !7) 111!2 = distinct !DISubprogram(name: "typedevent", scope: !3, file: !3, line: 3, type: !4, scopeLine: 3, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !7) 112!3 = !DIFile(filename: "a.c", directory: "/tmp") 113!4 = !DISubroutineType(types: !5) 114!5 = !{!6} 115!6 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed) 116!7 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus_14, file: !3, producer: "clang version 12.0.0", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug) 117!8 = !DILocation(line: 2, column: 3, scope: !1) 118!9 = !DILocation(line: 4, column: 3, scope: !2) 119 120!10 = !{i32 7, !"Dwarf Version", i32 5} 121!11 = !{i32 2, !"Debug Info Version", i32 3} 122