This is an archive of the discontinued LLVM Phabricator instance.

Fix conflict for referencing "flags" variable in X86 assembly syntax
ClosedPublic

Authored by myatsina on Jul 26 2015, 10:06 AM.

Details

Summary

This asm instruction passes compilation:
mov eax, flags2

This asm instruction fails compilation:
mov eax, flags

When parsing the latter, the X86AsmParser “flags” should be matched to a memory location and not to the implicit EFLAGS register.

Test case uploaded in review:
http://reviews.llvm.org/D11513

Diff Detail

Repository
rL LLVM

Event Timeline

myatsina updated this revision to Diff 30656.Jul 26 2015, 10:06 AM
myatsina retitled this revision from to Fix conflict for referencing "flags" variable in X86 assembly syntax.
myatsina updated this object.
myatsina added reviewers: rnk, MatzeB.
myatsina set the repository for this revision to rL LLVM.
myatsina added a subscriber: llvm-commits.

Test case is in the following review:

http://reviews.llvm.org/D11513

myatsina updated this object.Jul 26 2015, 10:11 AM
rnk added inline comments.Jul 27 2015, 11:05 AM
lib/Target/X86/AsmParser/X86AsmParser.cpp
808 ↗(On Diff #30656)

I don't think you need the helper method in this case. I expect there will only ever be one caller, so you can just inline it.

922 ↗(On Diff #30656)

I'm thinking:

// The "flags" register cannot be referenced directly. Treat it as an identifier instead.
if (isParsingInlineAsm() && RegNo == X86::EFLAGS)
  RegNo = 0;
myatsina updated this revision to Diff 30825.Jul 28 2015, 9:19 AM

I've added "isParsingIntelSyntax" because we should not encounter this issue in att syntax (for att memory location has a $ sign - $flags)

lib/Target/X86/AsmParser/X86AsmParser.cpp
915 ↗(On Diff #30825)

I've added "isParsingIntelSyntax" because we should not encounter this issue in att syntax (for att memory location has a $ sign - $flags)

rnk accepted this revision.Jul 28 2015, 9:23 AM
rnk edited edge metadata.

lgtm

This revision is now accepted and ready to land.Jul 28 2015, 9:23 AM
This revision was automatically updated to reflect the committed changes.