Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
77fdbb8
Synthesize handles for function addresses with auipc+ld
tomeksowi Aug 18, 2025
60ec4a9
Use auipc+ld/addi for addresses also in non-compReloc
tomeksowi Aug 29, 2025
848ac99
Always record relocation
tomeksowi Aug 29, 2025
65014e2
clear gc info when address is built in register
tomeksowi Sep 1, 2025
b43e790
fix reloc type
tomeksowi Sep 1, 2025
bd0e79c
cleanup: emitAlllocInstr sets idGCref and idOpSize based on attr
tomeksowi Sep 1, 2025
1f016da
remove redundant assert
tomeksowi Sep 1, 2025
80bca29
remove unused debug fields
tomeksowi Sep 1, 2025
c8b605d
Merge branch 'main' into pc-rel-pointers
tomeksowi Oct 23, 2025
289740a
Estimate if data is in range, handle also stores
tomeksowi Oct 24, 2025
41cbc5a
Handle floating data
tomeksowi Oct 24, 2025
5f86c9d
spmi
tomeksowi Oct 24, 2025
b857350
fix comment
tomeksowi Oct 24, 2025
9fa6ef2
fix nullcheck
tomeksowi Oct 27, 2025
4277e8b
AddrNeedsReloc more appropriate for addresses
tomeksowi Oct 27, 2025
7d04735
add assert
tomeksowi Oct 27, 2025
12596e1
use relative pointer synthesizing where possible in genSetRegToConst
tomeksowi Oct 27, 2025
33f0b88
Revert "use relative pointer synthesizing where possible in genSetReg…
tomeksowi Oct 27, 2025
13b6421
Record relocations for loads for indirect calls only when the load ad…
tomeksowi Oct 31, 2025
15fd38b
Merge branch 'main' into pc-rel-pointers
tomeksowi Nov 7, 2025
7f1f98d
Check if direct calls are in range and synthesize the absolute addres…
tomeksowi Nov 12, 2025
809cedf
Remove hardcoded branch offset from genJumpToThrowHlpBlk_la
tomeksowi Nov 12, 2025
f8b8083
asserts
tomeksowi Nov 13, 2025
025883d
Fix genFnEpilog emitting always a relocatable load / func pointer
tomeksowi Nov 13, 2025
5f35980
remove assert
tomeksowi Nov 13, 2025
7e6357e
Fix genProfiling(Enter|Leave)Callback emitting always a relocatable l…
tomeksowi Nov 13, 2025
ab556f8
Centralize checking whether direct call is in range
tomeksowi Nov 13, 2025
e38cf3f
jump stubs
tomeksowi Nov 17, 2025
4c7f286
FitsIn
tomeksowi Nov 19, 2025
315c807
Add different relocation types to avoid telling jalr by disasm
tomeksowi Nov 19, 2025
5a5881e
Tell S-type by relocation type instead of disassembling the fixup site
tomeksowi Nov 19, 2025
4b8d487
comment
tomeksowi Nov 19, 2025
2874ec4
Refactor fix-up to use same code structure as arm64
tomeksowi Nov 19, 2025
455bcb7
Merge branch 'main' into pc-rel-pointers (resolve conflicts)
tomeksowi Nov 19, 2025
5b5ce0a
Use PCREL_I for ld
tomeksowi Nov 19, 2025
80a6998
fix musl build
tomeksowi Nov 19, 2025
062652b
lower bool
tomeksowi Nov 20, 2025
917fb8d
Add symbol for PC-relative HI20 relocation and record another relocat…
tomeksowi Nov 20, 2025
398e3b9
FitsInRiscV64
tomeksowi Nov 20, 2025
c2ab644
Explain where auipc combo bounds come from
tomeksowi Nov 20, 2025
abacec7
Merge branch 'main' into pc-rel-pointers
tomeksowi Nov 25, 2025
8c081a6
Fix build
tomeksowi Nov 25, 2025
e5ce631
Fix types and format
tomeksowi Nov 25, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/coreclr/inc/corinfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -902,7 +902,9 @@ enum class CorInfoReloc
LOONGARCH64_JIR, // LoongArch64: pcaddu18i+jirl

// RISCV64 relocs
RISCV64_PC, // RiscV64: auipc
RISCV64_CALL_PLT, // RiscV64: auipc + jalr
RISCV64_PCREL_I, // RiscV64: auipc + I-type
RISCV64_PCREL_S, // RiscV64: auipc + S-type
};

enum CorInfoGCType
Expand Down
21 changes: 17 additions & 4 deletions src/coreclr/inc/utilcode.h
Original file line number Diff line number Diff line change
Expand Up @@ -3353,14 +3353,14 @@ void PutLoongArch64PC12(UINT32 * pCode, INT64 imm);
void PutLoongArch64JIR(UINT32 * pCode, INT64 imm);

//*****************************************************************************
// Extract the PC-Relative offset from auipc + I-type adder (addi/ld/jalr)
// Extract the PC-Relative offset from auipc + I-type or S-type adder (addi/load/store/jalr)
//*****************************************************************************
INT64 GetRiscV64AuipcItype(UINT32 * pCode);
INT64 GetRiscV64AuipcCombo(UINT32 * pCode, bool isStype);

//*****************************************************************************
// Deposit the PC-Relative offset into auipc + I-type adder (addi/ld/jalr)
// Deposit the PC-Relative offset into auipc + I-type or S-type adder (addi/load/store/jalr)
//*****************************************************************************
void PutRiscV64AuipcItype(UINT32 * pCode, INT64 offset);
void PutRiscV64AuipcCombo(UINT32 * pCode, INT64 offset, bool isStype);

//*****************************************************************************
// Returns whether the offset fits into bl instruction
Expand Down Expand Up @@ -3402,6 +3402,19 @@ inline bool FitsInRel28(INT64 val64)
return (val64 >= -0x08000000LL) && (val64 < 0x08000000LL);
}

//*****************************************************************************
// Returns whether the offset fits into a RISC-V auipc + I-type or S-type instruction combo
//*****************************************************************************
inline bool FitsInRiscV64AuipcCombo(INT64 val64)
{
// A PC relative load/store/jalr/addi is 2 instructions, e.g.:
// auipc reg, offset_hi20 # range: [0x80000000, 0x7FFFF000]
// ld reg, reg, offset_lo12 # range: [0xFFFFF800, 0x000007FF]
// Both hi20 and lo12 immediates are sign-extended and combined with a 64-bit adder,
// which shifts the total 32-bit range into the negative by half of the 12-bit immediate range.
return (val64 >= -(1ll << 31) - (1ll << 11)) && (val64 < (1ll << 31) - (1ll << 11));
}

//
// TEB access can be dangerous when using fibers because a fiber may
// run on multiple threads. If the TEB pointer is retrieved and saved
Expand Down
Loading
Loading