[PATCH] clang-cl: Merge adjacent single-line __asm blocks

Reid Kleckner rnk at google.com
Wed Jul 23 17:41:33 PDT 2014


Nice!

================
Comment at: lib/Parse/ParseStmtAsm.cpp:413-416
@@ -402,5 +412,6 @@
       } else if (!InAsmComment && Tok.is(tok::r_brace)) {
-        // Single-line asm always ends when a closing brace is seen.
-        // FIXME: This is compatible with Apple gcc's -fasm-blocks; what
-        // does MSVC do here?
-        break;
+        // Single-line asm always ends when a closing brace is seen in
+        // Apple gcc style -fasm-blocks mode.  But in MSVC mode, braces
+        // only participate in brace matching and separating the asm
+        // statements.
+        if (!BraceNesting || !getLangOpts().MicrosoftExt)
----------------
Apple's gcc was always attempting to implement MSVC's asm block behavior.  I don't think we need to emulate Apple gcc, especially now that it is dead for good.  I would drop the MicrosoftExt check here.

================
Comment at: test/CodeGen/ms-inline-asm.c:2
@@ -1,3 +1,3 @@
 // REQUIRES: x86-registered-target
-// RUN: %clang_cc1 %s -triple i386-apple-darwin10 -fasm-blocks -emit-llvm -o - | FileCheck %s
+// RUN: %clang_cc1 %s -triple i386-apple-darwin10 -fasm-blocks -fms-extensions -emit-llvm -o - | FileCheck %s
 
----------------
If you agree with the other comment, remember to revert this flag change.

================
Comment at: test/CodeGen/ms-inline-asm.c:147
@@ -152,5 +146,3 @@
 // CHECK: t15
-// CHECK: call void asm sideeffect inteldialect "mov eax, dword ptr $0", "*m,~{eax},~{dirflag},~{fpsr},~{flags}"(i32* %{{.*}})
-// CHECK: call void asm sideeffect inteldialect "mov eax, $0", "r,~{eax},~{dirflag},~{fpsr},~{flags}"(i32* %{{.*}})
-// CHECK: call void asm sideeffect inteldialect "mov eax, $0", "r,~{eax},~{dirflag},~{fpsr},~{flags}"(i32* @{{.*}})
+// CHECK: call void asm sideeffect inteldialect "mov eax, dword ptr $0\0A\09mov eax, $1\0A\09mov eax, $2", "*m,r,r,~{eax},~{dirflag},~{fpsr},~{flags}"(i32* %{{.*}}, i32* %{{.*}}, i32* @{{.*}})
 }
----------------
A lot of these changes make the tests harder to read and understand.

The tests from here on down are mostly testing the name lookup, and I think are best structured along the lines of:
  { __asm mov eax, WeirdCXXIdentifier }
  // CHECK: call void asm ...
  { __asm mov eax, WeirdCXX::Identifier }
  // CHECK: call void asm ...

That way we can keep the CHECK lines separate.

http://reviews.llvm.org/D4598






More information about the cfe-commits mailing list