Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Re-apply "[ORC][ORC-RT] Add initial native-TLV support to MachOPlatfo…
…rm." Reapplies fe1fa43, which was reverted in 6d8c639, with fixes: 1. Remove .subsections_via_symbols directive from macho_tlv.x86-64.s (it's not needed here anyway). 2. Return error from pthread_key_create to the MachOPlatform to silence unused variable warning.
- Loading branch information
Showing
8 changed files
with
395 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
//===-- orc_rt_macho_tlv.x86-64.s -------------------------------*- ASM -*-===// | ||
// | ||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
// See https://llvm.org/LICENSE.txt for license information. | ||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
// | ||
//===----------------------------------------------------------------------===// | ||
// | ||
// This file is a part of the ORC runtime support library. | ||
// | ||
//===----------------------------------------------------------------------===// | ||
|
||
#define REGISTER_SAVE_SPACE_SIZE 512 | ||
|
||
.text | ||
|
||
// returns address of TLV in %rax, all other registers preserved | ||
.globl ___orc_rt_macho_tlv_get_addr | ||
___orc_rt_macho_tlv_get_addr: | ||
pushq %rbp | ||
movq %rsp, %rbp | ||
subq $REGISTER_SAVE_SPACE_SIZE, %rsp | ||
movq %rbx, -8(%rbp) | ||
movq %rcx, -16(%rbp) | ||
movq %rdx, -24(%rbp) | ||
movq %rsi, -32(%rbp) | ||
movq %rdi, -40(%rbp) | ||
movq %r8, -48(%rbp) | ||
movq %r9, -56(%rbp) | ||
movq %r10, -64(%rbp) | ||
movq %r11, -72(%rbp) | ||
movq %r12, -80(%rbp) | ||
movq %r13, -88(%rbp) | ||
movq %r14, -96(%rbp) | ||
movq %r15, -104(%rbp) | ||
movdqa %xmm0, -128(%rbp) | ||
movdqa %xmm1, -144(%rbp) | ||
movdqa %xmm2, -160(%rbp) | ||
movdqa %xmm3, -176(%rbp) | ||
movdqa %xmm4, -192(%rbp) | ||
movdqa %xmm5, -208(%rbp) | ||
movdqa %xmm6, -224(%rbp) | ||
movdqa %xmm7, -240(%rbp) | ||
call ___orc_rt_macho_tlv_get_addr_impl | ||
movq -8(%rbp), %rbx | ||
movq -16(%rbp), %rcx | ||
movq -24(%rbp), %rdx | ||
movq -32(%rbp), %rsi | ||
movq -40(%rbp), %rdi | ||
movq -48(%rbp), %r8 | ||
movq -56(%rbp), %r9 | ||
movq -64(%rbp), %r10 | ||
movq -72(%rbp), %r11 | ||
movq -80(%rbp), %r12 | ||
movq -88(%rbp), %r13 | ||
movq -96(%rbp), %r14 | ||
movq -104(%rbp), %r15 | ||
movdqa -128(%rbp), %xmm0 | ||
movdqa -144(%rbp), %xmm1 | ||
movdqa -160(%rbp), %xmm2 | ||
movdqa -176(%rbp), %xmm3 | ||
movdqa -192(%rbp), %xmm4 | ||
movdqa -208(%rbp), %xmm5 | ||
movdqa -224(%rbp), %xmm6 | ||
movdqa -240(%rbp), %xmm7 | ||
addq $REGISTER_SAVE_SPACE_SIZE, %rsp | ||
popq %rbp | ||
ret |
63 changes: 63 additions & 0 deletions
63
compiler-rt/test/orc/TestCases/Darwin/x86-64/trivial-tlv.S
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
// RUN: %clang -c -o %t %s | ||
// RUN: %llvm_jitlink %t | ||
// | ||
// Test that basic MachO TLVs work by adding together TLVs with values | ||
// 0, 1, and -1, and returning the result (0 for success). This setup | ||
// tests both zero-initialized (__thread_bss) and non-zero-initialized | ||
// (__thread_data) secitons. | ||
|
||
.section __TEXT,__text,regular,pure_instructions | ||
.build_version macos, 11, 0 | ||
|
||
.globl _main | ||
.p2align 4, 0x90 | ||
_main: | ||
pushq %rax | ||
movq _x@TLVP(%rip), %rdi | ||
callq *(%rdi) | ||
movq %rax, %rcx | ||
movq _y@TLVP(%rip), %rdi | ||
callq *(%rdi) | ||
movl (%rax), %edx | ||
addl (%rcx), %edx | ||
movq _z@TLVP(%rip), %rdi | ||
callq *(%rdi) | ||
addl (%rax), %edx | ||
movl %edx, %eax | ||
popq %rcx | ||
retq | ||
|
||
.tbss _x$tlv$init, 4, 2 | ||
|
||
.section __DATA,__thread_vars,thread_local_variables | ||
.globl _x | ||
_x: | ||
.quad __tlv_bootstrap | ||
.quad 0 | ||
.quad _x$tlv$init | ||
|
||
.section __DATA,__thread_data,thread_local_regular | ||
.p2align 2 | ||
_y$tlv$init: | ||
.long 4294967295 | ||
|
||
.section __DATA,__thread_vars,thread_local_variables | ||
.globl _y | ||
_y: | ||
.quad __tlv_bootstrap | ||
.quad 0 | ||
.quad _y$tlv$init | ||
|
||
.section __DATA,__thread_data,thread_local_regular | ||
.p2align 2 | ||
_z$tlv$init: | ||
.long 1 | ||
|
||
.section __DATA,__thread_vars,thread_local_variables | ||
.globl _z | ||
_z: | ||
.quad __tlv_bootstrap | ||
.quad 0 | ||
.quad _z$tlv$init | ||
|
||
.subsections_via_symbols |
Oops, something went wrong.