This is an archive of the discontinued LLVM Phabricator instance.

X86 Asm should produce error messages instead of assertions when it's possible
ClosedPublic

Authored by avt77 on Jul 7 2017, 3:20 AM.

Details

Summary

If we use Intal syntax assembler and deal with negative value of Scale in LEA instruction then Clang crashes (see pr33661 for details).

Diff Detail

Repository
rL LLVM

Event Timeline

avt77 created this revision.Jul 7 2017, 3:20 AM
RKSimon added inline comments.Jul 7 2017, 6:11 AM
lib/Target/X86/AsmParser/X86AsmParser.cpp
532 ↗(On Diff #105609)

Add newlines before/after the function and pass it through clang-format

553 ↗(On Diff #105609)
if (checkScale(ErrMsg))
  return true;
605 ↗(On Diff #105609)
if (checkScale(ErrMsg))
  return true;
test/CodeGen/ARM/arguments-nosplit-double.ll
11 ↗(On Diff #105609)

NFC commit?

test/CodeGen/ARM/arguments-nosplit-i64.ll
11 ↗(On Diff #105609)

NFC commit?

avt77 updated this revision to Diff 105645.Jul 7 2017, 7:55 AM

I removed NFCs from this patch.

RKSimon added inline comments.Jul 9 2017, 4:03 AM
test/MC/X86/intel-syntax-invalid-scale.s
12 ↗(On Diff #105645)

Any idea why this error message is different? Is it worth fixing?

avt77 added inline comments.Jul 11 2017, 3:43 AM
test/MC/X86/intel-syntax-invalid-scale.s
12 ↗(On Diff #105645)

gcc produces the same message like above 3 ones but Clang does what we see. Clang does it automatically (without any my intervation) that's why I decided don't touch it. But I could try to fix.

RKSimon added inline comments.Jul 11 2017, 8:08 AM
test/MC/X86/intel-syntax-invalid-scale.s
12 ↗(On Diff #105645)

Do you think you can easily add it to this patch or would it be better to separate it as a follow up patch?

avt77 added inline comments.Jul 11 2017, 8:21 AM
test/MC/X86/intel-syntax-invalid-scale.s
12 ↗(On Diff #105645)

I'm no sure it's easy but I'll try to do it tomorrow. If I fail...

avt77 added inline comments.Jul 14 2017, 1:47 AM
test/MC/X86/intel-syntax-invalid-scale.s
12 ↗(On Diff #105645)

I need some more time to fix it that's why it's better to do it in the follow up patch.

RKSimon added inline comments.Jul 14 2017, 3:43 AM
lib/Target/X86/AsmParser/X86AsmParser.cpp
129 ↗(On Diff #105645)

Improve the comment to explain that the invalid value will be caught later by checkScale

avt77 updated this revision to Diff 107675.Jul 21 2017, 8:13 AM
avt77 retitled this revision from Clang's assembler crashes if Scale in lea is negative (pr33661) to X86 Asm should produce error messages instead of assertions when it's possible.

This patch replaces assertions with normal diagnostic when it's possible. Now we see normal error messages instead of compiler crashes. It should close PR33861, PR33862 and PR33661. In addition the patch prepares tests for D35621.

davide accepted this revision.Jul 24 2017, 8:35 AM

LGTM but please test with assertions on :)

This revision is now accepted and ready to land.Jul 24 2017, 8:35 AM
RKSimon accepted this revision.Jul 24 2017, 10:47 AM

LGTM with one minor

test/MC/X86/intel-syntax2.s
2 ↗(On Diff #107675)

Very minor but please call this file intel-syntax-3.s (we already have a intel-syntax-2.s).

This revision was automatically updated to reflect the committed changes.