-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[LoongArch] Allow delayed decision for ADD/SUB relocations #72960
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
3 commits
Select commit
Hold shift + click to select a range
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
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,38 @@ | ||
# RUN: not llvm-mc --filetype=obj --triple=loongarch64 --mattr=-relax %s -o /dev/null 2>&1 | FileCheck %s --check-prefixes=ERR,NORELAX --implicit-check-not=error: | ||
## TODO: not llvm-mc --filetype=obj --triple=loongarch64 --mattr=+relax %s -o /dev/null 2>&1 | FileCheck %s --check-prefixes=ERR,RELAX --implicit-check-not=error: | ||
|
||
a: | ||
nop | ||
b: | ||
la.pcrel $t0, a | ||
c: | ||
nop | ||
d: | ||
|
||
.data | ||
## Positive subsection numbers | ||
## With relaxation, report an error as c-b is not an assemble-time constant. | ||
# RELAX: :[[#@LINE+1]]:14: error: cannot evaluate subsection number | ||
.subsection c-b | ||
# RELAX: :[[#@LINE+1]]:14: error: cannot evaluate subsection number | ||
.subsection d-b | ||
# RELAX: :[[#@LINE+1]]:14: error: cannot evaluate subsection number | ||
.subsection c-a | ||
|
||
.subsection b-a | ||
.subsection d-c | ||
|
||
## Negative subsection numbers | ||
# NORELAX: :[[#@LINE+2]]:14: error: subsection number -8 is not within [0,2147483647] | ||
# RELAX: :[[#@LINE+1]]:14: error: cannot evaluate subsection number | ||
.subsection b-c | ||
# NORELAX: :[[#@LINE+2]]:14: error: subsection number -12 is not within [0,2147483647] | ||
# RELAX: :[[#@LINE+1]]:14: error: cannot evaluate subsection number | ||
.subsection b-d | ||
# NORELAX: :[[#@LINE+2]]:14: error: subsection number -12 is not within [0,2147483647] | ||
# RELAX: :[[#@LINE+1]]:14: error: cannot evaluate subsection number | ||
.subsection a-c | ||
# ERR: :[[#@LINE+1]]:14: error: subsection number -4 is not within [0,2147483647] | ||
.subsection a-b | ||
# ERR: :[[#@LINE+1]]:14: error: subsection number -4 is not within [0,2147483647] | ||
.subsection c-d |
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,68 @@ | ||
# RUN: llvm-mc --filetype=obj --triple=loongarch64 --mattr=-relax %s \ | ||
# RUN: | llvm-readobj -r -x .data - | FileCheck %s --check-prefix=NORELAX | ||
# RUN: llvm-mc --filetype=obj --triple=loongarch64 --mattr=+relax %s \ | ||
# RUN: | llvm-readobj -r -x .data - | FileCheck %s --check-prefix=RELAX | ||
|
||
# NORELAX: Relocations [ | ||
# NORELAX-NEXT: Section ({{.*}}) .rela.text { | ||
# NORELAX-NEXT: 0x10 R_LARCH_PCALA_HI20 .text 0x0 | ||
# NORELAX-NEXT: 0x14 R_LARCH_PCALA_LO12 .text 0x0 | ||
# NORELAX-NEXT: } | ||
# NORELAX-NEXT: ] | ||
|
||
# NORELAX: Hex dump of section '.data': | ||
# NORELAX-NEXT: 0x00000000 04040004 00000004 00000000 0000000c | ||
# NORELAX-NEXT: 0x00000010 0c000c00 00000c00 00000000 00000808 | ||
# NORELAX-NEXT: 0x00000020 00080000 00080000 00000000 00 | ||
|
||
# RELAX: Relocations [ | ||
# RELAX-NEXT: Section ({{.*}}) .rela.text { | ||
# RELAX-NEXT: 0x10 R_LARCH_PCALA_HI20 .L1 0x0 | ||
# RELAX-NEXT: 0x14 R_LARCH_PCALA_LO12 .L1 0x0 | ||
# RELAX-NEXT: } | ||
# RELAX-NEXT: Section ({{.*}}) .rela.data { | ||
# RELAX-NEXT: 0xF R_LARCH_ADD8 .L3 0x0 | ||
# RELAX-NEXT: 0xF R_LARCH_SUB8 .L2 0x0 | ||
# RELAX-NEXT: 0x10 R_LARCH_ADD16 .L3 0x0 | ||
# RELAX-NEXT: 0x10 R_LARCH_SUB16 .L2 0x0 | ||
# RELAX-NEXT: 0x12 R_LARCH_ADD32 .L3 0x0 | ||
# RELAX-NEXT: 0x12 R_LARCH_SUB32 .L2 0x0 | ||
# RELAX-NEXT: 0x16 R_LARCH_ADD64 .L3 0x0 | ||
# RELAX-NEXT: 0x16 R_LARCH_SUB64 .L2 0x0 | ||
# RELAX-NEXT: } | ||
# RELAX-NEXT: ] | ||
|
||
# RELAX: Hex dump of section '.data': | ||
# RELAX-NEXT: 0x00000000 04040004 00000004 00000000 00000000 | ||
# RELAX-NEXT: 0x00000010 00000000 00000000 00000000 00000808 | ||
# RELAX-NEXT: 0x00000020 00080000 00080000 00000000 00 | ||
|
||
.text | ||
.L1: | ||
nop | ||
.L2: | ||
.align 4 | ||
.L3: | ||
la.pcrel $t0, .L1 | ||
.L4: | ||
ret | ||
|
||
.data | ||
## Not emit relocs | ||
.byte .L2 - .L1 | ||
.short .L2 - .L1 | ||
.word .L2 - .L1 | ||
.dword .L2 - .L1 | ||
## With relaxation, emit relocs because of the .align making the diff variable. | ||
## TODO Handle alignment directive. Why they emit relocs now? They returns | ||
## without folding symbols offset in AttemptToFoldSymbolOffsetDifference(). | ||
.byte .L3 - .L2 | ||
.short .L3 - .L2 | ||
.word .L3 - .L2 | ||
.dword .L3 - .L2 | ||
## TODO | ||
## With relaxation, emit relocs because la.pcrel is a linker-relaxable inst. | ||
.byte .L4 - .L3 | ||
.short .L4 - .L3 | ||
.word .L4 - .L3 | ||
.dword .L4 - .L3 |
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.