[PATCH] ms-inline-asm: Scope inline asm labels to functions
Reid Kleckner
rnk at google.com
Fri Jul 18 12:39:49 PDT 2014
================
Comment at: include/clang/Sema/Sema.h:3134
@@ +3133,3 @@
+ };
+ const MSAsmLabelEntry& GetMSAsmLabel(StringRef ExternalLabelName,
+ SourceLocation Location,
----------------
micro nit: & on the right.
================
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;
+ }
----------------
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.
================
Comment at: test/CodeGen/ms-inline-asm.c:499-500
@@ +498,4 @@
+void label1() {
+ __asm label:
+ __asm jmp label
+ // CHECK-LABEL: define void @label1
----------------
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.
http://reviews.llvm.org/D4589
More information about the cfe-commits
mailing list