[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
This commit is contained in:
Ayke van Laethem 2020-04-19 20:58:36 +02:00
parent d332ec9209
commit ff4817ec2a
No known key found for this signature in database
GPG Key ID: E97FF5335DFDFDED
2 changed files with 1045 additions and 23 deletions

View File

@ -91,8 +91,6 @@ static void adjustRelativeBranch(unsigned Size, const MCFixup &Fixup,
// one.
signed_width(Size + 1, Value, std::string("branch target"), Fixup, Ctx);
Value -= 2;
// Rightshifts the value by one.
AVR::fixups::adjustBranchTarget(Value);
}
@ -249,27 +247,6 @@ void AVRAsmBackend::adjustFixupValue(const MCFixup &Fixup,
uint64_t Size = AVRAsmBackend::getFixupKindInfo(Fixup.getKind()).TargetSize;
unsigned Kind = Fixup.getKind();
// Parsed LLVM-generated temporary labels are already
// adjusted for instruction size, but normal labels aren't.
//
// To handle both cases, we simply un-adjust the temporary label
// case so it acts like all other labels.
if (const MCSymbolRefExpr *A = Target.getSymA()) {
if (A->getSymbol().isTemporary()) {
switch (Kind) {
case FK_Data_1:
case FK_Data_2:
case FK_Data_4:
case FK_Data_8:
// Don't shift value for absolute addresses.
break;
default:
Value += 2;
}
}
}
switch (Kind) {
default:
llvm_unreachable("unhandled fixup");

File diff suppressed because it is too large Load Diff