parenthesize symbol names that start with $, fixing X86/dollar-name.ll with
the new asmprinter.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@81269 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/MC/MCExpr.cpp b/lib/MC/MCExpr.cpp
index 3eae6bd..c0ecad0 100644
--- a/lib/MC/MCExpr.cpp
+++ b/lib/MC/MCExpr.cpp
@@ -20,9 +20,20 @@
     OS << cast<MCConstantExpr>(*this).getValue();
     return;
 
-  case MCExpr::SymbolRef:
-    cast<MCSymbolRefExpr>(*this).getSymbol().print(OS, MAI);
+  case MCExpr::SymbolRef: {
+    const MCSymbol &Sym = cast<MCSymbolRefExpr>(*this).getSymbol();
+    
+    // Parenthesize names that start with $ so that they don't look like
+    // absolute names.
+    if (Sym.getName()[0] == '$') {
+      OS << '(';
+      Sym.print(OS, MAI);
+      OS << ')';
+    } else {
+      Sym.print(OS, MAI);
+    }
     return;
+  }
 
   case MCExpr::Unary: {
     const MCUnaryExpr &UE = cast<MCUnaryExpr>(*this);