Skip to content

Commit 118ac53

Browse files
aykevldylanmckay
authored andcommitted
[AVR] Don't adjust for instruction size
I'm not entirely sure why this was ever needed, but when I remove both adjustments all tests still pass. This fixes a bug where a long branch (using the `jmp` instead of the `rjmp` instruction) was incorrectly adjusted by 2 because it jumps to an absolute address instead of a PC-relative address. I could have added AVR::fixup_call to the list of exceptions, but it seemed more sensible to me to just remove this code. Differential Revision: https://reviews.llvm.org/D78459
1 parent bc27c28 commit 118ac53

File tree

2 files changed

+1045
-23
lines changed

2 files changed

+1045
-23
lines changed

llvm/lib/Target/AVR/MCTargetDesc/AVRAsmBackend.cpp

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,6 @@ void adjustRelativeBranch(unsigned Size, const MCFixup &Fixup, uint64_t &Value,
8989
// one.
9090
signed_width(Size + 1, Value, std::string("branch target"), Fixup, Ctx);
9191

92-
Value -= 2;
93-
9492
// Rightshifts the value by one.
9593
AVR::fixups::adjustBranchTarget(Value);
9694
}
@@ -249,27 +247,6 @@ void AVRAsmBackend::adjustFixupValue(const MCFixup &Fixup,
249247
uint64_t Size = AVRAsmBackend::getFixupKindInfo(Fixup.getKind()).TargetSize;
250248

251249
unsigned Kind = Fixup.getKind();
252-
253-
// Parsed LLVM-generated temporary labels are already
254-
// adjusted for instruction size, but normal labels aren't.
255-
//
256-
// To handle both cases, we simply un-adjust the temporary label
257-
// case so it acts like all other labels.
258-
if (const MCSymbolRefExpr *A = Target.getSymA()) {
259-
if (A->getSymbol().isTemporary()) {
260-
switch (Kind) {
261-
case FK_Data_1:
262-
case FK_Data_2:
263-
case FK_Data_4:
264-
case FK_Data_8:
265-
// Don't shift value for absolute addresses.
266-
break;
267-
default:
268-
Value += 2;
269-
}
270-
}
271-
}
272-
273250
switch (Kind) {
274251
default:
275252
llvm_unreachable("unhandled fixup");

0 commit comments

Comments
 (0)