From f4bb62e85c167c49dfc4027a684b230f75c39374 Mon Sep 17 00:00:00 2001 From: Job Noorman Date: Mon, 26 Jun 2023 09:09:19 +0200 Subject: [PATCH] [JITLink][RISCV] Support relaxable edges without relaxation pass Relaxable edges are created unconditionally, even when the relaxation pass will not run. However, they were not recognized by applyFixup causing them to not be applied. To support configurations without the relaxation pass, this patch adds these relaxable edges to applyFixup: - CallRelaxable: Can be treated as R_RISCV_CALL - AlignRelaxable: Can simply be ignored An alternative could be to unconditionally run the relaxation pass, even in contexts where shouldAddDefaultTargetPasses returns false. However, I could imagine there being use cases for disabling relaxation which wouldn't be possible anymore then. Reviewed By: StephenFan Differential Revision: https://reviews.llvm.org/D153541 --- llvm/lib/ExecutionEngine/JITLink/ELF_riscv.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/llvm/lib/ExecutionEngine/JITLink/ELF_riscv.cpp b/llvm/lib/ExecutionEngine/JITLink/ELF_riscv.cpp index d07b30f..69aa2d2 100644 --- a/llvm/lib/ExecutionEngine/JITLink/ELF_riscv.cpp +++ b/llvm/lib/ExecutionEngine/JITLink/ELF_riscv.cpp @@ -233,6 +233,8 @@ private: (RawInstr & 0xFFF) | Imm20 | Imm10_1 | Imm11 | Imm19_12; break; } + case CallRelaxable: + // Treat as R_RISCV_CALL when the relaxation pass did not run case R_RISCV_CALL_PLT: case R_RISCV_CALL: { int64_t Value = E.getTarget().getAddress() + E.getAddend() - FixupAddress; @@ -451,6 +453,9 @@ private: *(little32_t *)FixupPtr = Word32; break; } + case AlignRelaxable: + // Ignore when the relaxation pass did not run + break; } return Error::success(); } -- 2.7.4