From af50d00829b8d9ddbaf819619cd14758c6b96e21 Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Tue, 9 Apr 2002 05:45:58 +0000 Subject: [PATCH] * Add a file header with some information * Delete the DelaySlotInfo objects created by the SchedulingManager class. These leaked objects were accounting for 3/4 of the memory leaked by the backend, so this is a relatively major win. * Reorganize SchedulingManager::getDelaySlotInfoForInstr so that it has better code locality (making it easier to read). git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@2197 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/CodeGen/InstrSched/InstrScheduling.cpp | 60 ++++++++----------- .../SparcV9/InstrSched/InstrScheduling.cpp | 60 ++++++++----------- 2 files changed, 50 insertions(+), 70 deletions(-) diff --git a/lib/CodeGen/InstrSched/InstrScheduling.cpp b/lib/CodeGen/InstrSched/InstrScheduling.cpp index 69813c744e5..7f29b8c70b1 100644 --- a/lib/CodeGen/InstrSched/InstrScheduling.cpp +++ b/lib/CodeGen/InstrSched/InstrScheduling.cpp @@ -1,14 +1,9 @@ -// $Id$ -//*************************************************************************** -// File: -// InstrScheduling.cpp -// -// Purpose: -// -// History: -// 7/23/01 - Vikram Adve - Created -//**************************************************************************/ - +//===- InstrScheduling.cpp - Generic Instruction Scheduling support -------===// +// +// This file implements the llvm/CodeGen/InstrScheduling.h interface, along with +// generic support routines for instruction scheduling. +// +//===----------------------------------------------------------------------===// #include "llvm/CodeGen/InstrScheduling.h" #include "llvm/CodeGen/MachineInstr.h" @@ -364,10 +359,14 @@ private: // indexed by branch node ptr public: - /*ctor*/ SchedulingManager (const TargetMachine& _target, - const SchedGraph* graph, - SchedPriorities& schedPrio); - /*dtor*/ ~SchedulingManager () {} + SchedulingManager(const TargetMachine& _target, const SchedGraph* graph, + SchedPriorities& schedPrio); + ~SchedulingManager() { + for (std::hash_map::iterator I = delaySlotInfoForBranches.begin(), + E = delaySlotInfoForBranches.end(); I != E; ++I) + delete I->second; + } //---------------------------------------------------------------------- // Simplify access to the machine instruction info @@ -497,30 +496,21 @@ public: inline DelaySlotInfo* getDelaySlotInfoForInstr(const SchedGraphNode* bn, bool createIfMissing=false) { - DelaySlotInfo* dinfo; - std::hash_map::const_iterator + std::hash_map::const_iterator I = delaySlotInfoForBranches.find(bn); - if (I == delaySlotInfoForBranches.end()) - { - if (createIfMissing) - { - dinfo = new DelaySlotInfo(bn, - getInstrInfo().getNumDelaySlots(bn->getOpCode())); - delaySlotInfoForBranches[bn] = dinfo; - } - else - dinfo = NULL; - } - else - dinfo = (*I).second; - - return dinfo; + if (I != delaySlotInfoForBranches.end()) + return I->second; + + if (!createIfMissing) return 0; + + DelaySlotInfo *dinfo = + new DelaySlotInfo(bn, getInstrInfo().getNumDelaySlots(bn->getOpCode())); + return delaySlotInfoForBranches[bn] = dinfo; } private: - /*ctor*/ SchedulingManager (); // Disable: DO NOT IMPLEMENT. - void updateEarliestStartTimes(const SchedGraphNode* node, - cycles_t schedTime); + SchedulingManager(); // DISABLED: DO NOT IMPLEMENT + void updateEarliestStartTimes(const SchedGraphNode* node, cycles_t schedTime); }; diff --git a/lib/Target/SparcV9/InstrSched/InstrScheduling.cpp b/lib/Target/SparcV9/InstrSched/InstrScheduling.cpp index 69813c744e5..7f29b8c70b1 100644 --- a/lib/Target/SparcV9/InstrSched/InstrScheduling.cpp +++ b/lib/Target/SparcV9/InstrSched/InstrScheduling.cpp @@ -1,14 +1,9 @@ -// $Id$ -//*************************************************************************** -// File: -// InstrScheduling.cpp -// -// Purpose: -// -// History: -// 7/23/01 - Vikram Adve - Created -//**************************************************************************/ - +//===- InstrScheduling.cpp - Generic Instruction Scheduling support -------===// +// +// This file implements the llvm/CodeGen/InstrScheduling.h interface, along with +// generic support routines for instruction scheduling. +// +//===----------------------------------------------------------------------===// #include "llvm/CodeGen/InstrScheduling.h" #include "llvm/CodeGen/MachineInstr.h" @@ -364,10 +359,14 @@ private: // indexed by branch node ptr public: - /*ctor*/ SchedulingManager (const TargetMachine& _target, - const SchedGraph* graph, - SchedPriorities& schedPrio); - /*dtor*/ ~SchedulingManager () {} + SchedulingManager(const TargetMachine& _target, const SchedGraph* graph, + SchedPriorities& schedPrio); + ~SchedulingManager() { + for (std::hash_map::iterator I = delaySlotInfoForBranches.begin(), + E = delaySlotInfoForBranches.end(); I != E; ++I) + delete I->second; + } //---------------------------------------------------------------------- // Simplify access to the machine instruction info @@ -497,30 +496,21 @@ public: inline DelaySlotInfo* getDelaySlotInfoForInstr(const SchedGraphNode* bn, bool createIfMissing=false) { - DelaySlotInfo* dinfo; - std::hash_map::const_iterator + std::hash_map::const_iterator I = delaySlotInfoForBranches.find(bn); - if (I == delaySlotInfoForBranches.end()) - { - if (createIfMissing) - { - dinfo = new DelaySlotInfo(bn, - getInstrInfo().getNumDelaySlots(bn->getOpCode())); - delaySlotInfoForBranches[bn] = dinfo; - } - else - dinfo = NULL; - } - else - dinfo = (*I).second; - - return dinfo; + if (I != delaySlotInfoForBranches.end()) + return I->second; + + if (!createIfMissing) return 0; + + DelaySlotInfo *dinfo = + new DelaySlotInfo(bn, getInstrInfo().getNumDelaySlots(bn->getOpCode())); + return delaySlotInfoForBranches[bn] = dinfo; } private: - /*ctor*/ SchedulingManager (); // Disable: DO NOT IMPLEMENT. - void updateEarliestStartTimes(const SchedGraphNode* node, - cycles_t schedTime); + SchedulingManager(); // DISABLED: DO NOT IMPLEMENT + void updateEarliestStartTimes(const SchedGraphNode* node, cycles_t schedTime); }; -- 2.34.1