From af650354a1de1254c0937a9f6e9c88f447ad3889 Mon Sep 17 00:00:00 2001 From: Jakub Staszak Date: Tue, 27 Nov 2012 01:14:34 +0000 Subject: [PATCH] Remove unused MachineLoopRanges analysis. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@168659 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/CodeGen/MachineLoopRanges.h | 112 ---------------------- include/llvm/CodeGen/Passes.h | 3 - include/llvm/InitializePasses.h | 1 - lib/CodeGen/CMakeLists.txt | 1 - lib/CodeGen/LiveIntervalUnion.cpp | 28 ------ lib/CodeGen/LiveIntervalUnion.h | 4 - lib/CodeGen/MachineLoopRanges.cpp | 116 ----------------------- 7 files changed, 265 deletions(-) diff --git a/include/llvm/CodeGen/MachineLoopRanges.h b/include/llvm/CodeGen/MachineLoopRanges.h index 6a30e8b53c0..e69de29bb2d 100644 --- a/include/llvm/CodeGen/MachineLoopRanges.h +++ b/include/llvm/CodeGen/MachineLoopRanges.h @@ -1,112 +0,0 @@ -//===- MachineLoopRanges.h - Ranges of machine loops -----------*- c++ -*--===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// -// -// This file provides the interface to the MachineLoopRanges analysis. -// -// Provide on-demand information about the ranges of machine instructions -// covered by a loop. -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_CODEGEN_MACHINELOOPRANGES_H -#define LLVM_CODEGEN_MACHINELOOPRANGES_H - -#include "llvm/ADT/IntervalMap.h" -#include "llvm/CodeGen/SlotIndexes.h" - -namespace llvm { - -class MachineLoop; -class MachineLoopInfo; -class raw_ostream; - -/// MachineLoopRange - Range information for a single loop. -class MachineLoopRange { - friend class MachineLoopRanges; - -public: - typedef IntervalMap Map; - typedef Map::Allocator Allocator; - -private: - /// The mapped loop. - const MachineLoop *const Loop; - - /// Map intervals to a bit mask. - /// Bit 0 = inside loop block. - Map Intervals; - - /// Loop area as measured by SlotIndex::distance. - unsigned Area; - - /// Create a MachineLoopRange, only accessible to MachineLoopRanges. - MachineLoopRange(const MachineLoop*, Allocator&, SlotIndexes&); - -public: - /// getLoop - Return the mapped machine loop. - const MachineLoop *getLoop() const { return Loop; } - - /// overlaps - Return true if this loop overlaps the given range of machine - /// inteructions. - bool overlaps(SlotIndex Start, SlotIndex Stop); - - /// getNumber - Return the loop number. This is the same as the number of the - /// header block. - unsigned getNumber() const; - - /// getArea - Return the loop area. This number is approximately proportional - /// to the number of instructions in the loop. - unsigned getArea() const { return Area; } - - /// getMap - Allow public read-only access for IntervalMapOverlaps. - const Map &getMap() { return Intervals; } - - /// print - Print loop ranges on OS. - void print(raw_ostream&) const; - - /// byNumber - Comparator for array_pod_sort that sorts a list of - /// MachineLoopRange pointers by number. - static int byNumber(const void*, const void*); - - /// byAreaDesc - Comparator for array_pod_sort that sorts a list of - /// MachineLoopRange pointers by descending area, then by number. - static int byAreaDesc(const void*, const void*); -}; - -raw_ostream &operator<<(raw_ostream&, const MachineLoopRange&); - -/// MachineLoopRanges - Analysis pass that provides on-demand per-loop range -/// information. -class MachineLoopRanges : public MachineFunctionPass { - typedef DenseMap CacheMap; - typedef MachineLoopRange::Allocator MapAllocator; - - MapAllocator Allocator; - SlotIndexes *Indexes; - CacheMap Cache; - -public: - static char ID; // Pass identification, replacement for typeid - - MachineLoopRanges() : MachineFunctionPass(ID), Indexes(0) {} - ~MachineLoopRanges() { releaseMemory(); } - - /// getLoopRange - Return the range of loop. - MachineLoopRange *getLoopRange(const MachineLoop *Loop); - -private: - virtual bool runOnMachineFunction(MachineFunction&); - virtual void releaseMemory(); - virtual void getAnalysisUsage(AnalysisUsage&) const; -}; - - -} // end namespace llvm - -#endif // LLVM_CODEGEN_MACHINELOOPRANGES_H diff --git a/include/llvm/CodeGen/Passes.h b/include/llvm/CodeGen/Passes.h index 7bd576494ef..44c9676b2ce 100644 --- a/include/llvm/CodeGen/Passes.h +++ b/include/llvm/CodeGen/Passes.h @@ -288,9 +288,6 @@ namespace llvm { /// MachineLoopInfo - This pass is a loop analysis pass. extern char &MachineLoopInfoID; - /// MachineLoopRanges - This pass is an on-demand loop coverage analysis. - extern char &MachineLoopRangesID; - /// MachineDominators - This pass is a machine dominators analysis pass. extern char &MachineDominatorsID; diff --git a/include/llvm/InitializePasses.h b/include/llvm/InitializePasses.h index 8c164eb9198..e06b8928741 100644 --- a/include/llvm/InitializePasses.h +++ b/include/llvm/InitializePasses.h @@ -172,7 +172,6 @@ void initializeMachineDominatorTreePass(PassRegistry&); void initializeMachinePostDominatorTreePass(PassRegistry&); void initializeMachineLICMPass(PassRegistry&); void initializeMachineLoopInfoPass(PassRegistry&); -void initializeMachineLoopRangesPass(PassRegistry&); void initializeMachineModuleInfoPass(PassRegistry&); void initializeMachineSchedulerPass(PassRegistry&); void initializeMachineSinkingPass(PassRegistry&); diff --git a/lib/CodeGen/CMakeLists.txt b/lib/CodeGen/CMakeLists.txt index fa6d4e16cfe..7a20ff631e2 100644 --- a/lib/CodeGen/CMakeLists.txt +++ b/lib/CodeGen/CMakeLists.txt @@ -54,7 +54,6 @@ add_llvm_library(LLVMCodeGen MachineInstrBundle.cpp MachineLICM.cpp MachineLoopInfo.cpp - MachineLoopRanges.cpp MachineModuleInfo.cpp MachineModuleInfoImpls.cpp MachinePassRegistry.cpp diff --git a/lib/CodeGen/LiveIntervalUnion.cpp b/lib/CodeGen/LiveIntervalUnion.cpp index dadd02bfc65..679c1807aac 100644 --- a/lib/CodeGen/LiveIntervalUnion.cpp +++ b/lib/CodeGen/LiveIntervalUnion.cpp @@ -16,7 +16,6 @@ #define DEBUG_TYPE "regalloc" #include "LiveIntervalUnion.h" #include "llvm/ADT/SparseBitVector.h" -#include "llvm/CodeGen/MachineLoopRanges.h" #include "llvm/Support/Debug.h" #include "llvm/Support/raw_ostream.h" #include "llvm/Target/TargetRegisterInfo.h" @@ -182,33 +181,6 @@ collectInterferingVRegs(unsigned MaxInterferingRegs) { return InterferingVRegs.size(); } -bool LiveIntervalUnion::Query::checkLoopInterference(MachineLoopRange *Loop) { - // VirtReg is likely live throughout the loop, so start by checking LIU-Loop - // overlaps. - IntervalMapOverlaps - Overlaps(LiveUnion->getMap(), Loop->getMap()); - if (!Overlaps.valid()) - return false; - - // The loop is overlapping an LIU assignment. Check VirtReg as well. - LiveInterval::iterator VRI = VirtReg->find(Overlaps.start()); - - for (;;) { - if (VRI == VirtReg->end()) - return false; - if (VRI->start < Overlaps.stop()) - return true; - - Overlaps.advanceTo(VRI->start); - if (!Overlaps.valid()) - return false; - if (Overlaps.start() < VRI->end) - return true; - - VRI = VirtReg->advanceTo(VRI, Overlaps.start()); - } -} - void LiveIntervalUnion::Array::init(LiveIntervalUnion::Allocator &Alloc, unsigned NSize) { // Reuse existing allocation. diff --git a/lib/CodeGen/LiveIntervalUnion.h b/lib/CodeGen/LiveIntervalUnion.h index 4d41fca85ad..4d2c4cb3add 100644 --- a/lib/CodeGen/LiveIntervalUnion.h +++ b/lib/CodeGen/LiveIntervalUnion.h @@ -173,10 +173,6 @@ public: return InterferingVRegs; } - /// checkLoopInterference - Return true if there is interference overlapping - /// Loop. - bool checkLoopInterference(MachineLoopRange*); - private: Query(const Query&) LLVM_DELETED_FUNCTION; void operator=(const Query&) LLVM_DELETED_FUNCTION; diff --git a/lib/CodeGen/MachineLoopRanges.cpp b/lib/CodeGen/MachineLoopRanges.cpp index 17fe67f6504..e69de29bb2d 100644 --- a/lib/CodeGen/MachineLoopRanges.cpp +++ b/lib/CodeGen/MachineLoopRanges.cpp @@ -1,116 +0,0 @@ -//===- MachineLoopRanges.cpp - Ranges of machine loops --------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// -// -// This file provides the implementation of the MachineLoopRanges analysis. -// -//===----------------------------------------------------------------------===// - -#include "llvm/CodeGen/MachineLoopRanges.h" -#include "llvm/CodeGen/MachineLoopInfo.h" -#include "llvm/CodeGen/Passes.h" - -using namespace llvm; - -char MachineLoopRanges::ID = 0; -INITIALIZE_PASS_BEGIN(MachineLoopRanges, "machine-loop-ranges", - "Machine Loop Ranges", true, true) -INITIALIZE_PASS_DEPENDENCY(SlotIndexes) -INITIALIZE_PASS_DEPENDENCY(MachineLoopInfo) -INITIALIZE_PASS_END(MachineLoopRanges, "machine-loop-ranges", - "Machine Loop Ranges", true, true) - -char &llvm::MachineLoopRangesID = MachineLoopRanges::ID; - -void MachineLoopRanges::getAnalysisUsage(AnalysisUsage &AU) const { - AU.setPreservesAll(); - AU.addRequiredTransitive(); - AU.addRequiredTransitive(); - MachineFunctionPass::getAnalysisUsage(AU); -} - -/// runOnMachineFunction - Don't do much, loop ranges are computed on demand. -bool MachineLoopRanges::runOnMachineFunction(MachineFunction &) { - releaseMemory(); - Indexes = &getAnalysis(); - return false; -} - -void MachineLoopRanges::releaseMemory() { - DeleteContainerSeconds(Cache); - Cache.clear(); -} - -MachineLoopRange *MachineLoopRanges::getLoopRange(const MachineLoop *Loop) { - MachineLoopRange *&Range = Cache[Loop]; - if (!Range) - Range = new MachineLoopRange(Loop, Allocator, *Indexes); - return Range; -} - -/// Create a MachineLoopRange, only accessible to MachineLoopRanges. -MachineLoopRange::MachineLoopRange(const MachineLoop *loop, - MachineLoopRange::Allocator &alloc, - SlotIndexes &Indexes) - : Loop(loop), Intervals(alloc), Area(0) { - // Compute loop coverage. - for (MachineLoop::block_iterator I = Loop->block_begin(), - E = Loop->block_end(); I != E; ++I) { - const std::pair &Range = Indexes.getMBBRange(*I); - Intervals.insert(Range.first, Range.second, 1u); - Area += Range.first.distance(Range.second); - } -} - -/// overlaps - Return true if this loop overlaps the given range of machine -/// instructions. -bool MachineLoopRange::overlaps(SlotIndex Start, SlotIndex Stop) { - Map::const_iterator I = Intervals.find(Start); - return I.valid() && Stop > I.start(); -} - -unsigned MachineLoopRange::getNumber() const { - return Loop->getHeader()->getNumber(); -} - -/// byNumber - Comparator for array_pod_sort that sorts a list of -/// MachineLoopRange pointers by number. -int MachineLoopRange::byNumber(const void *pa, const void *pb) { - const MachineLoopRange *a = *static_cast(pa); - const MachineLoopRange *b = *static_cast(pb); - unsigned na = a->getNumber(); - unsigned nb = b->getNumber(); - if (na < nb) - return -1; - if (na > nb) - return 1; - return 0; -} - -/// byAreaDesc - Comparator for array_pod_sort that sorts a list of -/// MachineLoopRange pointers by: -/// 1. Descending area. -/// 2. Ascending number. -int MachineLoopRange::byAreaDesc(const void *pa, const void *pb) { - const MachineLoopRange *a = *static_cast(pa); - const MachineLoopRange *b = *static_cast(pb); - if (a->getArea() != b->getArea()) - return a->getArea() > b->getArea() ? -1 : 1; - return byNumber(pa, pb); -} - -void MachineLoopRange::print(raw_ostream &OS) const { - OS << "Loop#" << getNumber() << " ="; - for (Map::const_iterator I = Intervals.begin(); I.valid(); ++I) - OS << " [" << I.start() << ';' << I.stop() << ')'; -} - -raw_ostream &llvm::operator<<(raw_ostream &OS, const MachineLoopRange &MLR) { - MLR.print(OS); - return OS; -} -- 2.34.1