This is an archive of the discontinued LLVM Phabricator instance.

[AVR] Fix incorrect decoding of conditional branch instructions
ClosedPublic

Authored by benshi001 on Jan 1 2023, 12:39 AM.

Details

Summary

This patch fixes the inaccurate decoding of the offset operand of
the conditional branch instructions.

Diff Detail

Event Timeline

benshi001 created this revision.Jan 1 2023, 12:39 AM
Herald added a project: Restricted Project. · View Herald TranscriptJan 1 2023, 12:39 AM
benshi001 requested review of this revision.Jan 1 2023, 12:39 AM

We can not test this in llvm/test/MC/AVR/, since the llvm-objdump decodes all addresses/offsets (before linking) to zeros. We have to test them in lld/test/ELF/.

benshi001 updated this revision to Diff 487056.Jan 6 2023, 11:28 PM
benshi001 edited the summary of this revision. (Show Details)
benshi001 added inline comments.Jan 6 2023, 11:33 PM
llvm/test/MC/AVR/inst-brbc.s
19

The llvm-objdump's option --no-aliases has not been implemented on AVR. So we can not decoded to their original forms.

The conditional branch instructions are defined in two ways:

  1. Defined as stand alone instructions: such as breq, brne, brlo, ...
  2. Defined as aliases of brbc/brbs, such brbs, brbc, brid, brie, ...

The above two situations are both tested in current patch.

ping ...

This patch block another patch (https://reviews.llvm.org/D141197) which has already been approved. If this one can be accepted, all known dissassembler bugs should be fixed.

MaskRay accepted this revision.Jan 28 2023, 9:32 PM
MaskRay added inline comments.
llvm/lib/Target/AVR/Disassembler/AVRDisassembler.cpp
300

A pair array will be more efficient with so few values. You can use llvm::partition_point to do bisection.

This revision is now accepted and ready to land.Jan 28 2023, 9:32 PM
benshi001 added inline comments.Jan 28 2023, 9:54 PM
llvm/lib/Target/AVR/Disassembler/AVRDisassembler.cpp
300

Thanks. I will change to llvm::partition_point when commiting.

This revision was landed with ongoing or failed builds.Jan 29 2023, 12:28 AM
This revision was automatically updated to reflect the committed changes.