Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[AVR] Jumps are off by 2 #102436

Closed
Patryk27 opened this issue Aug 8, 2024 · 8 comments
Closed

[AVR] Jumps are off by 2 #102436

Patryk27 opened this issue Aug 8, 2024 · 8 comments

Comments

@Patryk27
Copy link
Contributor

Patryk27 commented Aug 8, 2024

Hi,

Ever since 6859685 (or, more precisely, 84428da), the AVR backend encodes jumps across basic blocks with an extra offset of 2.

That's related to this check:

if (const auto *SymA = Target.getSymA())

... which wasn't triggered for basic blocks before, but it is now (i.e. shouldForceRelocation() returns false for such jumps now).

I'm working on a pure LLVM reproducer, but the original rustc issue has been reported here - if you compare the *.elf from older toolchain and the newer toolchain, you'll see that calls are alright, but jumps have an extra offset.

@Patryk27
Copy link
Contributor Author

Patryk27 commented Aug 8, 2024

Alright, adding Value -= 1; here:

static void adjustRelativeBranch(unsigned Size, const MCFixup &Fixup,

... seems to solve the problem, but is it the correct solution?

@Patryk27
Copy link
Contributor Author

Patryk27 commented Sep 9, 2024

Issue has been already solved, just forgot to add closes xyz to the commit message.

@Patryk27 Patryk27 closed this as completed Sep 9, 2024
@benshi001
Copy link
Member

Though 86a60e7 has been merged, the fix is incorrect, since the llvm-objdump still has problem, as I have indicated at #102936 (comment)

@benshi001 benshi001 reopened this Sep 17, 2024
@benshi001
Copy link
Member

@Patryk27 If you are busy, please assign this issue to me. I will take a time to find a better solution later this month.

@Patryk27
Copy link
Contributor Author

Ah, right, I forgot about it - feel free to take a stab at it.

@Patryk27 Patryk27 removed their assignment Sep 17, 2024
@benshi001
Copy link
Member

benshi001 commented Sep 18, 2024

@Patryk27 Your fix is good! I have made a mistake, and I have confirmed the output of both llvm-mc -show-encoding and llvm-objdump -d are correct by your patch

@Patryk27
Copy link
Contributor Author

Cool, thanks for checking! 🙂

@benshi001
Copy link
Member

@Patryk27 Though your fix is good, there is still an underlying issue, which I have fixed by #109124. You are appreciated to have a look.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants