[PATCH] D138781: [RISCV] Check missed Expected<T> result
Philip Reames via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Dec 7 08:27:04 PST 2022
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGa2c9f12dd6ac: [RISCV][JitLink] Propagate error from Expected<T> result during… (authored by dkurt, committed by reames).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D138781/new/
https://reviews.llvm.org/D138781
Files:
llvm/lib/ExecutionEngine/JITLink/ELF_riscv.cpp
llvm/test/ExecutionEngine/JITLink/RISCV/ELF_pc_indirect.s
Index: llvm/test/ExecutionEngine/JITLink/RISCV/ELF_pc_indirect.s
===================================================================
--- llvm/test/ExecutionEngine/JITLink/RISCV/ELF_pc_indirect.s
+++ llvm/test/ExecutionEngine/JITLink/RISCV/ELF_pc_indirect.s
@@ -38,6 +38,18 @@
.size test_pcrel32, .-test_pcrel32
+# Test R_RISCV_PCREL_HI20 and R_RISCV_PCREL_LO12_S
+# jitlink-check: decode_operand(test_pcrel32_s, 1) = ((external_data - test_pcrel32_s) + 0x800)[31:12]
+# jitlink-check: decode_operand(test_pcrel32_s+4, 2)[11:0] = (external_data - test_pcrel32_s)[11:0]
+ .globl test_pcrel32_s
+ .p2align 1
+ .type test_pcrel32_s, at function
+test_pcrel32_s:
+ auipc a0, %pcrel_hi(external_data)
+ sw a0, %pcrel_lo(test_pcrel32_s)(a0)
+
+ .size test_pcrel32_s, .-test_pcrel32_s
+
# Test R_RISCV_CALL
# jitlink-check: decode_operand(test_call, 1) = ((external_func - test_call) + 0x800)[31:12]
# jitlink-check: decode_operand(test_call+4, 2)[11:0] = (external_func - test_call)[11:0]
Index: llvm/lib/ExecutionEngine/JITLink/ELF_riscv.cpp
===================================================================
--- llvm/lib/ExecutionEngine/JITLink/ELF_riscv.cpp
+++ llvm/lib/ExecutionEngine/JITLink/ELF_riscv.cpp
@@ -302,6 +302,8 @@
// pairs with current relocation R_RISCV_PCREL_LO12_S. So here may need a
// check.
auto RelHI20 = getRISCVPCRelHi20(E);
+ if (!RelHI20)
+ return RelHI20.takeError();
int64_t Value = RelHI20->getTarget().getAddress() +
RelHI20->getAddend() - E.getTarget().getAddress();
int64_t Lo = Value & 0xFFF;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D138781.480929.patch
Type: text/x-patch
Size: 1658 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20221207/2b613bcd/attachment.bin>
More information about the llvm-commits
mailing list