-
Notifications
You must be signed in to change notification settings - Fork 15.2k
[LoongArch] Ensure pcaddu18i and jirl adjacency in tail calls for correct relocation #113932
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
Changes from 3 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
9267fd0
[LoongArch] Ensure pcaddu18i and jirl adjacency in tail calls for cor…
heiher 3eca8ed
Adds instruction sizes for Pseudo{CALL,TAIL}_Medium
heiher b8ce4b7
Address xen0n's comments
heiher a862a17
Drop test cases
heiher 66652e0
Merge branch 'main' into fix-tailcall-medium
heiher 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
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
heiher marked this conversation as resolved.
Show resolved
Hide resolved
|
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,120 @@ | ||
| ; RUN: llc --mtriple=loongarch64 -mattr=+d --relocation-model=pic \ | ||
heiher marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| ; RUN: --code-model=medium < %s | FileCheck --check-prefix=MEDIUM %s | ||
| ; RUN: llc --mtriple=loongarch64 -mattr=+d --relocation-model=pic \ | ||
| ; RUN: --code-model=large < %s | FileCheck --check-prefix=LARGE %s | ||
| ; RUN: llc --mtriple=loongarch64 -mattr=+d --relocation-model=pic \ | ||
| ; RUN: --enable-tlsdesc --code-model=large < %s | \ | ||
| ; RUN: FileCheck --check-prefix=LARGEDESC %s | ||
|
|
||
| ; Check the adjancency of pseudo-instruction expansions to ensure | ||
| ; compliance with psABI requirements: | ||
| ; https://github.com/loongson/la-abi-specs/releases/tag/v2.30 | ||
|
|
||
| declare void @llvm.memset.p0.i64(ptr, i8, i64, i1) | ||
|
|
||
| define void @call_external_sym(ptr %dst) { | ||
| ; LARGE-LABEL: call_external_sym: | ||
| ; LARGE: pcalau12i [[REG1:\$[a-z0-9]+]], %pc_hi20(memset) | ||
| ; LARGE-NEXT: addi.d [[REG2:\$[a-z0-9]+]], $zero, %pc_lo12(memset) | ||
| ; LARGE-NEXT: lu32i.d [[REG2]], %pc64_lo20(memset) | ||
| ; LARGE-NEXT: lu52i.d [[REG2]], [[REG2]], %pc64_hi12(memset) | ||
| entry: | ||
| call void @llvm.memset.p0.i64(ptr %dst, i8 0, i64 1000, i1 false) | ||
| ret void | ||
| } | ||
|
|
||
| declare i32 @callee_tail(i32 %i) | ||
|
|
||
| define i32 @caller_call_tail(i32 %i) nounwind { | ||
| ; MEDIUM-LABEL: caller_call_tail: | ||
| ; MEDIUM: pcaddu18i $t8, %call36(callee_tail) | ||
| ; MEDIUM-NEXT: jr $t8 | ||
| ; | ||
| ; LARGE-LABEL: caller_call_tail: | ||
| ; LARGE: pcalau12i [[REG1:\$[a-z0-9]+]], %got_pc_hi20(callee_tail) | ||
| ; LARGE-NEXT: addi.d [[REG2:\$[a-z0-9]+]], $zero, %got_pc_lo12(callee_tail) | ||
| ; LARGE-NEXT: lu32i.d [[REG2]], %got64_pc_lo20(callee_tail) | ||
| ; LARGE-NEXT: lu52i.d [[REG2]], [[REG2]], %got64_pc_hi12(callee_tail) | ||
| entry: | ||
| call i32 @callee_tail(i32 %i) | ||
| %r = tail call i32 @callee_tail(i32 %i) | ||
| ret i32 %r | ||
| } | ||
|
|
||
| @ie = external thread_local(initialexec) global i32 | ||
|
|
||
| define void @test_la_tls_ie(i32 signext %n) { | ||
| ; LARGE-LABEL: test_la_tls_ie: | ||
| ; LARGE: pcalau12i [[REG1:\$[a-z0-9]+]], %ie_pc_hi20(ie) | ||
| ; LARGE-NEXT: addi.d [[REG2:\$[a-z0-9]+]], $zero, %ie_pc_lo12(ie) | ||
| ; LARGE-NEXT: lu32i.d [[REG2]], %ie64_pc_lo20(ie) | ||
| ; LARGE-NEXT: lu52i.d [[REG2]], [[REG2]], %ie64_pc_hi12(ie) | ||
| entry: | ||
| br label %loop | ||
|
|
||
| loop: | ||
| %i = phi i32 [ %inc, %loop ], [ 0, %entry ] | ||
| %0 = load volatile i32, ptr @ie, align 4 | ||
| %inc = add nuw nsw i32 %i, 1 | ||
| %cmp = icmp slt i32 %inc, %n | ||
| br i1 %cmp, label %loop, label %ret | ||
|
|
||
| ret: | ||
| ret void | ||
| } | ||
|
|
||
| @ld = external thread_local(localdynamic) global i32 | ||
|
|
||
| define void @test_la_tls_ld(i32 signext %n) { | ||
| ; LARGE-LABEL: test_la_tls_ld: | ||
| ; LARGE: pcalau12i [[REG1:\$[a-z0-9]+]], %ld_pc_hi20(ld) | ||
| ; LARGE-NEXT: addi.d [[REG2:\$[a-z0-9]+]], $zero, %got_pc_lo12(ld) | ||
| ; LARGE-NEXT: lu32i.d [[REG2]], %got64_pc_lo20(ld) | ||
| ; LARGE-NEXT: lu52i.d [[REG2]], [[REG2]], %got64_pc_hi12(ld) | ||
| entry: | ||
| br label %loop | ||
|
|
||
| loop: | ||
| %i = phi i32 [ %inc, %loop ], [ 0, %entry ] | ||
| %0 = load volatile i32, ptr @ld, align 4 | ||
| %inc = add nuw nsw i32 %i, 1 | ||
| %cmp = icmp slt i32 %inc, %n | ||
| br i1 %cmp, label %loop, label %ret | ||
|
|
||
| ret: | ||
| ret void | ||
| } | ||
|
|
||
| @gd = external thread_local global i32 | ||
|
|
||
| define void @test_la_tls_gd(i32 signext %n) nounwind { | ||
| ; LARGE-LABEL: test_la_tls_gd: | ||
| ; LARGE: pcalau12i [[REG1:\$[a-z0-9]+]], %gd_pc_hi20(gd) | ||
| ; LARGE-NEXT: addi.d [[REG2:\$[a-z0-9]+]], $zero, %got_pc_lo12(gd) | ||
| ; LARGE-NEXT: lu32i.d [[REG2]], %got64_pc_lo20(gd) | ||
| ; LARGE-NEXT: lu52i.d [[REG2]], [[REG2]], %got64_pc_hi12(gd) | ||
| entry: | ||
| br label %loop | ||
|
|
||
| loop: | ||
| %i = phi i32 [ %inc, %loop ], [ 0, %entry ] | ||
| %0 = load volatile i32, ptr @gd, align 4 | ||
| %inc = add nuw nsw i32 %i, 1 | ||
| %cmp = icmp slt i32 %inc, %n | ||
| br i1 %cmp, label %loop, label %ret | ||
|
|
||
| ret: | ||
| ret void | ||
| } | ||
|
|
||
| @unspecified = external thread_local global i32 | ||
|
|
||
| define ptr @test_la_tls_desc() nounwind { | ||
| ; LARGEDESC-LABEL: test_la_tls_desc: | ||
| ; LARGEDESC: pcalau12i [[REG1:\$[a-z0-9]+]], %desc_pc_hi20(unspecified) | ||
| ; LARGEDESC-NEXT: addi.d [[REG2:\$[a-z0-9]+]], $zero, %desc_pc_lo12(unspecified) | ||
| ; LARGEDESC-NEXT: lu32i.d [[REG2]], %desc64_pc_lo20(unspecified) | ||
| ; LARGEDESC-NEXT: lu52i.d [[REG2]], [[REG2]], %desc64_pc_hi12(unspecified) | ||
| entry: | ||
| ret ptr @unspecified | ||
| } | ||
Oops, something went wrong.
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.