Simplify and clean up MC symbol lookup for ARM constant pool values. This fixes
double quoting of ObjC symbol names in constant pool entries.

rdar://8652107

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@118688 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Target/ARM/ARMAsmPrinter.cpp b/lib/Target/ARM/ARMAsmPrinter.cpp
index 174346b..73d3e1c 100644
--- a/lib/Target/ARM/ARMAsmPrinter.cpp
+++ b/lib/Target/ARM/ARMAsmPrinter.cpp
@@ -622,40 +622,40 @@
   int Size = TM.getTargetData()->getTypeAllocSize(MCPV->getType());
 
   ARMConstantPoolValue *ACPV = static_cast<ARMConstantPoolValue*>(MCPV);
-  SmallString<128> Str;
-  raw_svector_ostream OS(Str);
 
+  MCSymbol *MCSym;
   if (ACPV->isLSDA()) {
+    SmallString<128> Str;
+    raw_svector_ostream OS(Str);
     OS << MAI->getPrivateGlobalPrefix() << "_LSDA_" << getFunctionNumber();
+    MCSym = OutContext.GetOrCreateSymbol(OS.str());
   } else if (ACPV->isBlockAddress()) {
-    OS << *GetBlockAddressSymbol(ACPV->getBlockAddress());
+    MCSym = GetBlockAddressSymbol(ACPV->getBlockAddress());
   } else if (ACPV->isGlobalValue()) {
     const GlobalValue *GV = ACPV->getGV();
     bool isIndirect = Subtarget->isTargetDarwin() &&
       Subtarget->GVIsIndirectSymbol(GV, TM.getRelocationModel());
     if (!isIndirect)
-      OS << *Mang->getSymbol(GV);
+      MCSym = Mang->getSymbol(GV);
     else {
       // FIXME: Remove this when Darwin transition to @GOT like syntax.
-      MCSymbol *Sym = GetSymbolWithGlobalValueBase(GV, "$non_lazy_ptr");
-      OS << *Sym;
+      MCSym = GetSymbolWithGlobalValueBase(GV, "$non_lazy_ptr");
 
       MachineModuleInfoMachO &MMIMachO =
         MMI->getObjFileInfo<MachineModuleInfoMachO>();
       MachineModuleInfoImpl::StubValueTy &StubSym =
-        GV->hasHiddenVisibility() ? MMIMachO.getHiddenGVStubEntry(Sym) :
-        MMIMachO.getGVStubEntry(Sym);
+        GV->hasHiddenVisibility() ? MMIMachO.getHiddenGVStubEntry(MCSym) :
+        MMIMachO.getGVStubEntry(MCSym);
       if (StubSym.getPointer() == 0)
         StubSym = MachineModuleInfoImpl::
           StubValueTy(Mang->getSymbol(GV), !GV->hasInternalLinkage());
     }
   } else {
     assert(ACPV->isExtSymbol() && "unrecognized constant pool value");
-    OS << *GetExternalSymbolSymbol(ACPV->getSymbol());
+    MCSym = GetExternalSymbolSymbol(ACPV->getSymbol());
   }
 
   // Create an MCSymbol for the reference.
-  MCSymbol *MCSym = OutContext.GetOrCreateSymbol(OS.str());
   const MCExpr *Expr =
     MCSymbolRefExpr::Create(MCSym, getModifierVariantKind(ACPV->getModifier()),
                             OutContext);