-
Notifications
You must be signed in to change notification settings - Fork 5.2k
Update ImportThunk for community architectures to use PC-relative addressing #121453
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?
Conversation
They now match the ARM64 model we just moved to in dotnet#121352 Also, clean up the ARM64 emitter while we're at it.
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.
Pull Request Overview
This PR refactors the ImportThunk code generation for RiscV64 and LoongArch64 architectures to use a more efficient PC-relative addressing approach for loading the Module* pointer. The changes simplify the code by introducing new EmitLD(Register, ISymbolNode) overloads that emit PC-relative relocations directly in the instruction sequence, eliminating the need for manually managing offset calculations and DIR64 data slots that were required in the previous implementation.
- Removes complex PC-based offset calculations and replaces them with cleaner PC-relative relocations
- Introduces new
EmitLD(Register, ISymbolNode)helper methods in both RiscV64Emitter and LoongArch64Emitter - Simplifies ImportThunk code by removing manual relocation management and offset tracking
- Removes the
_symbolOffsetfield andISymbolNode.Offsetoverride that were needed for alignment workarounds
Reviewed Changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
src/coreclr/tools/aot/ILCompiler.ReadyToRun/Compiler/DependencyAnalysis/ReadyToRun/Target_RiscV64/ImportThunk.cs |
Refactored to use new EmitLD helper for Module* loading, removing manual PC-relative addressing code |
src/coreclr/tools/aot/ILCompiler.ReadyToRun/Compiler/DependencyAnalysis/ReadyToRun/Target_LoongArch64/ImportThunk.cs |
Refactored to use new EmitLD helper for Module* loading, removing manual PC-relative addressing code |
src/coreclr/tools/aot/ILCompiler.ReadyToRun/Compiler/DependencyAnalysis/ReadyToRun/Target_ARM64/ImportThunk.cs |
Removed relocsOnly early return handling as part of code cleanup |
src/coreclr/tools/aot/ILCompiler.ReadyToRun/Compiler/DependencyAnalysis/ReadyToRun/ImportThunk.cs |
Removed _symbolOffset field and related offset adjustment logic no longer needed with new approach |
src/coreclr/tools/Common/Compiler/DependencyAnalysis/Target_RiscV64/RiscV64Emitter.cs |
Added new EmitLD overload for symbol-based loading; simplified EmitJMP to use the new helper |
src/coreclr/tools/Common/Compiler/DependencyAnalysis/Target_LoongArch64/LoongArch64Emitter.cs |
Added new EmitLD overload for symbol-based loading; simplified EmitJMP to use the new helper |
Comments suppressed due to low confidence (1)
src/coreclr/tools/aot/ILCompiler.ReadyToRun/Compiler/DependencyAnalysis/ReadyToRun/Target_RiscV64/ImportThunk.cs:27
- Dead code. The case
Kind.Eageris unreachable because it's already handled by the early return at lines 18-22. This case should be removed as it can never be executed.
case Kind.Eager:
break;
...t/ILCompiler.ReadyToRun/Compiler/DependencyAnalysis/ReadyToRun/Target_RiscV64/ImportThunk.cs
Outdated
Show resolved
Hide resolved
am11
left a comment
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.
LGTM!
cc @dotnet/samsung @LuckyXu-HF @shushanhf
|
Running AOT smoke tests leg (QEMU) against this PR: linux-riscv64: https://github.com/am11/CrossRepoCITesting/actions/runs/19179619151 |
…yAnalysis/ReadyToRun/Target_RiscV64/ImportThunk.cs Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
|
Errors look related: riscv64: loongarch64: |
|
Guess I still need the relocs-only paths. I'll go fix that. |
… during the relocs-only phase
They now match the ARM64 model we just moved to in #121352
Also, clean up the ARM64 import thunk code while we're at it.