This is an archive of the discontinued LLVM Phabricator instance.

[mips] Show an error if register number is out of range
ClosedPublic

Authored by atanasyan on Apr 21 2018, 12:55 AM.

Details

Summary

Current code does not check that a register number is in the 0-31 range. Sometimes the parser checks that later for some kinds of instructions, but that leads to unclear / incorrect error messages like that:

% cat test.s
.text
lb $4, 8($32)

% llvm-mc test.s -triple=mips64-unknown-linux
test.s:2:10: error: expected memory with 16-bit signed offset
  lb $4, 8($32)
         ^

Sometimes the parser just crashes:

% cat test.s
.text
lw  $4, 8($32)

% llvm-mc test.s -triple=mips64-unknown-linux

This patch resolves the problem by checking that register number after '$' sign is in the 0-31 range. If the number is out of the range the parser shows the invalid register number error, but treats invalid register number as a normal one to continue parsing and catch other possible errors.

Diff Detail

Repository
rL LLVM

Event Timeline

atanasyan created this revision.Apr 21 2018, 12:55 AM
sdardis accepted this revision.Apr 24 2018, 5:52 AM

LGTM.

This revision is now accepted and ready to land.Apr 24 2018, 5:52 AM
This revision was automatically updated to reflect the committed changes.

Thanks for review.