aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2005-11-21 07:06:27 +0000
committerChris Lattner <sabre@nondot.org>2005-11-21 07:06:27 +0000
commitac28fbd0436dd8b2bc0c071ba150b60bbfca67f3 (patch)
treed9edb72c6bf281582ac420fc2e9bfe5c3b72ca6b
parente2b1f1188fd8c28977b5cf2a6842fc7bbb008713 (diff)
Add section switching to common code generator code. Add a couple of
asserts. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@24445 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/CodeGen/AsmPrinter.cpp19
-rw-r--r--lib/CodeGen/LiveVariables.cpp5
-rw-r--r--lib/CodeGen/RegAllocLinearScan.cpp1
3 files changed, 23 insertions, 2 deletions
diff --git a/lib/CodeGen/AsmPrinter.cpp b/lib/CodeGen/AsmPrinter.cpp
index d81846bd7a..9faea7085a 100644
--- a/lib/CodeGen/AsmPrinter.cpp
+++ b/lib/CodeGen/AsmPrinter.cpp
@@ -19,8 +19,27 @@
#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;
}
diff --git a/lib/CodeGen/LiveVariables.cpp b/lib/CodeGen/LiveVariables.cpp
index cb034c017a..a1bda195ff 100644
--- a/lib/CodeGen/LiveVariables.cpp
+++ b/lib/CodeGen/LiveVariables.cpp
@@ -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.
}
}
}
diff --git a/lib/CodeGen/RegAllocLinearScan.cpp b/lib/CodeGen/RegAllocLinearScan.cpp
index a42a366ef3..9bad0d376f 100644
--- a/lib/CodeGen/RegAllocLinearScan.cpp
+++ b/lib/CodeGen/RegAllocLinearScan.cpp
@@ -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");