]> granicus.if.org Git - clang/commitdiff
MS asm: Filter out fpsw clobbers
authorReid Kleckner <reid@kleckner.net>
Thu, 27 Mar 2014 00:00:03 +0000 (00:00 +0000)
committerReid Kleckner <reid@kleckner.net>
Thu, 27 Mar 2014 00:00:03 +0000 (00:00 +0000)
When parsing MS inline assembly, we note that fpsw is an implicit def of
most x87 FP operations, and add it to the clobber list.  However, we
don't recognize fpsw as a gcc register name, and we assert.  Clang
always adds an fpsr clobber, which means the same thing to LLVM, so we
can just use that.

This test case was broken by my LLVM change r196939.

Reviewers: echristo

Differential Revision: http://llvm-reviews.chandlerc.com/D2993

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@204878 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Parse/ParseStmt.cpp
test/CodeGen/ms-inline-asm.c

index 038d7dad0eaa6de6dbddcc93059edb6f311008d1..7254eb3c11733cd08471fae34f3b2377e5db27ac 100644 (file)
@@ -2211,6 +2211,11 @@ StmtResult Parser::ParseMicrosoftAsmStatement(SourceLocation AsmLoc) {
                                Clobbers, MII, IP, 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());
+
   // Build the vector of clobber StringRefs.
   unsigned NumClobbers = Clobbers.size();
   ClobberRefs.resize(NumClobbers);
index 318d509cfa469c384a80aabd0d15ec3b815ca971..6395e428ed6a5fcd3659bdb7e5d4cdf662c335eb 100644 (file)
@@ -460,3 +460,12 @@ void t39() {
   // CHECK: call void asm sideeffect inteldialect "mov eax, [eax] .4", "~{eax},~{dirflag},~{fpsr},~{flags}"()
   // CHECK: call void asm sideeffect inteldialect "mov eax, fs:[$$0] .4", "~{eax},~{dirflag},~{fpsr},~{flags}"()
 }
+
+void t40(float a) {
+  int i;
+  __asm fld a
+  __asm fistp i
+  // CHECK-LABEL: define void @t40
+  // CHECK: call void asm sideeffect inteldialect "fld dword ptr $0", "*m,~{dirflag},~{fpsr},~{flags}"(float* {{.*}})
+  // CHECK: call void asm sideeffect inteldialect "fistp dword ptr $0", "=*m,~{dirflag},~{fpsr},~{flags}"(i32* {{.*}})
+}