Subzero: Remove IceString.

The purpose is to get control over excess string creation and deletion, especially when the strings are long enough to involve malloc/free.

Strings that interface with the outside world, or used for dump/debug, are now explicitly std::string.

Variable names and node names are represented as string IDs and pooled locally in the CFG.  (In a non-DUMP build, this pool should always be empty.)

Other strings that are used across functions are represented as string IDs and pooled globally in the GlobalContext.

The --dump-strings flag allows these strings to be dumped for sanity checking, even in a MINIMAL build.  In a MINIMAL build, the set of strings includes external symbol names, intrinsic names, helper function names, and label names of pooled constants to facilitate deterministic ELF string table output.  For now, it also includes jump table entry names until that gets sorted out.

Constants are fixed so that the name and pooled fields are properly immutable after the constant is fully initialized.

BUG= https://bugs.chromium.org/p/nativeclient/issues/detail?id=4360
R=jpp@chromium.org

Review URL: https://codereview.chromium.org/1838753002 .
diff --git a/src/IceTargetLowering.h b/src/IceTargetLowering.h
index b775d92..03a8cb2 100644
--- a/src/IceTargetLowering.h
+++ b/src/IceTargetLowering.h
@@ -57,7 +57,8 @@
       /* Use llvm_unreachable instead of report_fatal_error, which gives       \
          better stack traces. */                                               \
       llvm_unreachable(                                                        \
-          ("Not yet implemented: " + Instr->getInstName()).c_str());           \
+          (std::string("Not yet implemented: ") + Instr->getInstName())        \
+              .c_str());                                                       \
       abort();                                                                 \
     }                                                                          \
   } while (0)
@@ -172,6 +173,7 @@
   static void staticInit(GlobalContext *Ctx);
   // Each target must define a public static method:
   //   static void staticInit(GlobalContext *Ctx);
+  static bool shouldBePooled(const class Constant *C);
 
   static std::unique_ptr<TargetLowering> createLowering(TargetArch Target,
                                                         Cfg *Func);
@@ -237,7 +239,7 @@
   virtual Variable *getPhysicalRegister(RegNumT RegNum,
                                         Type Ty = IceType_void) = 0;
   /// Returns a printable name for the register.
-  virtual IceString getRegName(RegNumT RegNum, Type Ty) const = 0;
+  virtual const char *getRegName(RegNumT RegNum, Type Ty) const = 0;
 
   virtual bool hasFramePointer() const { return false; }
   virtual void setHasFramePointer() = 0;
@@ -364,12 +366,11 @@
 
   explicit TargetLowering(Cfg *Func);
   // Applies command line filters to TypeToRegisterSet array.
-  static void
-  filterTypeToRegisterSet(GlobalContext *Ctx, int32_t NumRegs,
-                          SmallBitVector TypeToRegisterSet[],
-                          size_t TypeToRegisterSetSize,
-                          std::function<IceString(RegNumT)> getRegName,
-                          std::function<IceString(RegClass)> getRegClassName);
+  static void filterTypeToRegisterSet(
+      GlobalContext *Ctx, int32_t NumRegs, SmallBitVector TypeToRegisterSet[],
+      size_t TypeToRegisterSetSize,
+      std::function<std::string(RegNumT)> getRegName,
+      std::function<const char *(RegClass)> getRegClassName);
   virtual void lowerAlloca(const InstAlloca *Instr) = 0;
   virtual void lowerArithmetic(const InstArithmetic *Instr) = 0;
   virtual void lowerAssign(const InstAssign *Instr) = 0;
@@ -583,13 +584,13 @@
   virtual ~TargetDataLowering();
 
   virtual void lowerGlobals(const VariableDeclarationList &Vars,
-                            const IceString &SectionSuffix) = 0;
+                            const std::string &SectionSuffix) = 0;
   virtual void lowerConstants() = 0;
   virtual void lowerJumpTables() = 0;
 
 protected:
   void emitGlobal(const VariableDeclaration &Var,
-                  const IceString &SectionSuffix);
+                  const std::string &SectionSuffix);
 
   /// For now, we assume .long is the right directive for emitting 4 byte emit
   /// global relocations. However, LLVM MIPS usually uses .4byte instead.