-
Notifications
You must be signed in to change notification settings - Fork 15.6k
[JITLink] Add TLS support for SystemZ #171559
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
5aa262b
[JITLink] TLS support for SystemZ. Original patch #170706 included or…
b6083d1
Merge branch 'main' of github.com:anoopkg6/llvm-project into tls-only…
6abd159
Incorporate code review feedback
ea54558
Merge branch 'llvm:main' into tls-only-jitlink
anoopkg6 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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,42 @@ | ||
| //===-- orc_rt_elfnix_tls_systemz.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. | ||
| // | ||
| //===----------------------------------------------------------------------===// | ||
|
|
||
| // The special thing about the s390 TLS ABI is that we do not have the | ||
| // standard __tls_get_addr function but the __tls_get_offset function | ||
| // which differs in two important aspects: | ||
| // 1) __tls_get_offset gets a got offset instead of a pointer to the | ||
| // tls_index structure | ||
| // 2) __tls_get_offset returns the offset of the requested variable to | ||
| // the thread descriptor instead of a pointer to the variable. | ||
|
|
||
| // The content of this file is systemz-only | ||
|
|
||
| #if defined(__s390x__) | ||
|
|
||
| .text | ||
| // returns offset of TLV from TP in %r2. | ||
| .globl ___orc_rt_elfnix_tls_get_offset | ||
| ___orc_rt_elfnix_tls_get_offset: | ||
| stmg %r14, %r15, 112(%r15) | ||
| aghi %r15, -160 | ||
| // Pass pointer to tls_index. | ||
| la %r2, 0(%r2, %r12) | ||
| brasl %r14, __orc_rt_elfnix_tls_get_addr_impl | ||
| // Return offset from TP. | ||
| ear %r0, %a0 | ||
| sllg %r0, %r0, 32 | ||
| ear %r0, %a1 | ||
| sgr %r2, %r0 | ||
| lmg %r14, %r15, 272(%r15) | ||
| br %r14 | ||
|
|
||
| #endif // defined(__s390x__) | ||
67 changes: 67 additions & 0 deletions
67
compiler-rt/test/orc/TestCases/Linux/systemz/trivial-tls.S
This file contains hidden or 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,67 @@ | ||
| // RUN: %clang -c -o %t %s | ||
| // RUN: %llvm_jitlink %t | ||
| // | ||
| // Test that basic ELF TLS work by adding together TLSs with values | ||
| // 0, 1, and -1, and returning the result (0 for success). This setup | ||
| // tests both zero-initialized (.tbss) and non-zero-initialized | ||
| // (.tdata) sections. | ||
|
|
||
| .section .data.rel.ro,"aw",@progbits | ||
| .p2align 3, 0x0 | ||
| .LCPI0_0: | ||
| .quad x@TLSGD | ||
| .LCPI0_1: | ||
| .quad y@TLSGD | ||
| .LCPI0_2: | ||
| .quad z@TLSGD | ||
|
|
||
| .text | ||
| .globl main | ||
| .p2align 4 | ||
| .type main,@function | ||
| main: | ||
| stmg %r10, %r15, 80(%r15) | ||
| aghi %r15, -160 | ||
| lgrl %r2, .LCPI0_0 | ||
| larl %r12, _GLOBAL_OFFSET_TABLE_ | ||
| brasl %r14, __tls_get_offset@PLT:tls_gdcall:x | ||
| lgr %r13, %r2 | ||
| lgrl %r2, .LCPI0_1 | ||
| brasl %r14, __tls_get_offset@PLT:tls_gdcall:y | ||
| ear %r0, %a0 | ||
| sllg %r11, %r0, 32 | ||
| ear %r11, %a1 | ||
| l %r10, 0(%r2,%r11) | ||
| lgrl %r2, .LCPI0_2 | ||
| a %r10, 0(%r13,%r11) | ||
| brasl %r14, __tls_get_offset@PLT:tls_gdcall:z | ||
| a %r10, 0(%r2,%r11) | ||
| lgfr %r2, %r10 | ||
| lmg %r10, %r15, 240(%r15) | ||
| br %r14 | ||
| .Lfunc_end0: | ||
| .size main, .Lfunc_end0-main | ||
|
|
||
|
|
||
| .type x,@object # @x | ||
| .section .tbss,"awT",@nobits | ||
| .globl x | ||
| .p2align 2, 0x0 | ||
| x: | ||
| .long 0 # 0x0 | ||
| .size x, 4 | ||
|
|
||
| .type y,@object # @y | ||
| .section .tdata,"awT",@progbits | ||
| .globl y | ||
| .p2align 2, 0x0 | ||
| y: | ||
| .long 1 # 0x1 | ||
| .size y, 4 | ||
|
|
||
| .type z,@object # @z | ||
| .globl z | ||
| .p2align 2, 0x0 | ||
| z: | ||
| .long 4294967295 # 0xffffffff | ||
| .size z, 4 |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.