This is an archive of the discontinued LLVM Phabricator instance.

[ARM64] Fix the misleading diagnostic on bad extend amount of reg+reg addressing mode.
AcceptedPublic

Authored by kevin.qin on May 8 2014, 3:11 AM.

Details

Summary

Hi Tim and Jim,

This patch is going to fix Bug 19502 (http://llvm.org/bugs/show_bug.cgi?id=19502). As comments described, I can't simply adding new diagnostic to asmoperand, so I implemented this in C code by a "hack" way. It's the best solution I can image without refactoring whole load/store implementation. Please review, thanks.

Diff Detail

Event Timeline

kevin.qin updated this revision to Diff 9203.May 8 2014, 3:11 AM
kevin.qin retitled this revision from to [ARM64] Fix the misleading diagnostic on bad extend amount of reg+reg addressing mode..
kevin.qin updated this object.
kevin.qin edited the test plan for this revision. (Show Details)
kevin.qin added reviewers: grosbach, t.p.northover.
kevin.qin added a subscriber: Unknown Object (MLST).
t.p.northover edited edge metadata.May 8 2014, 4:29 AM

Hi Kevin,

I don't think that degree of hackery is justified for a slightly better diagnostic. ARM64 already suffers from too much C++ code in the AsmParser, We want to work towards decreasing that rather than making it worse.

Cheers.

Tim.

Hi Tim,

I agree with your point, that the AsmParser in ARM64 is already too
complexity. But for this bug, it can't avoid adding more codes in AsmParser
unless factoring whole address operand of load/store instructions. The
reason why I give up providing a suitably vague warning is that, there's
too many instructions sharing two diagnostics!

feeding diag.s in patch to llvm-mc built by trunk today, you will see

llvm-mc -triple=arm64 -mattr=+neon -assemble -show-encoding <diag.s

.text
<stdin>:1:13: error: index must be a multiple of 4 in range [0, 16380].
ldrb w1 , [x3, w3, sxtw #4]

^

<stdin>:2:13: error: index must be a multiple of 4 in range [0, 16380].
ldrh w1 , [x3, w3, sxtw #4]

^

<stdin>:3:13: error: index must be a multiple of 4 in range [0, 16380].
ldr w1 , [x3, w3, sxtw #4]

^

<stdin>:4:13: error: index must be a multiple of 8 in range [0, 32760].
ldr x1 , [x3, w3, sxtw #4]

^

<stdin>:5:13: error: index must be a multiple of 8 in range [0, 32760].
ldr b1 , [x3, w3, sxtw #4]

^

<stdin>:6:13: error: index must be a multiple of 8 in range [0, 32760].
ldr h1 , [x3, w3, sxtw #4]

^

<stdin>:7:13: error: index must be a multiple of 8 in range [0, 32760].
ldr s1 , [x3, w3, sxtw #4]

^

<stdin>:8:13: error: index must be a multiple of 8 in range [0, 32760].
ldr d1 , [x3, w3, sxtw #4]

^

<stdin>:9:13: error: index must be a multiple of 8 in range [0, 32760].
ldr q1 , [x3, w3, sxtw #1]

^

Each diagnostic will hold too many information and get end-users more
confused. Also, previous misleading diagnostic is for addressing mode [reg,
offset], the suggested offset ranges are incorrect
for 8/16/128 bit loading.
For example, when parsing "ldrb w1, [x3, #4096]", current diagnostic is "error:
index must be a multiple of 4 in range [0, 16380]." But correct index
should be any integer in [0, 4095].
This patch can fix this problem as well.

2014-05-08 19:29 GMT+08:00 Tim Northover <t.p.northover@gmail.com>:

Hi Kevin,

I don't think that degree of hackery is justified for a slightly better
diagnostic. ARM64 already suffers from too much C++ code in the AsmParser,
We want to work towards decreasing that rather than making it worse.

Cheers.

Tim.

http://reviews.llvm.org/D3662

Hi Kevin,

Nevertheless, I'd prefer a vague diagnostic like "invalid offset in memory address" to putting this code in the AsmParser.

If you really want more accurate diagnostics then we need to do in some way that actually improves the code quality, not just the diagnostic quality.

Cheers.

Tim.

kevin.qin updated this revision to Diff 9334.May 13 2014, 12:03 AM
kevin.qin edited edge metadata.

Changed to the vague diagnostic as Tim suggested.

t.p.northover accepted this revision.May 13 2014, 12:18 AM
t.p.northover edited edge metadata.

Hi Kevin,

This patch looks fine. Thanks for changing it like that, I know you were keen on the better diagnostics.

Cheers.

Tim.

This revision is now accepted and ready to land.May 13 2014, 12:18 AM