[llvm] f4bb62e - [JITLink][RISCV] Support relaxable edges without relaxation pass

Job Noorman via llvm-commits llvm-commits at lists.llvm.org
Mon Jun 26 00:44:52 PDT 2023


Author: Job Noorman
Date: 2023-06-26T09:41:20+02:00
New Revision: f4bb62e85c167c49dfc4027a684b230f75c39374

URL: https://github.com/llvm/llvm-project/commit/f4bb62e85c167c49dfc4027a684b230f75c39374
DIFF: https://github.com/llvm/llvm-project/commit/f4bb62e85c167c49dfc4027a684b230f75c39374.diff

LOG: [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

Added: 
    

Modified: 
    llvm/lib/ExecutionEngine/JITLink/ELF_riscv.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/ExecutionEngine/JITLink/ELF_riscv.cpp b/llvm/lib/ExecutionEngine/JITLink/ELF_riscv.cpp
index d07b30ffa48c5..69aa2d2740752 100644
--- a/llvm/lib/ExecutionEngine/JITLink/ELF_riscv.cpp
+++ b/llvm/lib/ExecutionEngine/JITLink/ELF_riscv.cpp
@@ -233,6 +233,8 @@ class ELFJITLinker_riscv : public JITLinker<ELFJITLinker_riscv> {
           (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 @@ class ELFJITLinker_riscv : public JITLinker<ELFJITLinker_riscv> {
       *(little32_t *)FixupPtr = Word32;
       break;
     }
+    case AlignRelaxable:
+      // Ignore when the relaxation pass did not run
+      break;
     }
     return Error::success();
   }


        


More information about the llvm-commits mailing list