Subzero: Fix symbol name mangling. Make flags global.

This cleans up the whole --prefix handling mechanism, so that all mangling is done based on logic in the parser instead of scattered all over the code base.  Another nice side effect is that it allows some getName() style functions to return a const string reference instead of a string copy.

Also, moves ClFlags into a static field of GlobalContext, i.e. makes it global, so that these constant flags can be accessed without having to plumb a GlobalContext object.  Note that some of the ClFlags and ClFlagsExtra plumbing in the compile server classes could be simplified to directly use the corresponding static fields, but this is left mostly as is for now, for when we do a proper separation between core and supplemental flags.

BUG= none
R=jpp@chromium.org

Review URL: https://codereview.chromium.org/1766233002 .
diff --git a/src/IceTargetLoweringARM32.cpp b/src/IceTargetLoweringARM32.cpp
index 3f72052..6efee62 100644
--- a/src/IceTargetLoweringARM32.cpp
+++ b/src/IceTargetLoweringARM32.cpp
@@ -907,18 +907,17 @@
   const IceString CRGotoffName =
       "GOTOFF$" + Func->getFunctionName() + "$" + CRName;
   if (KnownGotoffs.count(CRGotoffName) == 0) {
-    auto *Global = VariableDeclaration::create(Ctx);
+    constexpr bool SuppressMangling = true;
+    auto *Global = VariableDeclaration::create(Ctx, SuppressMangling);
     Global->setIsConstant(true);
     Global->setName(CRName);
-    Global->setSuppressMangling();
 
-    auto *Gotoff = VariableDeclaration::create(Ctx);
+    auto *Gotoff = VariableDeclaration::create(Ctx, SuppressMangling);
     constexpr auto GotFixup = R_ARM_GOTOFF32;
     Gotoff->setIsConstant(true);
-    Gotoff->setName(CRGotoffName);
-    Gotoff->setSuppressMangling();
     Gotoff->addInitializer(VariableDeclaration::RelocInitializer::create(
         Global, {RelocOffset::create(Ctx, 0)}, GotFixup));
+    Gotoff->setName(CRGotoffName);
     Func->addGlobal(Gotoff);
     KnownGotoffs.emplace(CRGotoffName);
   }
@@ -963,7 +962,7 @@
 
 void TargetARM32::loadNamedConstantRelocatablePIC(
     const IceString &Name, Variable *Register,
-    std::function<void(Variable *PC)> Finish, bool SuppressMangling) {
+    std::function<void(Variable *PC)> Finish) {
   assert(SandboxingType == ST_Nonsfi);
   // We makeReg() here instead of getPhysicalRegister() because the latter ends
   // up creating multi-blocks temporaries that liveness fails to validate.
@@ -974,8 +973,6 @@
   auto *AddPcLabel = InstARM32Label::create(Func, this);
   AddPcLabel->setRelocOffset(AddPcReloc);
 
-  const IceString EmitText = Name;
-
   auto *MovwReloc = RelocOffset::create(Ctx);
   auto *MovwLabel = InstARM32Label::create(Func, this);
   MovwLabel->setRelocOffset(MovwReloc);
@@ -994,9 +991,9 @@
   // relocations.
   static constexpr RelocOffsetT PcOffset = -8;
   auto *CRLower = Ctx->getConstantSym(PcOffset, {MovwReloc, AddPcReloc}, Name,
-                                      EmitText + " -16", SuppressMangling);
+                                      Name + " -16");
   auto *CRUpper = Ctx->getConstantSym(PcOffset, {MovtReloc, AddPcReloc}, Name,
-                                      EmitText + " -12", SuppressMangling);
+                                      Name + " -12");
 
   Context.insert(MovwLabel);
   _movw(Register, CRLower);
@@ -5974,9 +5971,9 @@
       // Load floats/doubles from literal pool.
       std::string Buffer;
       llvm::raw_string_ostream StrBuf(Buffer);
-      llvm::cast<Constant>(From)->emitPoolLabel(StrBuf, Ctx);
+      llvm::cast<Constant>(From)->emitPoolLabel(StrBuf);
       llvm::cast<Constant>(From)->setShouldBePooled(true);
-      Constant *Offset = Ctx->getConstantSym(0, StrBuf.str(), true);
+      Constant *Offset = Ctx->getConstantSym(0, StrBuf.str());
       Variable *BaseReg = nullptr;
       if (SandboxingType == ST_Nonsfi) {
         // vldr does not support the [base, index] addressing mode, so we need
@@ -6758,10 +6755,10 @@
 
 template <typename T>
 void emitConstant(
-    Ostream &Str, const GlobalContext *Ctx,
+    Ostream &Str,
     const typename ConstantPoolEmitterTraits<T>::ConstantType *Const) {
   using Traits = ConstantPoolEmitterTraits<T>;
-  Const->emitPoolLabel(Str, Ctx);
+  Const->emitPoolLabel(Str);
   Str << ":\n\t" << Traits::AsmTag << "\t0x";
   T Value = Const->getValue();
   Str.write_hex(Traits::bitcastToUint64(Value));
@@ -6794,7 +6791,7 @@
       continue;
     }
 
-    emitConstant<T>(Str, Ctx, llvm::dyn_cast<typename Traits::ConstantType>(C));
+    emitConstant<T>(Str, llvm::dyn_cast<typename Traits::ConstantType>(C));
   }
 }
 } // end of anonymous namespace