Use BitVector instead of vector<bool> which can be extremely slow.
authorEvan Cheng <evan.cheng@apple.com>
Thu, 15 Feb 2007 05:59:24 +0000 (05:59 +0000)
committerEvan Cheng <evan.cheng@apple.com>
Thu, 15 Feb 2007 05:59:24 +0000 (05:59 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@34302 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/CodeGen/LiveIntervalAnalysis.h
include/llvm/CodeGen/LiveVariables.h
include/llvm/Target/MRegisterInfo.h
lib/CodeGen/LiveIntervalAnalysis.cpp
lib/CodeGen/RegAllocLocal.cpp
lib/Target/MRegisterInfo.cpp

index 70c189df7806800a6655feb5c9797170194a1642..362b3545fb497f32f8c6a0f3aff3e54d508566c5 100644 (file)
@@ -22,6 +22,7 @@
 
 #include "llvm/CodeGen/MachineFunctionPass.h"
 #include "llvm/CodeGen/LiveInterval.h"
+#include "llvm/ADT/BitVector.h"
 #include "llvm/ADT/IndexedMap.h"
 
 namespace llvm {
@@ -54,7 +55,7 @@ namespace llvm {
     typedef IndexedMap<unsigned> Reg2RegMap;
     Reg2RegMap r2rMap_;
 
-    std::vector<bool> allocatableRegs_;
+    BitVector allocatableRegs_;
 
   public:
     struct CopyRec {
index 47801a94722dc1b49e03bb346a762d155fc7d415..6e7e23d495b8d131b4bfce767765a2aa7e5b17ae 100644 (file)
@@ -30,6 +30,7 @@
 #define LLVM_CODEGEN_LIVEVARIABLES_H
 
 #include "llvm/CodeGen/MachineFunctionPass.h"
+#include "llvm/ADT/BitVector.h"
 #include <map>
 
 namespace llvm {
@@ -75,7 +76,7 @@ public:
     /// through.  This is a bit set which uses the basic block number as an
     /// index.
     ///
-    std::vector<bool> AliveBlocks;
+    BitVector AliveBlocks;
 
     /// Kills - List of MachineInstruction's which are the last use of this
     /// virtual register (kill it) in their basic block.
@@ -111,7 +112,7 @@ private:
   /// are actually register allocatable by the target machine.  We can not track
   /// liveness for values that are not in this set.
   ///
-  std::vector<bool> AllocatablePhysicalRegisters;
+  BitVector AllocatablePhysicalRegisters;
 
 private:   // Intermediate data structures
   const MRegisterInfo *RegInfo;
index 46a2cc34f1747d26d00fdb38e06d3478706f5428..6d53d51456c4e8f89ce1317ab0d19e0d7762875a 100644 (file)
@@ -30,6 +30,7 @@ class MachineLocation;
 class MachineMove;
 class TargetRegisterClass;
 class CalleeSavedInfo;
+class BitVector;
 
 /// TargetRegisterDesc - This record contains all of the information known about
 /// a particular register.  The AliasSet field (if not null) contains a pointer
@@ -240,7 +241,7 @@ public:
 
   /// getAllocatableSet - Returns a bitset indexed by register number
   /// indicating if a register is allocatable or not.
-  std::vector<bool> getAllocatableSet(MachineFunction &MF) const;
+  BitVector getAllocatableSet(MachineFunction &MF) const;
 
   const TargetRegisterDesc &operator[](unsigned RegNo) const {
     assert(RegNo < NumRegs &&
index 83852ca8b9c2c69a5c6053a0ef2f66d0390665f5..57a73d2642b5faacef14e3c4751265845f719910 100644 (file)
@@ -461,7 +461,7 @@ void LiveIntervals::handleVirtualRegisterDef(MachineBasicBlock *mbb,
       // If the kill happens after the definition, we have an intra-block
       // live range.
       if (killIdx > defIndex) {
-        assert(vi.AliveBlocks.empty() &&
+        assert(vi.AliveBlocks.none() &&
                "Shouldn't be alive across any blocks!");
         LiveRange LR(defIndex, killIdx, ValNum);
         interval.addRange(LR);
index 74d76c14fc4575136fa729f065fabc8b3f5801b7..f862023e8f88e9eff45e30039fefb7d0114ebfd7 100644 (file)
@@ -789,7 +789,7 @@ bool RA::runOnMachineFunction(MachineFunction &Fn) {
   // is allocatable.  To handle this, we mark all unallocatable registers as
   // being pinned down, permanently.
   {
-    std::vector<bool> Allocable = RegInfo->getAllocatableSet(Fn);
+    BitVector Allocable = RegInfo->getAllocatableSet(Fn);
     for (unsigned i = 0, e = Allocable.size(); i != e; ++i)
       if (!Allocable[i])
         PhysRegsUsed[i] = -2;  // Mark the reg unallocable.
index 01295e802a3fe84395aa401f0eca30f58213a071..7caaae9d4fac3dd8aa9d480860c77763e09c4389 100644 (file)
 #include "llvm/Target/TargetMachine.h"
 #include "llvm/Target/MRegisterInfo.h"
 #include "llvm/Target/TargetFrameInfo.h"
-
 #include "llvm/CodeGen/MachineFunction.h"
 #include "llvm/CodeGen/MachineFrameInfo.h"
 #include "llvm/CodeGen/MachineLocation.h"
+#include "llvm/ADT/BitVector.h"
 
 using namespace llvm;
 
@@ -34,8 +34,8 @@ MRegisterInfo::MRegisterInfo(const TargetRegisterDesc *D, unsigned NR,
 
 MRegisterInfo::~MRegisterInfo() {}
 
-std::vector<bool> MRegisterInfo::getAllocatableSet(MachineFunction &MF) const {
-  std::vector<bool> Allocatable(NumRegs);
+BitVector MRegisterInfo::getAllocatableSet(MachineFunction &MF) const {
+  BitVector Allocatable(NumRegs);
   for (MRegisterInfo::regclass_iterator I = regclass_begin(),
          E = regclass_end(); I != E; ++I) {
     const TargetRegisterClass *RC = *I;