-
Notifications
You must be signed in to change notification settings - Fork 14.8k
[RISCV] Mark More Relocs as Relaxable #151422
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,45 @@ | ||
;; With +relax, J below needs a relocation to ensure the target is correct | ||
;; after linker relaxation. See https://github.com/ClangBuiltLinux/linux/issues/1965 | ||
|
||
; RUN: llc -mtriple=riscv64 -mattr=-relax -filetype=obj < %s \ | ||
; RUN: | llvm-objdump -d -r - | FileCheck %s --check-prefixes=CHECK,NORELAX | ||
; RUN: llc -mtriple=riscv64 -mattr=+relax -filetype=obj < %s \ | ||
; RUN: | llvm-objdump -d -r - | FileCheck %s --check-prefixes=CHECK,RELAX | ||
|
||
;; With +relax, All `j` instructions below need a relocation to ensure the target is correct | ||
;; after linker relaxation. See https://github.com/ClangBuiltLinux/linux/issues/1965 | ||
|
||
; CHECK: j {{.*}} | ||
; RELAX-NEXT: R_RISCV_JAL {{.*}} | ||
; RELAX-NOT: R_RISCV_RELAX | ||
; CHECK-NEXT: auipc ra, 0x0 | ||
; CHECK-NEXT: R_RISCV_CALL_PLT f | ||
; RELAX-NEXT: R_RISCV_RELAX *ABS* | ||
; CHECK-NEXT: jalr ra | ||
; CHECK-NEXT: j {{.*}} | ||
; RELAX-NEXT: R_RISCV_JAL {{.*}} | ||
; RELAX-NOT: R_RISCV_RELAX | ||
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. I believe J is not supposed to be assembler- or linker- relaxable. Then we should not mark it as such. 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 Table Jump Relaxation applies to 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. TIL :) Thanks 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. Even aside from that couldn't jal be relaxed to c.jal and j to c.j (with the former only being available on RV32)? I don't think that's a currently-implemented relaxation, it's only done if the original (pseudo)instruction is a call, but for those that believe in the fun that is linker relaxation it would seem an obvious one to implement. |
||
; CHECK-NEXT: j {{.*}} | ||
; RELAX-NEXT: R_RISCV_JAL .L0 | ||
; RELAX-NEXT: R_RISCV_JAL {{.*}} | ||
; RELAX-NEXT: R_RISCV_RELAX *ABS* | ||
; NORELAX-NEXT: li a0, 0x0 | ||
; RELAX-EMPTY: | ||
|
||
define dso_local noundef signext i32 @main() local_unnamed_addr #0 { | ||
entry: | ||
callbr void asm sideeffect ".option push\0A.option norelax\0Aj $0\0A.option pop\0A", "!i"() | ||
to label %asm.fallthrough [label %label] | ||
callbr void asm sideeffect " | ||
.option push | ||
.option norelax | ||
j $0 | ||
.option pop", | ||
"!i"() to label %asm.fallthrough [label %label] | ||
|
||
asm.fallthrough: ; preds = %entry | ||
tail call void @f() | ||
callbr void asm sideeffect ".option push\0A.option norelax\0Aj $0\0A.option pop\0A", "!i"() | ||
to label %asm.fallthrough [label %label] | ||
callbr void asm sideeffect " | ||
.option push | ||
.option norelax | ||
j $0 | ||
.option pop", | ||
"!i"() to label %asm.fallthrough [label %label] | ||
br label %label | ||
|
||
label: ; preds = %asm.fallthrough, %entry | ||
|
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.