Add section switching to common code generator code. Add a couple of
authorChris Lattner <sabre@nondot.org>
Mon, 21 Nov 2005 07:06:27 +0000 (07:06 +0000)
committerChris Lattner <sabre@nondot.org>
Mon, 21 Nov 2005 07:06:27 +0000 (07:06 +0000)
asserts.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@24445 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/AsmPrinter.cpp
lib/CodeGen/LiveVariables.cpp
lib/CodeGen/RegAllocLinearScan.cpp

index d81846bd7a83c66f3a5450f33d5f44f85dc8f9b1..9faea7085a7839fc3ae45120eb54ec608713309e 100644 (file)
 #include "llvm/Target/TargetMachine.h"
 using namespace llvm;
 
+/// SwitchSection - Switch to the specified section of the executable if we
+/// are not already in it!
+///
+void AsmPrinter::SwitchSection(const char *NewSection, const GlobalValue *GV) {
+  std::string NS;
+  
+  if (GV && GV->hasSection())
+    NS = ".section " + GV->getSection();
+  else
+    NS = NewSection;
+  
+  if (CurrentSection != NS) {
+    CurrentSection = NS;
+    if (!CurrentSection.empty())
+      O << "\t" << CurrentSection << "\n";
+  }
+}
+
 bool AsmPrinter::doInitialization(Module &M) {
   Mang = new Mangler(M, GlobalPrefix);
+  SwitchSection("", 0);   // Reset back to no section.
   return false;
 }
 
index cb034c017a89ab486b674612896f3980d18dd193..a1bda195ff67adbb3314b9c5fcacc452b7ae11ef 100644 (file)
@@ -278,10 +278,11 @@ bool LiveVariables::runOnMachineFunction(MachineFunction &MF) {
             MachineOperand &MO = MI->getOperand(i);
             if (!MO.getVRegValueOrNull()) {
               VarInfo &VRInfo = getVarInfo(MO.getReg());
+              assert(VRInfo.DefInst && "Register use before def (or no def)!");
 
-              // Only mark it alive only in the block we are representing...
+              // Only mark it alive only in the block we are representing.
               MarkVirtRegAliveInBlock(VRInfo, MBB);
-              break;   // Found the PHI entry for this block...
+              break;   // Found the PHI entry for this block.
             }
           }
         }
index a42a366ef36b8b9841baff72baef120c6bd7a57a..9bad0d376f8f87f2dcfe20cbea61a40c51f9b0d7 100644 (file)
@@ -547,6 +547,7 @@ void RA::assignRegOrStackSlotAtInterval(LiveInterval* cur)
       minReg = reg;
     }
   }
+  assert(minReg && "Didn't find any reg!");
   DEBUG(std::cerr << "\t\tregister with min weight: "
         << mri_->getName(minReg) << " (" << minWeight << ")\n");