Index: lib/Target/X86/AsmParser/X86AsmParser.cpp =================================================================== --- lib/Target/X86/AsmParser/X86AsmParser.cpp +++ lib/Target/X86/AsmParser/X86AsmParser.cpp @@ -805,6 +805,7 @@ CreateX86AsmInstrumentation(Options, Parser.getContext(), STI)); } + unsigned FixMatchedRegister(unsigned RegNo); bool ParseRegister(unsigned &RegNo, SMLoc &StartLoc, SMLoc &EndLoc) override; void SetFrameRegister(unsigned RegNo) override; @@ -882,6 +883,16 @@ return true; } +unsigned X86AsmParser::FixMatchedRegister(unsigned RegNo) { + + if (isParsingInlineAsm() && RegNo == X86::EFLAGS) { + // Cannot address reg called "flags" - this is just an identifier! + return 0; + } + + return RegNo; +} + bool X86AsmParser::ParseRegister(unsigned &RegNo, SMLoc &StartLoc, SMLoc &EndLoc) { MCAsmParser &Parser = getParser(); @@ -909,6 +920,8 @@ if (RegNo == 0) RegNo = MatchRegisterName(Tok.getString().lower()); + RegNo = FixMatchedRegister(RegNo); + if (!is64BitMode()) { // FIXME: This should be done using Requires and // Requires so "eiz" usage in 64-bit instructions can be also