This is an archive of the discontinued LLVM Phabricator instance.

MS inline asm: produce "ambiguous" error when encountering "<type> ptr <reg name>"
ClosedPublic

Authored by zizhar on Nov 12 2015, 4:12 AM.

Details

Summary

Currently "<type> ptr <reg name>" treated as <reg name> in MS inline asm, ignoring the "<type> ptr" completely and possibly ignoring the intention of the user.
Fixed llvm to produce "ambiguous" error when encountering "<type> ptr <reg name>" operands.

For example: andpd xmm1,xmmword ptr xmm1 --> andpd xmm1, xmm1
though andpd has 2 possible matching formats - andpd xmm, xmm/m128

Diff Detail

Repository
rL LLVM

Event Timeline

zizhar updated this revision to Diff 40027.Nov 12 2015, 4:12 AM
zizhar retitled this revision from to MS inline asm: produce "ambiguous" error when encountering "<type> ptr <reg name>" .
zizhar updated this object.
zizhar added reviewers: rnk, mcrosier.
zizhar set the repository for this revision to rL LLVM.
zizhar added a subscriber: llvm-commits.
rnk added inline comments.Nov 12 2015, 2:36 PM
lib/Target/X86/AsmParser/X86AsmParser.cpp
1770–1771

I think a better diagnostic would be something like:
expected memory operand after 'ptr', found register operand instead

test/MC/X86/intel-syntax-ambiguous.s
56

Can you add a test case with a GPR operand? This also seems bad:

mov dword ptr eax, ebx

The user should write the following, right?

mov dword ptr [eax], ebx
zizhar updated this revision to Diff 40271.Nov 16 2015, 3:51 AM
zizhar removed rL LLVM as the repository for this revision.

fixed rnk's comments

zizhar set the repository for this revision to rL LLVM.Nov 16 2015, 3:52 AM
rnk accepted this revision.Nov 16 2015, 8:57 AM
rnk edited edge metadata.

lgtm

lib/Target/X86/AsmParser/X86AsmParser.cpp
1770

The broken string should align with the open paren. clang-format can do this.

This revision is now accepted and ready to land.Nov 16 2015, 8:57 AM
zizhar updated this revision to Diff 41214.Nov 26 2015, 1:33 AM
zizhar edited edge metadata.

fixed the error line to how clang-format does it.

This revision was automatically updated to reflect the committed changes.