[llvm] [AVR] Force relocations for non-encodable jumps (PR #121498)
Patryk Wychowaniec via llvm-commits
llvm-commits at lists.llvm.org
Thu Jan 2 23:20:11 PST 2025
================
@@ -60,31 +70,37 @@ static void unsigned_width(unsigned Width, uint64_t Value,
Ctx->reportError(Fixup.getLoc(), Diagnostic);
}
+
+ return false;
}
/// Adjusts the value of a branch target before fixup application.
static void adjustBranch(unsigned Size, const MCFixup &Fixup, uint64_t &Value,
MCContext *Ctx) {
// We have one extra bit of precision because the value is rightshifted by
// one.
- unsigned_width(Size + 1, Value, std::string("branch target"), Fixup, Ctx);
+ checkUnsignedWidth(Size + 1, Value, std::string("branch target"), Fixup, Ctx);
// Rightshifts the value by one.
AVR::fixups::adjustBranchTarget(Value);
}
/// Adjusts the value of a relative branch target before fixup application.
-static void adjustRelativeBranch(unsigned Size, const MCFixup &Fixup,
- uint64_t &Value, MCContext *Ctx) {
+static bool adjustRelativeBranch(unsigned Size, const MCFixup &Fixup,
+ uint64_t &Value, MCContext *Ctx,
+ const MCSubtargetInfo *STI = nullptr) {
// Jumps are relative to the current instruction.
Value -= 2;
// We have one extra bit of precision because the value is rightshifted by
// one.
Size += 1;
- if (!isIntN(Size, Value) &&
- Ctx->getSubtargetInfo()->hasFeature(AVR::FeatureWrappingRjmp)) {
+ if (!STI) {
----------------
Patryk27 wrote:
There's two contexts this function is called from:
- from within `adjustFixupValue()`, where we're gotten `MCContext *Ctx`,
- from within `shouldForceRelocation()`, where we're gotten only `const MCSubtargetInfo *STI`.
This `if (!STI)` part is invoked when we're being called from `adjustFixupValue()` and it just fetches `STI` from the `Ctx`, since it's available there. Alternatively we could adjust the call-sites of this function to be `(..., Ctx, Ctx->getSubtargetInfo())`, but I thought automatic substitution would be less error-prone.
https://github.com/llvm/llvm-project/pull/121498
More information about the llvm-commits
mailing list