-
Notifications
You must be signed in to change notification settings - Fork 15.3k
[LLD][ARM] Arm v6-m should not use short Thunks. #118111
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
2 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,57 @@ | ||
| // REQUIRES: arm | ||
| // RUN: rm -rf %t && split-file %s %t && cd %t | ||
| // RUN: llvm-mc -filetype=obj -arm-add-build-attributes -triple=armv6m-none-eabi asm -o v6m.o | ||
| // RUN: ld.lld --script=lds v6m.o -o v6m | ||
| // RUN: llvm-objdump --no-print-imm-hex --no-show-raw-insn -d v6m --triple=armv6m-none-eabi | FileCheck %s | ||
|
|
||
| // RUN: llvm-mc -filetype=obj -arm-add-build-attributes -triple=armv8m.base-none-eabi asm -o v8m.o | ||
| // RUN: ld.lld --script=lds v8m.o -o v8m | ||
| // RUN: llvm-objdump --no-print-imm-hex --no-show-raw-insn -d v8m --triple=armv8m.base-none-eabi | FileCheck --check-prefix=CHECKV8BASE %s | ||
|
|
||
| /// Test that short thunks are not generated for v6-m as this architecture | ||
| /// does not have the B.w instruction. | ||
|
|
||
| //--- asm | ||
| .syntax unified | ||
|
|
||
| .section .text_low, "ax", %progbits | ||
| .thumb | ||
| .type _start, %function | ||
| .balign 4 | ||
| .globl _start | ||
| _start: | ||
| bl far | ||
| .space 0x1000 - (. - _start) | ||
|
|
||
| /// Thunks will be inserted here. They are in short thunk range for a B.w | ||
| /// instruction. Expect v6-M to use a long thunk as v6-M does not have B.w. | ||
| /// Expect v8-m.base to use a short thunk as despite not having Thumb 2 it | ||
| /// does have B.w. | ||
|
|
||
| // CHECK-LABEL: <__Thumbv6MABSLongThunk_far>: | ||
| // CHECK-NEXT: 2000: push {r0, r1} | ||
| // CHECK-NEXT: ldr r0, [pc, #4] | ||
| // CHECK-NEXT: str r0, [sp, #4] | ||
| // CHECK-NEXT: pop {r0, pc} | ||
| // CHECK-NEXT: 01 20 00 01 .word 0x01002001 | ||
|
|
||
| // CHECKV8BASE-LABEL: <__Thumbv7ABSLongThunk_far>: | ||
| // CHECKV8BASE-NEXT: 2000: b.w 0x1002000 <far> | ||
|
|
||
| .section .text_high, "ax", %progbits | ||
| .globl far | ||
| .type far, %function | ||
| .balign 4 | ||
| far: | ||
| bx lr | ||
|
|
||
| //--- lds | ||
|
|
||
| PHDRS { | ||
| low PT_LOAD FLAGS(0x1 | 0x4); | ||
| high PT_LOAD FLAGS(0x1 | 0x4); | ||
| } | ||
| SECTIONS { | ||
| .text_low 0x1000 : { *(.text_low) } | ||
| .text_high 0x1002000 : { *(.text_high) } | ||
| } | ||
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The test passes even without the code change. Is that expected?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Apologies it looks like I forgot to add FileCheck to the objdump for v6-m. Now done, which revealed a typo induced by fumbling a tmux switch buffer.
Tested that this now passes with the patch, and doesn't with an existing lld.