This revision was automatically updated to reflect the committed changes.
Closed by commit rL256545: [ms inline asm] Add support for label names with '$' 
chars (authored by myatsina).

Changed prior to commit:
  http://reviews.llvm.org/D15795?vs=43692&id=43718#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D15795

Files:
  cfe/trunk/lib/Sema/SemaStmtAsm.cpp
  cfe/trunk/test/CodeGen/ms-inline-asm.c

Index: cfe/trunk/lib/Sema/SemaStmtAsm.cpp
===================================================================
--- cfe/trunk/lib/Sema/SemaStmtAsm.cpp
+++ cfe/trunk/lib/Sema/SemaStmtAsm.cpp
@@ -750,7 +750,15 @@
     // Create an internal name for the label.  The name should not be a valid 
mangled
     // name, and should be unique.  We use a dot to make the name an invalid 
mangled
     // name.
-    OS << "__MSASMLABEL_." << MSAsmLabelNameCounter++ << "__" << 
ExternalLabelName;
+    OS << "__MSASMLABEL_." << MSAsmLabelNameCounter++ << "__";
+    for (auto it = ExternalLabelName.begin(); it != ExternalLabelName.end();
+         ++it) {
+      OS << *it;
+      if (*it == '$') {
+        // We escape '$' in asm strings by replacing it with "$$"
+        OS << '$';
+      }
+    }
     Label->setMSAsmLabel(OS.str());
   }
   if (AlwaysCreate) {
Index: cfe/trunk/test/CodeGen/ms-inline-asm.c
===================================================================
--- cfe/trunk/test/CodeGen/ms-inline-asm.c
+++ cfe/trunk/test/CodeGen/ms-inline-asm.c
@@ -616,6 +616,15 @@
   // CHECK: call void asm sideeffect inteldialect 
"{{.*}}__MSASMLABEL_.4__label:\0A\09mov eax, {{.*}}__MSASMLABEL_.4__label", 
"~{eax},~{dirflag},~{fpsr},~{flags}"()
 }
 
+void label5() {
+  __asm {
+    jmp dollar_label$
+    dollar_label$:
+  }
+  // CHECK-LABEL: define void @label5
+  // CHECK: call void asm sideeffect inteldialect "jmp 
{{.*}}__MSASMLABEL_.5__dollar_label$$\0A\09{{.*}}__MSASMLABEL_.5__dollar_label$$:",
 "~{dirflag},~{fpsr},~{flags}"()
+}
+
 typedef union _LARGE_INTEGER {
   struct {
     unsigned int LowPart;


Index: cfe/trunk/lib/Sema/SemaStmtAsm.cpp
===================================================================
--- cfe/trunk/lib/Sema/SemaStmtAsm.cpp
+++ cfe/trunk/lib/Sema/SemaStmtAsm.cpp
@@ -750,7 +750,15 @@
     // Create an internal name for the label.  The name should not be a valid mangled
     // name, and should be unique.  We use a dot to make the name an invalid mangled
     // name.
-    OS << "__MSASMLABEL_." << MSAsmLabelNameCounter++ << "__" << ExternalLabelName;
+    OS << "__MSASMLABEL_." << MSAsmLabelNameCounter++ << "__";
+    for (auto it = ExternalLabelName.begin(); it != ExternalLabelName.end();
+         ++it) {
+      OS << *it;
+      if (*it == '$') {
+        // We escape '$' in asm strings by replacing it with "$$"
+        OS << '$';
+      }
+    }
     Label->setMSAsmLabel(OS.str());
   }
   if (AlwaysCreate) {
Index: cfe/trunk/test/CodeGen/ms-inline-asm.c
===================================================================
--- cfe/trunk/test/CodeGen/ms-inline-asm.c
+++ cfe/trunk/test/CodeGen/ms-inline-asm.c
@@ -616,6 +616,15 @@
   // CHECK: call void asm sideeffect inteldialect "{{.*}}__MSASMLABEL_.4__label:\0A\09mov eax, {{.*}}__MSASMLABEL_.4__label", "~{eax},~{dirflag},~{fpsr},~{flags}"()
 }
 
+void label5() {
+  __asm {
+    jmp dollar_label$
+    dollar_label$:
+  }
+  // CHECK-LABEL: define void @label5
+  // CHECK: call void asm sideeffect inteldialect "jmp {{.*}}__MSASMLABEL_.5__dollar_label$$\0A\09{{.*}}__MSASMLABEL_.5__dollar_label$$:", "~{dirflag},~{fpsr},~{flags}"()
+}
+
 typedef union _LARGE_INTEGER {
   struct {
     unsigned int LowPart;
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to