summaryrefslogtreecommitdiffstats
path: root/llvm/test/CodeGen/X86
diff options
context:
space:
mode:
authorDean Michael Berris <dberris@google.com>2017-08-23 04:49:41 +0000
committerDean Michael Berris <dberris@google.com>2017-08-23 04:49:41 +0000
commit0884b732202d043af4755d05aeb7fd3da8951a24 (patch)
treed0c2971364fbc3858cb0f2a72cb3f2f58901e42a /llvm/test/CodeGen/X86
parent71f88a955d30645d082ddd42d2215226f3ea8744 (diff)
downloadbcm5719-llvm-0884b732202d043af4755d05aeb7fd3da8951a24.tar.gz
bcm5719-llvm-0884b732202d043af4755d05aeb7fd3da8951a24.zip
[XRay][CodeGen] Use PIC-friendly code in XRay sleds; remove synthetic references in .text
Summary: This change achieves two things: - Redefine the Custom Event handling instrumentation points emitted by the compiler to not require dynamic relocation of references to the __xray_CustomEvent trampoline. - Remove the synthetic reference we emit at the end of a function that we used to keep auxiliary sections alive in favour of SHF_LINK_ORDER associated with the section where the function is defined. To achieve the custom event handling change, we've had to introduce the concept of sled versioning -- this will need to be supported by the runtime to allow us to understand how to turn on/off the new version of the custom event handling sleds. That change has to land first before we change the way we write the sleds. To remove the synthetic reference, we rely on a relatively new linker feature that preserves the sections that are associated with each other. This allows us to limit the effects on the .text section of ELF binaries. Because we're still using absolute references that are resolved at runtime for the instrumentation map (and function index) maps, we mark these sections write-able. In the future we can re-define the entries in the map to use relative relocations instead that can be statically determined by the linker. That change will be a bit more invasive so we defer this for later. Depends on D36816. Reviewers: dblaikie, echristo, pcc Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D36615 llvm-svn: 311525
Diffstat (limited to 'llvm/test/CodeGen/X86')
-rw-r--r--llvm/test/CodeGen/X86/xray-attribute-instrumentation.ll28
-rw-r--r--llvm/test/CodeGen/X86/xray-custom-log.ll13
-rw-r--r--llvm/test/CodeGen/X86/xray-log-args.ll44
-rw-r--r--llvm/test/CodeGen/X86/xray-loop-detection.ll1
-rw-r--r--llvm/test/CodeGen/X86/xray-section-group.ll4
-rw-r--r--llvm/test/CodeGen/X86/xray-tail-call-sled.ll22
6 files changed, 51 insertions, 61 deletions
diff --git a/llvm/test/CodeGen/X86/xray-attribute-instrumentation.ll b/llvm/test/CodeGen/X86/xray-attribute-instrumentation.ll
index 00b45f8d95b..7fa2c0e1180 100644
--- a/llvm/test/CodeGen/X86/xray-attribute-instrumentation.ll
+++ b/llvm/test/CodeGen/X86/xray-attribute-instrumentation.ll
@@ -1,27 +1,25 @@
; RUN: llc -filetype=asm -o - -mtriple=x86_64-unknown-linux-gnu < %s | FileCheck %s
+; RUN: llc -filetype=asm -o - -mtriple=x86_64-unknown-linux-gnu \
+; RUN: -relocation-model=pic < %s | FileCheck %s
; RUN: llc -filetype=asm -o - -mtriple=x86_64-darwin-unknown < %s | FileCheck %s
define i32 @foo() nounwind noinline uwtable "function-instrument"="xray-always" {
; CHECK: .p2align 1, 0x90
; CHECK-LABEL: Lxray_sled_0:
-; CHECK-NEXT: .ascii "\353\t"
+; CHECK: .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: retq
; CHECK-NEXT: nopw %cs:512(%rax,%rax)
}
-; CHECK: .p2align 4, 0x90
-; CHECK-NEXT: .quad {{.*}}xray_fn_idx_synth_0
-; CHECK-NEXT: .section {{.*}}xray_instr_map
+; CHECK-LABEL: xray_instr_map
; CHECK-LABEL: Lxray_sleds_start0:
; CHECK: .quad {{.*}}xray_sled_0
; CHECK: .quad {{.*}}xray_sled_1
; CHECK-LABEL: Lxray_sleds_end0:
-; CHECK: .section {{.*}}xray_fn_idx
-; CHECK-LABEL: Lxray_fn_idx_synth_0:
+; CHECK-LABEL: xray_fn_idx
; CHECK: .quad {{.*}}xray_sleds_start0
; CHECK-NEXT: .quad {{.*}}xray_sleds_end0
@@ -31,9 +29,8 @@ define i32 @foo() nounwind noinline uwtable "function-instrument"="xray-always"
define i32 @bar(i32 %i) nounwind noinline uwtable "function-instrument"="xray-always" {
; CHECK: .p2align 1, 0x90
; CHECK-LABEL: Lxray_sled_2:
-; CHECK-NEXT: .ascii "\353\t"
+; CHECK: .ascii "\353\t"
; CHECK-NEXT: nopw 512(%rax,%rax)
-; CHECK-LABEL: Ltmp1:
Test:
%cond = icmp eq i32 %i, 0
br i1 %cond, label %IsEqual, label %NotEqual
@@ -41,24 +38,21 @@ IsEqual:
ret i32 0
; CHECK: .p2align 1, 0x90
; CHECK-LABEL: Lxray_sled_3:
-; CHECK-NEXT: retq
+; CHECK: retq
; CHECK-NEXT: nopw %cs:512(%rax,%rax)
NotEqual:
ret i32 1
; CHECK: .p2align 1, 0x90
; CHECK-LABEL: Lxray_sled_4:
-; CHECK-NEXT: retq
+; CHECK: retq
; CHECK-NEXT: nopw %cs:512(%rax,%rax)
}
-; CHECK: .p2align 4, 0x90
-; CHECK-NEXT: .quad {{.*}}xray_fn_idx_synth_1
-; CHECK-NEXT: .section {{.*}}xray_instr_map
+; CHECK-LABEL: xray_instr_map
; CHECK-LABEL: Lxray_sleds_start1:
; CHECK: .quad {{.*}}xray_sled_2
; CHECK: .quad {{.*}}xray_sled_3
; CHECK: .quad {{.*}}xray_sled_4
; CHECK-LABEL: Lxray_sleds_end1:
-; CHECK: .section {{.*}}xray_fn_idx
-; CHECK-LABEL: Lxray_fn_idx_synth_1:
+; CHECK-LABEL: xray_fn_idx
; CHECK: .quad {{.*}}xray_sleds_start1
; CHECK-NEXT: .quad {{.*}}xray_sleds_end1
diff --git a/llvm/test/CodeGen/X86/xray-custom-log.ll b/llvm/test/CodeGen/X86/xray-custom-log.ll
index 69fd0f3e9f7..c9eff581884 100644
--- a/llvm/test/CodeGen/X86/xray-custom-log.ll
+++ b/llvm/test/CodeGen/X86/xray-custom-log.ll
@@ -7,16 +7,17 @@ define i32 @fn() nounwind noinline uwtable "function-instrument"="xray-always" {
%val = load i32, i32* %eventsize
call void @llvm.xray.customevent(i8* %eventptr, i32 %val)
; CHECK-LABEL: Lxray_event_sled_0:
- ; CHECK-NEXT: .ascii "\353\024
- ; CHECK-NEXT: pushq %rax
+ ; CHECK: .byte 0xeb, 0x0f
+ ; CHECK-NEXT: pushq %rdi
; CHECK-NEXT: movq {{.*}}, %rdi
+ ; CHECK-NEXT: pushq %rsi
; CHECK-NEXT: movq {{.*}}, %rsi
- ; CHECK-NEXT: movabsq $__xray_CustomEvent, %rax
- ; CHECK-NEXT: callq *%rax
- ; CHECK-NEXT: popq %rax
+ ; CHECK-NEXT: callq __xray_CustomEvent
+ ; CHECK-NEXT: popq %rsi
+ ; CHECK-NEXT: popq %rdi
ret i32 0
}
-; CHECK: .section {{.*}}xray_instr_map
+; CHECK-LABEL: xray_instr_map
; CHECK-LABEL: Lxray_sleds_start0:
; CHECK: .quad {{.*}}xray_event_sled_0
diff --git a/llvm/test/CodeGen/X86/xray-log-args.ll b/llvm/test/CodeGen/X86/xray-log-args.ll
index 6fe450ac8ad..09d2b10f3d7 100644
--- a/llvm/test/CodeGen/X86/xray-log-args.ll
+++ b/llvm/test/CodeGen/X86/xray-log-args.ll
@@ -7,29 +7,33 @@ define i32 @callee(i32 %arg) nounwind noinline uwtable "function-instrument"="xr
ret i32 %arg
}
; CHECK-LABEL: Lxray_sleds_start0:
-; 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
+; CHECK: .quad {{\.?}}Lxray_sled_0
+; CHECK: .quad {{_?}}callee
+; CHECK: .byte 0x03
+; CHECK: .byte 0x01
+; CHECK: .byte 0x00
+; CHECK: .{{(zero|space)}} 13
+; CHECK: .quad {{\.?}}Lxray_sled_1
+; CHECK: .quad {{_?}}callee
+; CHECK: .byte 0x01
+; CHECK: .byte 0x01
+; CHECK: .byte 0x00
+; CHECK: .{{(zero|space)}} 13
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_sleds_start1:
-; 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
+; CHECK: .quad {{\.?}}Lxray_sled_2
+; CHECK: .quad {{_?}}caller
+; CHECK: .byte 0x03
+; CHECK: .byte 0x01
+; CHECK: .byte 0x00
+; CHECK: .{{(zero|space)}} 13
+; CHECK: .quad {{\.?}}Lxray_sled_3
+; CHECK: .quad {{_?}}caller
+; CHECK: .byte 0x02
+; CHECK: .byte 0x01
+; CHECK: .byte 0x00
+; CHECK: .{{(zero|space)}} 13
diff --git a/llvm/test/CodeGen/X86/xray-loop-detection.ll b/llvm/test/CodeGen/X86/xray-loop-detection.ll
index 3cd6b4aa6f8..12904d76770 100644
--- a/llvm/test/CodeGen/X86/xray-loop-detection.ll
+++ b/llvm/test/CodeGen/X86/xray-loop-detection.ll
@@ -19,5 +19,4 @@ Exit:
; CHECK-LABEL: xray_sled_0:
; CHECK-NEXT: .ascii "\353\t"
; CHECK-NEXT: nopw 512(%rax,%rax)
-; CHECK-LABEL: Ltmp0:
diff --git a/llvm/test/CodeGen/X86/xray-section-group.ll b/llvm/test/CodeGen/X86/xray-section-group.ll
index 7dab8c2ebf7..a4c45a0893e 100644
--- a/llvm/test/CodeGen/X86/xray-section-group.ll
+++ b/llvm/test/CodeGen/X86/xray-section-group.ll
@@ -5,14 +5,14 @@
define i32 @foo() nounwind noinline uwtable "function-instrument"="xray-always" {
; CHECK: .section .text.foo,"ax",@progbits
ret i32 0
-; CHECK: .section xray_instr_map,"a",@progbits
+; CHECK: .section xray_instr_map,"awo",@progbits,.text.foo,unique,1
}
$bar = comdat any
define i32 @bar() nounwind noinline uwtable "function-instrument"="xray-always" comdat($bar) {
; CHECK: .section .text.bar,"axG",@progbits,bar,comdat
ret i32 1
-; CHECK: .section xray_instr_map,"aG",@progbits,bar,comdat
+; CHECK: .section xray_instr_map,"aGwo",@progbits,bar,comdat,.text.bar,unique,2
}
; CHECK-OBJ: section xray_instr_map:
diff --git a/llvm/test/CodeGen/X86/xray-tail-call-sled.ll b/llvm/test/CodeGen/X86/xray-tail-call-sled.ll
index c4a973e529f..59ab8ea5995 100644
--- a/llvm/test/CodeGen/X86/xray-tail-call-sled.ll
+++ b/llvm/test/CodeGen/X86/xray-tail-call-sled.ll
@@ -4,49 +4,41 @@
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: .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: retq
; CHECK-NEXT: nopw %cs:512(%rax,%rax)
}
-; CHECK: .p2align 4, 0x90
-; CHECK-NEXT: .quad {{.*}}xray_fn_idx_synth_0{{.*}}
-; CHECK-NEXT: .section {{.*}}xray_instr_map
+; CHECK-LABEL: xray_instr_map
; CHECK-LABEL: Lxray_sleds_start0:
; CHECK: .quad {{.*}}xray_sled_0
; CHECK: .quad {{.*}}xray_sled_1
; CHECK-LABEL: Lxray_sleds_end0:
-; CHECK-NEXT: .section {{.*}}xray_fn_idx
-; CHECK-LABEL: Lxray_fn_idx_synth_0:
+; CHECK-LABEL: xray_fn_idx
; CHECK: .quad {{.*}}xray_sleds_start0
; CHECK-NEXT: .quad {{.*}}xray_sleds_end0
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: .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()
; CHECK: jmp {{.*}}callee {{.*}}# TAILCALL
ret i32 %retval
}
-; CHECK: .p2align 4, 0x90
-; CHECK-NEXT: .quad {{.*}}xray_fn_idx_synth_1{{.*}}
+; CHECK-LABEL: xray_instr_map
; CHECK-LABEL: Lxray_sleds_start1:
; CHECK: .quad {{.*}}xray_sled_2
; CHECK: .quad {{.*}}xray_sled_3
; CHECK-LABEL: Lxray_sleds_end1:
-; CHECK: .section {{.*}}xray_fn_idx
-; CHECK-LABEL: Lxray_fn_idx_synth_1:
+; CHECK-LABEL: xray_fn_idx
; CHECK: .quad {{.*}}xray_sleds_start1
; CHECK: .quad {{.*}}xray_sleds_end1
OpenPOWER on IntegriCloud