
The `__DATA,xray_instr_map` section has label differences like `.quad Lxray_sled_0-Ltmp0` that is represented as a pair of UNSIGNED and SUBTRACTOR relocations. LLVM integrated assembler attempts to rewrite A-B into A-B'+offset where B' can be included in the symbol table. B' is called an atom and should be a non-temporary symbol in the same section. However, since `xray_instr_map` does not define a non-temporary symbol, the SUBTRACTOR relocation will have no associated symbol, and its `r_extern` value will be 0. Therefore, we will see linker errors like: error: SUBTRACTOR relocation must be extern at offset 0 of __DATA,xray_instr_map in a.o To fix this issue, we need to define a non-temporary symbol in the section. We can accomplish this by renaming `Lxray_sleds_start0` to `lxray_sleds_start0` ("L" to "l"). `lxray_sleds_start0` serves as the atom for this dead-strippable subsection. With the `S_ATTR_LIVE_SUPPORT` attribute, `ld -dead_strip` will retain subsections that reference live functions. Special thanks to Oleksii Lozovskyi for reporting the issue and providing initial analysis. Differential Revision: https://reviews.llvm.org/D153239
88 lines
2.8 KiB
LLVM
88 lines
2.8 KiB
LLVM
; RUN: llc -mtriple=aarch64-unknown-linux-gnu < %s | FileCheck %s -check-prefixes=CHECK,CHECK-LINUX
|
|
; RUN: llc -mtriple=aarch64-apple-darwin < %s | FileCheck %s -check-prefixes=CHECK,CHECK-MACOS
|
|
|
|
define i32 @foo() nounwind noinline uwtable "function-instrument"="xray-always" {
|
|
; CHECK-LABEL: foo:
|
|
; CHECK-LABEL: Lxray_sled_0:
|
|
; CHECK-NEXT: b #32
|
|
; CHECK-COUNT-7: nop
|
|
; CHECK-NEXT: Ltmp[[#]]:
|
|
ret i32 0
|
|
; CHECK-LABEL: Lxray_sled_1:
|
|
; CHECK-NEXT: b #32
|
|
; CHECK-COUNT-7: nop
|
|
; CHECK-NEXT: Ltmp[[#]]:
|
|
; CHECK-NEXT: ret
|
|
}
|
|
|
|
; CHECK-LINUX-LABEL: .section xray_instr_map,"ao",@progbits,foo{{$}}
|
|
; CHECK-LINUX-LABEL: Lxray_sleds_start0:
|
|
; CHECK-LINUX: .xword .Lxray_sled_0
|
|
; CHECK-LINUX: .xword .Lxray_sled_1
|
|
; CHECK-LINUX-LABEL: Lxray_sleds_end0:
|
|
|
|
; CHECK-MACOS-LABEL: .section __DATA,xray_instr_map,regular,live_support{{$}}
|
|
; CHECK-MACOS-LABEL: lxray_sleds_start0:
|
|
; CHECK-MACOS: .quad Lxray_sled_0
|
|
; CHECK-MACOS: .quad Lxray_sled_1
|
|
; CHECK-MACOS-LABEL: Lxray_sleds_end0:
|
|
|
|
define i32 @bar() nounwind noinline uwtable "function-instrument"="xray-never" "function-instrument"="xray-always" {
|
|
; CHECK-LABEL: bar:
|
|
; CHECK-LABEL: Lxray_sled_2:
|
|
; CHECK-NEXT: b #32
|
|
; CHECK-COUNT-7: nop
|
|
; CHECK-NEXT: Ltmp[[#]]:
|
|
ret i32 0
|
|
; CHECK-LABEL: Lxray_sled_3:
|
|
; CHECK-NEXT: b #32
|
|
; CHECK-COUNT-7: nop
|
|
; CHECK-NEXT: Ltmp[[#]]:
|
|
; CHECK-NEXT: ret
|
|
}
|
|
|
|
; CHECK-LINUX-LABEL: .section xray_instr_map,"ao",@progbits,bar{{$}}
|
|
; CHECK-LINUX-LABEL: Lxray_sleds_start1:
|
|
; CHECK-LINUX: .xword .Lxray_sled_2
|
|
; CHECK-LINUX: .xword .Lxray_sled_3
|
|
; CHECK-LINUX-LABEL: Lxray_sleds_end1:
|
|
|
|
; CHECK-MACOS-LABEL: .section __DATA,xray_instr_map,regular,live_support{{$}}
|
|
; CHECK-MACOS-LABEL: lxray_sleds_start1:
|
|
; CHECK-MACOS: .quad Lxray_sled_2
|
|
; CHECK-MACOS: .quad Lxray_sled_3
|
|
; CHECK-MACOS-LABEL: Lxray_sleds_end1:
|
|
|
|
define i32 @instrumented() nounwind noinline uwtable "xray-instruction-threshold"="1" {
|
|
; CHECK-LABEL: instrumented:
|
|
; CHECK-LABEL: Lxray_sled_4:
|
|
; CHECK-NEXT: b #32
|
|
; CHECK-COUNT-7: nop
|
|
; CHECK-NEXT: Ltmp[[#]]:
|
|
ret i32 0
|
|
; CHECK-LABEL: Lxray_sled_5:
|
|
; CHECK-NEXT: b #32
|
|
; CHECK-COUNT-7: nop
|
|
; CHECK-NEXT: Ltmp[[#]]:
|
|
; CHECK-NEXT: ret
|
|
}
|
|
|
|
; CHECK-LINUX-LABEL: .section xray_instr_map,"ao",@progbits,instrumented{{$}}
|
|
; CHECK-LINUX-LABEL: Lxray_sleds_start2:
|
|
; CHECK-LINUX: .xword .Lxray_sled_4
|
|
; CHECK-LINUX: .xword .Lxray_sled_5
|
|
; CHECK-LINUX-LABEL: Lxray_sleds_end2:
|
|
|
|
; CHECK-MACOS-LABEL: .section __DATA,xray_instr_map,regular,live_support{{$}}
|
|
; CHECK-MACOS-LABEL: lxray_sleds_start2:
|
|
; CHECK-MACOS: .quad Lxray_sled_4
|
|
; CHECK-MACOS: .quad Lxray_sled_5
|
|
; CHECK-MACOS-LABEL: Lxray_sleds_end2:
|
|
|
|
define i32 @not_instrumented() nounwind noinline uwtable "xray-instruction-threshold"="1" "function-instrument"="xray-never" {
|
|
; CHECK-LABEL: not_instrumented
|
|
; CHECK-NOT: Lxray_sled_6
|
|
ret i32 0
|
|
; CHECK: ret
|
|
}
|