This is an archive of the discontinued LLVM Phabricator instance.

[JITLink][RISCV] Implement eh_frame handling
AbandonedPublic

Authored by Hahnfeld on Aug 12 2023, 2:52 PM.

Details

Reviewers
StephenFan
lhames
Summary

This requires adding Delta{32,64} and NegDelta32 edge kinds that cannot be mapped to existing relocations.

Diff Detail

Event Timeline

Hahnfeld created this revision.Aug 12 2023, 2:52 PM
Herald added a project: Restricted Project. · View Herald TranscriptAug 12 2023, 2:52 PM
Hahnfeld requested review of this revision.Aug 12 2023, 2:52 PM
Herald added a project: Restricted Project. · View Herald TranscriptAug 12 2023, 2:52 PM

FWIW I thought we could reuse the ADD* relocations here, but it turns out the documentation had a sign error in the fixup expressions; I corrected that in rGf9d55410e242761d6d8697def28a86342560a60c.

It seems I created a PR implementing essentially the same thing :) Since both patches are equivalent, I don't mind which one gets merged.

My PR has one extra test case that checks if the values for CIE_pointer, address_range, and DW_CFA_advance_loc are patched correctly. It might be worth adding that test case to this patch.

llvm/lib/ExecutionEngine/JITLink/ELF_riscv.cpp
462

This is the same as R_RISCV_32_PCREL so maybe just reuse that one? At some point, R_RISCV_32_PCREL should be renamed to Delta32 though.

473

Add range check?

Hahnfeld added inline comments.Sep 18 2023, 1:06 AM
llvm/lib/ExecutionEngine/JITLink/ELF_riscv.cpp
462

Actually the (positive) Delta edges are not needed at all; the hypothetical AddFDEToCIEEdges discussed in https://reviews.llvm.org/D157802 only needs NegDelta32. That's another reason why I think it's the way to go.

jobnoorman added inline comments.Sep 18 2023, 1:19 AM
llvm/lib/ExecutionEngine/JITLink/ELF_riscv.cpp
462

Ah yes, you're right. I see the point about AddFDEToCIEEdges but I worry a bit about the (non-trivial) code duplication it would introduce. The documentation of EHFrameEdgeFixer mentions that it should be fine to provide Edge::Invalid for unsupported edge kinds but the implementation doesn't seem to check for that. Maybe this could be a way to configure it to not do more than necessary on RISC-V?

Hahnfeld abandoned this revision.Oct 4 2023, 1:17 PM

Superseded by https://github.com/llvm/llvm-project/pull/68253 which implements only one newly needed edge kind.