From: Brian Gaeke Date: Thu, 29 Jul 2004 21:31:20 +0000 (+0000) Subject: Convert a few assertions with side-effects into regular old runtime checks. X-Git-Url: http://plrg.eecs.uci.edu/git/?a=commitdiff_plain;h=365f54c7bc32c13e9c3919bbc37f32192b5cb354;p=oota-llvm.git Convert a few assertions with side-effects into regular old runtime checks. These side-effects seem to make a difference when using llc -march=sparcv9 in Release mode (i.e., with -DNDEBUG); when they are left out, lots of instructions just get dropped on the floor, because they never end up in the schedule. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@15339 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/CodeGen/InstrSched/InstrScheduling.cpp b/lib/CodeGen/InstrSched/InstrScheduling.cpp index dd2f45dabda..240bdefe94e 100644 --- a/lib/CodeGen/InstrSched/InstrScheduling.cpp +++ b/lib/CodeGen/InstrSched/InstrScheduling.cpp @@ -193,7 +193,10 @@ public: // accessor functions to query chosen schedule unsigned int slotNum, cycles_t cycle) { InstrGroup* igroup = this->getIGroup(cycle); - assert((*igroup)[slotNum] == NULL && "Slot already filled?"); + if (!((*igroup)[slotNum] == NULL)) { + std::cerr << "Slot already filled?\n"; + abort(); + } igroup->addInstr(node, slotNum); assert(node->getNodeId() < startTime.size()); startTime[node->getNodeId()] = cycle; @@ -626,7 +629,6 @@ RecordSchedule(MachineBasicBlock &MBB, const SchedulingManager& S) { const TargetInstrInfo& mii = S.schedInfo.getInstrInfo(); -#ifndef NDEBUG // Lets make sure we didn't lose any instructions, except possibly // some NOPs from delay slots. Also, PHIs are not included in the schedule. unsigned numInstr = 0; @@ -636,7 +638,6 @@ RecordSchedule(MachineBasicBlock &MBB, const SchedulingManager& S) ++numInstr; assert(S.isched.getNumInstructions() >= numInstr && "Lost some non-NOP instructions during scheduling!"); -#endif if (S.isched.getNumInstructions() == 0) return; // empty basic block! @@ -1174,8 +1175,10 @@ static void ReplaceNopsWithUsefulInstr(SchedulingManager& S, MachineBasicBlock& MBB = node->getMachineBasicBlock(); MachineBasicBlock::iterator MBBI = MBB.begin(); std::advance(MBBI, firstDelaySlotIdx - 1); - assert(&*MBBI++ == brInstr && - "Incorrect instr. index in basic block for brInstr"); + if (!(&*MBBI++ == brInstr)) { + std::cerr << "Incorrect instr. index in basic block for brInstr"; + abort(); + } // First find all useful instructions already in the delay slots // and USE THEM. We'll throw away the unused alternatives below diff --git a/lib/Target/SparcV9/InstrSched/InstrScheduling.cpp b/lib/Target/SparcV9/InstrSched/InstrScheduling.cpp index dd2f45dabda..240bdefe94e 100644 --- a/lib/Target/SparcV9/InstrSched/InstrScheduling.cpp +++ b/lib/Target/SparcV9/InstrSched/InstrScheduling.cpp @@ -193,7 +193,10 @@ public: // accessor functions to query chosen schedule unsigned int slotNum, cycles_t cycle) { InstrGroup* igroup = this->getIGroup(cycle); - assert((*igroup)[slotNum] == NULL && "Slot already filled?"); + if (!((*igroup)[slotNum] == NULL)) { + std::cerr << "Slot already filled?\n"; + abort(); + } igroup->addInstr(node, slotNum); assert(node->getNodeId() < startTime.size()); startTime[node->getNodeId()] = cycle; @@ -626,7 +629,6 @@ RecordSchedule(MachineBasicBlock &MBB, const SchedulingManager& S) { const TargetInstrInfo& mii = S.schedInfo.getInstrInfo(); -#ifndef NDEBUG // Lets make sure we didn't lose any instructions, except possibly // some NOPs from delay slots. Also, PHIs are not included in the schedule. unsigned numInstr = 0; @@ -636,7 +638,6 @@ RecordSchedule(MachineBasicBlock &MBB, const SchedulingManager& S) ++numInstr; assert(S.isched.getNumInstructions() >= numInstr && "Lost some non-NOP instructions during scheduling!"); -#endif if (S.isched.getNumInstructions() == 0) return; // empty basic block! @@ -1174,8 +1175,10 @@ static void ReplaceNopsWithUsefulInstr(SchedulingManager& S, MachineBasicBlock& MBB = node->getMachineBasicBlock(); MachineBasicBlock::iterator MBBI = MBB.begin(); std::advance(MBBI, firstDelaySlotIdx - 1); - assert(&*MBBI++ == brInstr && - "Incorrect instr. index in basic block for brInstr"); + if (!(&*MBBI++ == brInstr)) { + std::cerr << "Incorrect instr. index in basic block for brInstr"; + abort(); + } // First find all useful instructions already in the delay slots // and USE THEM. We'll throw away the unused alternatives below