[llvm-commits] [llvm] r48800 - in /llvm/trunk: include/llvm/CodeGen/MachineModuleInfo.h include/llvm/Target/TargetAsmInfo.h include/llvm/Target/TargetInstrItineraries.h lib/CodeGen/MachineModuleInfo.cpp lib/CodeGen/PseudoSourceValue.cpp lib/CodeGen/SelectionDAG/ScheduleDAG.cpp lib/Support/APInt.cpp lib/Support/CommandLine.cpp lib/Target/ARM/ARMTargetAsmInfo.cpp lib/Target/CBackend/CBackend.cpp lib/Target/PowerPC/PPCAsmPrinter.cpp lib/Target/X86/X86TargetAsmInfo.cpp utils/TableGen/SubtargetEmitter.cpp

Dan Gohman gohman at apple.com
Tue Mar 25 14:45:14 PDT 2008


Author: djg
Date: Tue Mar 25 16:45:14 2008
New Revision: 48800

URL: http://llvm.org/viewvc/llvm-project?rev=48800&view=rev
Log:
A quick nm audit turned up several fixed tables and objects that were
marked read-write. Use const so that they can be allocated in a
read-only segment.

Modified:
    llvm/trunk/include/llvm/CodeGen/MachineModuleInfo.h
    llvm/trunk/include/llvm/Target/TargetAsmInfo.h
    llvm/trunk/include/llvm/Target/TargetInstrItineraries.h
    llvm/trunk/lib/CodeGen/MachineModuleInfo.cpp
    llvm/trunk/lib/CodeGen/PseudoSourceValue.cpp
    llvm/trunk/lib/CodeGen/SelectionDAG/ScheduleDAG.cpp
    llvm/trunk/lib/Support/APInt.cpp
    llvm/trunk/lib/Support/CommandLine.cpp
    llvm/trunk/lib/Target/ARM/ARMTargetAsmInfo.cpp
    llvm/trunk/lib/Target/CBackend/CBackend.cpp
    llvm/trunk/lib/Target/PowerPC/PPCAsmPrinter.cpp
    llvm/trunk/lib/Target/X86/X86TargetAsmInfo.cpp
    llvm/trunk/utils/TableGen/SubtargetEmitter.cpp

Modified: llvm/trunk/include/llvm/CodeGen/MachineModuleInfo.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/MachineModuleInfo.h?rev=48800&r1=48799&r2=48800&view=diff

==============================================================================
--- llvm/trunk/include/llvm/CodeGen/MachineModuleInfo.h (original)
+++ llvm/trunk/include/llvm/CodeGen/MachineModuleInfo.h Tue Mar 25 16:45:14 2008
@@ -265,7 +265,7 @@
   
   /// getAnchorString - Return a string used to label this descriptor's anchor.
   ///
-  static const char *AnchorString;
+  static const char *const AnchorString;
   virtual const char *getAnchorString() const;
     
 #ifndef NDEBUG
@@ -664,7 +664,7 @@
   
   /// getAnchorString - Return a string used to label this descriptor's anchor.
   ///
-  static const char *AnchorString;
+  static const char *const AnchorString;
   virtual const char *getAnchorString() const;
     
 #ifndef NDEBUG
@@ -701,7 +701,7 @@
   
   /// getAnchorString - Return a string used to label this descriptor's anchor.
   ///
-  static const char *AnchorString;
+  static const char *const AnchorString;
   virtual const char *getAnchorString() const;
     
 #ifndef NDEBUG

Modified: llvm/trunk/include/llvm/Target/TargetAsmInfo.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Target/TargetAsmInfo.h?rev=48800&r1=48799&r2=48800&view=diff

==============================================================================
--- llvm/trunk/include/llvm/Target/TargetAsmInfo.h (original)
+++ llvm/trunk/include/llvm/Target/TargetAsmInfo.h Tue Mar 25 16:45:14 2008
@@ -388,7 +388,7 @@
 
     //===--- CBE Asm Translation Table -----------------------------------===//
 
-    const char** AsmTransCBE; // Defaults to empty
+    const char *const *AsmTransCBE; // Defaults to empty
 
   public:
     TargetAsmInfo();
@@ -664,7 +664,7 @@
     const char *getDwarfExceptionSection() const {
       return DwarfExceptionSection;
     }
-    const char** getAsmCBE() const {
+    const char *const *getAsmCBE() const {
       return AsmTransCBE;
     }
   };

Modified: llvm/trunk/include/llvm/Target/TargetInstrItineraries.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Target/TargetInstrItineraries.h?rev=48800&r1=48799&r2=48800&view=diff

==============================================================================
--- llvm/trunk/include/llvm/Target/TargetInstrItineraries.h (original)
+++ llvm/trunk/include/llvm/Target/TargetInstrItineraries.h Tue Mar 25 16:45:14 2008
@@ -47,14 +47,15 @@
 // used by a target.
 //
 struct InstrItineraryData {
-  InstrStage     *Stages;         // Array of stages selected
-  InstrItinerary *Itineratries;   // Array of itineraries selected
+  const InstrStage     *Stages;         // Array of stages selected
+  const InstrItinerary *Itineratries;   // Array of itineraries selected
 
 //
 // Ctors.
 //
   InstrItineraryData() : Stages(0), Itineratries(0) {}
-  InstrItineraryData(InstrStage *S, InstrItinerary *I) : Stages(S), Itineratries(I) {}
+  InstrItineraryData(const InstrStage *S, const InstrItinerary *I)
+    : Stages(S), Itineratries(I) {}
   
   //
   // isEmpty - Returns true if there are no itineraries.
@@ -64,7 +65,7 @@
   //
   // begin - Return the first stage of the itinerary.
   // 
-  inline InstrStage *begin(unsigned ItinClassIndx) const {
+  inline const InstrStage *begin(unsigned ItinClassIndx) const {
     unsigned StageIdx = Itineratries[ItinClassIndx].First;
     return Stages + StageIdx;
   }
@@ -72,7 +73,7 @@
   //
   // end - Return the last+1 stage of the itinerary.
   // 
-  inline InstrStage *end(unsigned ItinClassIndx) const {
+  inline const InstrStage *end(unsigned ItinClassIndx) const {
     unsigned StageIdx = Itineratries[ItinClassIndx].Last;
     return Stages + StageIdx;
   }

Modified: llvm/trunk/lib/CodeGen/MachineModuleInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/MachineModuleInfo.cpp?rev=48800&r1=48799&r2=48800&view=diff

==============================================================================
--- llvm/trunk/lib/CodeGen/MachineModuleInfo.cpp (original)
+++ llvm/trunk/lib/CodeGen/MachineModuleInfo.cpp Tue Mar 25 16:45:14 2008
@@ -670,7 +670,7 @@
 
 /// getAnchorString - Return a string used to label this descriptor's anchor.
 ///
-const char *CompileUnitDesc::AnchorString = "llvm.dbg.compile_units";
+const char *const CompileUnitDesc::AnchorString = "llvm.dbg.compile_units";
 const char *CompileUnitDesc::getAnchorString() const {
   return AnchorString;
 }
@@ -1120,7 +1120,7 @@
 
 /// getAnchorString - Return a string used to label this descriptor's anchor.
 ///
-const char *GlobalVariableDesc::AnchorString = "llvm.dbg.global_variables";
+const char *const GlobalVariableDesc::AnchorString = "llvm.dbg.global_variables";
 const char *GlobalVariableDesc::getAnchorString() const {
   return AnchorString;
 }
@@ -1174,7 +1174,7 @@
 
 /// getAnchorString - Return a string used to label this descriptor's anchor.
 ///
-const char *SubprogramDesc::AnchorString = "llvm.dbg.subprograms";
+const char *const SubprogramDesc::AnchorString = "llvm.dbg.subprograms";
 const char *SubprogramDesc::getAnchorString() const {
   return AnchorString;
 }

Modified: llvm/trunk/lib/CodeGen/PseudoSourceValue.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/PseudoSourceValue.cpp?rev=48800&r1=48799&r2=48800&view=diff

==============================================================================
--- llvm/trunk/lib/CodeGen/PseudoSourceValue.cpp (original)
+++ llvm/trunk/lib/CodeGen/PseudoSourceValue.cpp Tue Mar 25 16:45:14 2008
@@ -29,7 +29,7 @@
   const PseudoSourceValue *PseudoSourceValue::getJumpTable()
   { return &(*PSVs)[4]; }
 
-  static const char *PSVNames[] = {
+  static const char *const PSVNames[] = {
     "FixedStack",
     "Stack",
     "GOT",

Modified: llvm/trunk/lib/CodeGen/SelectionDAG/ScheduleDAG.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/ScheduleDAG.cpp?rev=48800&r1=48799&r2=48800&view=diff

==============================================================================
--- llvm/trunk/lib/CodeGen/SelectionDAG/ScheduleDAG.cpp (original)
+++ llvm/trunk/lib/CodeGen/SelectionDAG/ScheduleDAG.cpp Tue Mar 25 16:45:14 2008
@@ -221,8 +221,8 @@
     if (SU->Node->isTargetOpcode()) {
       unsigned SchedClass =
         TII->get(SU->Node->getTargetOpcode()).getSchedClass();
-      InstrStage *S = InstrItins.begin(SchedClass);
-      InstrStage *E = InstrItins.end(SchedClass);
+      const InstrStage *S = InstrItins.begin(SchedClass);
+      const InstrStage *E = InstrItins.end(SchedClass);
       for (; S != E; ++S)
         SU->Latency += S->Cycles;
     }
@@ -230,8 +230,8 @@
       SDNode *FNode = SU->FlaggedNodes[i];
       if (FNode->isTargetOpcode()) {
         unsigned SchedClass =TII->get(FNode->getTargetOpcode()).getSchedClass();
-        InstrStage *S = InstrItins.begin(SchedClass);
-        InstrStage *E = InstrItins.end(SchedClass);
+        const InstrStage *S = InstrItins.begin(SchedClass);
+        const InstrStage *E = InstrItins.end(SchedClass);
         for (; S != E; ++S)
           SU->Latency += S->Cycles;
       }

Modified: llvm/trunk/lib/Support/APInt.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/APInt.cpp?rev=48800&r1=48799&r2=48800&view=diff

==============================================================================
--- llvm/trunk/lib/Support/APInt.cpp (original)
+++ llvm/trunk/lib/Support/APInt.cpp Tue Mar 25 16:45:14 2008
@@ -1971,7 +1971,7 @@
 std::string APInt::toString(uint8_t radix, bool wantSigned) const {
   assert((radix == 10 || radix == 8 || radix == 16 || radix == 2) &&
          "Radix should be 2, 8, 10, or 16!");
-  static const char *digits[] = { 
+  static const char *const digits[] = { 
     "0","1","2","3","4","5","6","7","8","9","A","B","C","D","E","F" 
   };
   std::string result;

Modified: llvm/trunk/lib/Support/CommandLine.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/CommandLine.cpp?rev=48800&r1=48799&r2=48800&view=diff

==============================================================================
--- llvm/trunk/lib/Support/CommandLine.cpp (original)
+++ llvm/trunk/lib/Support/CommandLine.cpp Tue Mar 25 16:45:14 2008
@@ -267,7 +267,7 @@
 static void ParseCStringVector(std::vector<char *> &output,
                                const char *input) {
   // Characters which will be treated as token separators:
-  static const char *delims = " \v\f\t\r\n";
+  static const char *const delims = " \v\f\t\r\n";
 
   std::string work (input);
   // Skip past any delims at head of input string.

Modified: llvm/trunk/lib/Target/ARM/ARMTargetAsmInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMTargetAsmInfo.cpp?rev=48800&r1=48799&r2=48800&view=diff

==============================================================================
--- llvm/trunk/lib/Target/ARM/ARMTargetAsmInfo.cpp (original)
+++ llvm/trunk/lib/Target/ARM/ARMTargetAsmInfo.cpp Tue Mar 25 16:45:14 2008
@@ -17,7 +17,8 @@
 #include <cctype>
 using namespace llvm;
 
-static const char* arm_asm_table[] = {"{r0}", "r0",
+static const char *const arm_asm_table[] = {
+                                      "{r0}", "r0",
                                       "{r1}", "r1",
                                       "{r2}", "r2",
                                       "{r3}", "r3",

Modified: llvm/trunk/lib/Target/CBackend/CBackend.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/CBackend/CBackend.cpp?rev=48800&r1=48799&r2=48800&view=diff

==============================================================================
--- llvm/trunk/lib/Target/CBackend/CBackend.cpp (original)
+++ llvm/trunk/lib/Target/CBackend/CBackend.cpp Tue Mar 25 16:45:14 2008
@@ -2825,7 +2825,7 @@
 
   assert(c.Codes.size() == 1 && "Too many asm constraint codes to handle");
 
-  const char** table = 0;
+  const char *const *table = 0;
   
   //Grab the translation table from TargetAsmInfo if it exists
   if (!TAsm) {

Modified: llvm/trunk/lib/Target/PowerPC/PPCAsmPrinter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PowerPC/PPCAsmPrinter.cpp?rev=48800&r1=48799&r2=48800&view=diff

==============================================================================
--- llvm/trunk/lib/Target/PowerPC/PPCAsmPrinter.cpp (original)
+++ llvm/trunk/lib/Target/PowerPC/PPCAsmPrinter.cpp Tue Mar 25 16:45:14 2008
@@ -860,7 +860,7 @@
 
 
 bool DarwinAsmPrinter::doInitialization(Module &M) {
-  static const char *CPUDirectives[] = {
+  static const char *const CPUDirectives[] = {
     "",
     "ppc",
     "ppc601",

Modified: llvm/trunk/lib/Target/X86/X86TargetAsmInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86TargetAsmInfo.cpp?rev=48800&r1=48799&r2=48800&view=diff

==============================================================================
--- llvm/trunk/lib/Target/X86/X86TargetAsmInfo.cpp (original)
+++ llvm/trunk/lib/Target/X86/X86TargetAsmInfo.cpp Tue Mar 25 16:45:14 2008
@@ -25,7 +25,8 @@
 using namespace llvm;
 using namespace llvm::dwarf;
 
-static const char* x86_asm_table[] = {"{si}", "S",
+static const char *const x86_asm_table[] = {
+                                      "{si}", "S",
                                       "{di}", "D",
                                       "{ax}", "a",
                                       "{cx}", "c",

Modified: llvm/trunk/utils/TableGen/SubtargetEmitter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/SubtargetEmitter.cpp?rev=48800&r1=48799&r2=48800&view=diff

==============================================================================
--- llvm/trunk/utils/TableGen/SubtargetEmitter.cpp (original)
+++ llvm/trunk/utils/TableGen/SubtargetEmitter.cpp Tue Mar 25 16:45:14 2008
@@ -83,7 +83,7 @@
 
   // Begin feature table
   OS << "// Sorted (by key) array of values for CPU features.\n"
-     << "static llvm::SubtargetFeatureKV FeatureKV[] = {\n";
+     << "static const llvm::SubtargetFeatureKV FeatureKV[] = {\n";
   
   // For each feature
   for (unsigned i = 0, N = FeatureList.size(); i < N; ++i) {
@@ -269,7 +269,7 @@
   if (ProcItinList.size() < 2) return;
 
   // Begin stages table
-  OS << "static llvm::InstrStage Stages[] = {\n"
+  OS << "static const llvm::InstrStage Stages[] = {\n"
         "  { 0, 0 }, // No itinerary\n";
         
   unsigned ItinEnum = 1;
@@ -362,7 +362,7 @@
 
     // Begin processor itinerary table
     OS << "\n";
-    OS << "static llvm::InstrItinerary " << Name << "[] = {\n";
+    OS << "static const llvm::InstrItinerary " << Name << "[] = {\n";
     
     // For each itinerary class
     std::vector<InstrItinerary> &ItinList = *ProcListIter++;





More information about the llvm-commits mailing list