MS inline asm: Filter MXCSR out of the inferred clobber list

Since r295004, LLVM has started modelling this new register, but we
don't have GCC constraint inline asm spellings for it yet.

llvm-svn: 295107
This commit is contained in:
Reid Kleckner 2017-02-14 21:38:17 +00:00
parent 2e945ebb13
commit fb9f647e5f
2 changed files with 13 additions and 4 deletions

View File

@ -621,10 +621,11 @@ StmtResult Parser::ParseMicrosoftAsmStatement(SourceLocation AsmLoc) {
MII.get(), IP.get(), Callback))
return StmtError();
// Filter out "fpsw". Clang doesn't accept it, and it always lists flags and
// fpsr as clobbers.
auto End = std::remove(Clobbers.begin(), Clobbers.end(), "fpsw");
Clobbers.erase(End, Clobbers.end());
// Filter out "fpsw" and "mxcsr". They aren't valid GCC asm clobber
// constraints. Clang always adds fpsr to the clobber list anyway.
llvm::erase_if(Clobbers, [](const std::string &C) {
return C == "fpsw" || C == "mxcsr";
});
// Build the vector of clobber StringRefs.
ClobberRefs.insert(ClobberRefs.end(), Clobbers.begin(), Clobbers.end());

View File

@ -649,6 +649,14 @@ void label6(){
// CHECK: call void asm sideeffect inteldialect "jmp {{.*}}__MSASMLABEL_.${:uid}__label\0A\09{{.*}}__MSASMLABEL_.${:uid}__label:", "~{dirflag},~{fpsr},~{flags}"()
}
// Don't include mxcsr in the clobber list.
void mxcsr() {
char buf[4096];
__asm fxrstor buf
}
// CHECK-LABEL: define void @mxcsr
// CHECK: call void asm sideeffect inteldialect "fxrstor byte ptr $0", "=*m,~{dirflag},~{fpsr},~{flags}"
typedef union _LARGE_INTEGER {
struct {
unsigned int LowPart;