[PATCH] ms-inline-asm: Scope inline asm labels to functions

Ehsan Akhgari ehsan.akhgari at gmail.com
Fri Jul 18 13:41:13 PDT 2014


================
Comment at: lib/Parse/ParseStmtAsm.cpp:308-312
@@ -291,1 +307,7 @@
     assert(!SpellingInvalid && "spelling was invalid after correct parse?");
+    if (isNewStatement && Tok.is(tok::identifier) && i + 1 < e &&
+        AsmToks[i + 1].is(tok::colon)) {
+      // Encountered a label
+      const Sema::MSAsmLabelEntry& Entry = Actions.GetMSAsmLabel(TokenSpelling, Tok.getLocation(), true);
+      TokenSpelling = Entry.InternalName;
+    }
----------------
Reid Kleckner wrote:
> This seems like the responsibility of the assembly parser.  IMO it should call back into clang when it encounters a label in inline assembly mode, and then clang can set up the mapping.
Do we have access to the sema callback there?  AFAICT we don't... :/

================
Comment at: test/CodeGen/ms-inline-asm.c:499-500
@@ +498,4 @@
+void label1() {
+  __asm label:
+  __asm jmp label
+  // CHECK-LABEL: define void @label1
----------------
Reid Kleckner wrote:
> Can you use the __asm { ... } syntax for the test case?  In the future, we need to lower consecutive __asm statements into a single LLVM inline assembly blob, because right now LLVM can insert spills and restores between the two blobs.  In other words, you can't rely on this today:
>   __asm mov eax, x
>   __asm test eax, eax ; eax may be different, but we usually have no reason to spill here
> 
> If you use the __asm { } syntax, we won't have to change this test in the future.
Ah, this reminds me that I intended to work on a patch to merge these __asm blocks.  :-)

http://reviews.llvm.org/D4589






More information about the cfe-commits mailing list