diff --git a/clang/test/CodeGen/ms-inline-asm.c b/clang/test/CodeGen/ms-inline-asm.c index ca9b937a7cde14..00d408f431c41e 100644 --- a/clang/test/CodeGen/ms-inline-asm.c +++ b/clang/test/CodeGen/ms-inline-asm.c @@ -592,13 +592,21 @@ void t41(unsigned short a) { } void t42() { -// CHECK-LABEL: define void @t42 +// CHECK-LABEL: define void @t42( int flags; __asm mov flags, eax // CHECK: mov $0, eax // CHECK: "=*m,~{dirflag},~{fpsr},~{flags}"(i32* %flags) } +void t42b() { +// CHECK-LABEL: define void @t42b( + int mxcsr; + __asm mov mxcsr, eax +// CHECK: mov $0, eax +// CHECK: "=*m,~{dirflag},~{fpsr},~{flags}"(i32* %mxcsr) +} + void t43() { // CHECK-LABEL: define void @t43 C strct; diff --git a/llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp b/llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp index 25be79ec2b1edf..b5fbbc427a29bc 100644 --- a/llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp +++ b/llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp @@ -1112,9 +1112,10 @@ bool X86AsmParser::ParseRegister(unsigned &RegNo, if (RegNo == 0) RegNo = MatchRegisterName(Tok.getString().lower()); - // The "flags" register cannot be referenced directly. + // The "flags" and "mxcsr" registers cannot be referenced directly. // Treat it as an identifier instead. - if (isParsingInlineAsm() && isParsingIntelSyntax() && RegNo == X86::EFLAGS) + if (isParsingInlineAsm() && isParsingIntelSyntax() && + (RegNo == X86::EFLAGS || RegNo == X86::MXCSR)) RegNo = 0; if (!is64BitMode()) {