-
Notifications
You must be signed in to change notification settings - Fork 14.6k
[ARM] support -mlong-calls -fPIC on arm32 #39970 #147313
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
Open
jiangxuezhi
wants to merge
1
commit into
llvm:main
Choose a base branch
from
jiangxuezhi:mlong-call
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+73
−2
Open
Changes from all commits
Commits
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 |
---|---|---|
|
@@ -4,6 +4,9 @@ | |
; RUN: llc -mtriple=thumb-- -mcpu=cortex-a8 -relocation-model=static %s -o - -O0 | FileCheck -check-prefix=NO-OPTION %s | ||
; RUN: llc -mtriple=thumb-- -mcpu=cortex-a8 -relocation-model=static %s -o - -O0 -mattr=+long-calls | FileCheck -check-prefix=LONGCALL %s | ||
; RUN: llc -mtriple=thumb-- -mcpu=cortex-a8 -relocation-model=static %s -o - -O0 -mattr=-long-calls | FileCheck -check-prefix=NO-LONGCALL %s | ||
; RUN: llc -mtriple=arm-linux-gnueabi -mcpu=cortex-a8 -relocation-model=pic %s -o - -O0 -mattr=+long-calls | FileCheck -check-prefix=PIC-O0-LONGCALL %s | ||
; RUN: llc -mtriple=arm-linux-gnueabi -mcpu=cortex-a8 -relocation-model=pic %s -o - -O1 -mattr=+long-calls | FileCheck -check-prefix=PIC-LONGCALL %s | ||
; RUN: llc -mtriple=arm-linux-gnueabi -mcpu=cortex-a8 -relocation-model=pic %s -o - -O2 -mattr=+long-calls | FileCheck -check-prefix=PIC-LONGCALL %s | ||
|
||
; NO-OPTION-LABEL: {{_?}}caller0 | ||
; NO-OPTION: ldr [[R0:r[0-9]+]], [[L0:.*]] | ||
|
@@ -46,4 +49,62 @@ entry: | |
|
||
declare void @callee0() | ||
|
||
; PIC-O0-LONGCALL-LABEL: global_func: | ||
; PIC-O0-LONGCALL: bx lr | ||
|
||
; PIC-LONGCALL-LABEL: global_func: | ||
; PIC-LONGCALL: bx lr | ||
define void @global_func() { | ||
entry: | ||
ret void | ||
} | ||
|
||
; PIC-O0-LONGCALL-LABEL: test_global: | ||
; PIC-O0-LONGCALL: push {r11, lr} | ||
; PIC-O0-LONGCALL: ldr r0, [[GOT_LABEL:.*]] | ||
; PIC-O0-LONGCALL: ldr r0, [pc, r0] | ||
; PIC-O0-LONGCALL: blx r0 | ||
; PIC-O0-LONGCALL: pop {r11, pc} | ||
; PIC-O0-LONGCALL: [[GOT_LABEL]]: | ||
; PIC-O0-LONGCALL: .long global_func(GOT_PREL) | ||
|
||
; PIC-LONGCALL-LABEL: test_global: | ||
; PIC-LONGCALL: push {r11, lr} | ||
; PIC-LONGCALL: ldr r0, [[GOT_LABEL:.*]] | ||
; PIC-LONGCALL: ldr r0, [pc, r0] | ||
; PIC-LONGCALL: blx r0 | ||
; PIC-LONGCALL: pop {r11, pc} | ||
; PIC-LONGCALL: [[GOT_LABEL]]: | ||
; PIC-LONGCALL: .long global_func(GOT_PREL) | ||
define void @test_global() { | ||
entry: | ||
call void @global_func() | ||
ret void | ||
} | ||
|
||
; PIC-O0-LONGCALL-LABEL: test_memset: | ||
; PIC-O0-LONGCALL: push {r11, lr} | ||
; PIC-O0-LONGCALL: ldr r3, [[GOT_LABEL:.*]] | ||
; PIC-O0-LONGCALL: ldr r3, [pc, r3] | ||
; PIC-O0-LONGCALL: blx r3 | ||
; PIC-O0-LONGCALL: pop {r11, pc} | ||
; PIC-O0-LONGCALL: [[GOT_LABEL]]: | ||
; PIC-O0-LONGCALL: .long memset(GOT_PREL) | ||
|
||
; PIC-LONGCALL-LABEL: test_memset: | ||
; PIC-LONGCALL: push {r11, lr} | ||
; PIC-LONGCALL: ldr r3, [[MEMSET_LABEL:.*]] | ||
; PIC-LONGCALL: add r3, pc, r3 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The -O1 code is wrong. The -O0 code is also wrong. Look at what we do for something like |
||
; PIC-LONGCALL: blx r3 | ||
; PIC-LONGCALL: pop {r11, pc} | ||
; PIC-LONGCALL: [[MEMSET_LABEL]]: | ||
; PIC-LONGCALL: .long memset | ||
declare void @llvm.memset.p0.i32(ptr nocapture writeonly, i8, i32, i1 immarg) | ||
|
||
define void @test_memset(ptr %dst, i8 %val, i32 %len) { | ||
entry: | ||
call void @llvm.memset.p0.i32(ptr %dst, i8 %val, i32 %len, i1 false) | ||
ret void | ||
} | ||
|
||
attributes #0 = { "target-features"="+long-calls" } |
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.
You don't need both -O1 and -O2; -O0 is special in this context because it triggers globalisel/fastisel.
Please add RUN lines for execute-only, so we can see they work.
Please regenerate the CHECK lines with update_llc_test_checks.py, so it's easier to read/update.