This is an archive of the discontinued LLVM Phabricator instance.

Correct the upper bound for a CBZ/CBNZ branch target.
ClosedPublic

Authored by prakhar on Aug 15 2016, 4:44 AM.

Diff Detail

Repository
rL LLVM

Event Timeline

prakhar updated this revision to Diff 68015.Aug 15 2016, 4:44 AM
prakhar retitled this revision from to Correct the upper bound for a CBZ/CBNZ branch target..
prakhar updated this object.
prakhar added a subscriber: llvm-commits.
olista01 added inline comments.Aug 15 2016, 6:09 AM
lib/Target/ARM/MCTargetDesc/ARMAsmBackend.cpp
582 ↗(On Diff #68015)

The 4-byte offset is being applied a few lines down, so should this actually be checking for the range [4, 130]?

prakhar added inline comments.Aug 15 2016, 7:26 AM
lib/Target/ARM/MCTargetDesc/ARMAsmBackend.cpp
582 ↗(On Diff #68015)

The valid range is actually [2, 130] as offsets of 2 are relaxed to NOP. But yes I forgot to take the offset correction below into account.

prakhar updated this revision to Diff 68035.Aug 15 2016, 7:30 AM

Use the offset bounds before 4-byte correction

olista01 added inline comments.Aug 15 2016, 7:35 AM
test/MC/ARM/thumb-cb-negative-offsets.s
23 ↗(On Diff #68035)

The label is in-range of this instruction.

26 ↗(On Diff #68035)

This should probably be a nop, since we are branching to it. I'd suggest making this two nops, with a label for each, so that you can test the exact bound on the offset for both instructions.

prakhar added inline comments.Aug 15 2016, 8:02 AM
test/MC/ARM/thumb-cb-negative-offsets.s
23 ↗(On Diff #68035)

Yes, that is deliberate to test that this will not cause an error unlike the preceding instruction.

26 ↗(On Diff #68035)

Okay.

prakhar updated this revision to Diff 68037.Aug 15 2016, 8:05 AM

Clarify the upper bound tests

olista01 added inline comments.Aug 15 2016, 8:50 AM
test/MC/ARM/thumb-cb-negative-offsets.s
27 ↗(On Diff #68037)

This test won't fail if an error is emitted for this instruction. You'll need a CHECK-NOT line to ensure that no further diagnostics are emitted.

prakhar updated this revision to Diff 68143.Aug 16 2016, 12:14 AM

CHECK-NOT added

olista01 accepted this revision.Aug 16 2016, 3:39 AM
olista01 edited edge metadata.

LGTM

This revision is now accepted and ready to land.Aug 16 2016, 3:39 AM
This revision was automatically updated to reflect the committed changes.