MachineRegisterInfo/MIR: Initialize tracksSubRegLiveness early, do not print/parser it
authorMatthias Braun <matze@braunis.de>
Wed, 24 Aug 2016 22:17:45 +0000 (22:17 +0000)
committerMatthias Braun <matze@braunis.de>
Wed, 24 Aug 2016 22:17:45 +0000 (22:17 +0000)
tracksSubRegLiveness only depends on the Subtarget and a cl::opt, there
is not need to change it or save/parse it in a .mir file.
Make the field const and move the initialization LiveIntervalAnalysis to the
MachineRegisterInfo constructor. Also cleanup some code and fix some
instances which better use MachineRegisterInfo::subRegLivenessEnabled() instead
of TargetSubtargetInfo::enableSubRegLiveness().

llvm-svn: 279676

26 files changed:
llvm/include/llvm/CodeGen/MIRYamlMapping.h
llvm/include/llvm/CodeGen/MachineRegisterInfo.h
llvm/include/llvm/Target/TargetSubtargetInfo.h
llvm/lib/CodeGen/DetectDeadLanes.cpp
llvm/lib/CodeGen/LiveIntervalAnalysis.cpp
llvm/lib/CodeGen/MIRParser/MIRParser.cpp
llvm/lib/CodeGen/MIRPrinter.cpp
llvm/lib/CodeGen/MachineRegisterInfo.cpp
llvm/lib/CodeGen/RenameIndependentSubregs.cpp
llvm/test/CodeGen/AArch64/ldst-opt-dbg-limit.mir
llvm/test/CodeGen/AArch64/movimm-wzr.mir
llvm/test/CodeGen/ARM/ARMLoadStoreDBG.mir
llvm/test/CodeGen/MIR/AArch64/inst-size-tlsdesc-callseq.mir
llvm/test/CodeGen/MIR/AMDGPU/expected-target-index-name.mir
llvm/test/CodeGen/MIR/AMDGPU/invalid-target-index-operand.mir
llvm/test/CodeGen/MIR/AMDGPU/target-index-operands.mir
llvm/test/CodeGen/MIR/ARM/sched-it-debug-nodes.mir
llvm/test/CodeGen/MIR/Generic/register-info.mir
llvm/test/CodeGen/MIR/Lanai/peephole-compare.mir
llvm/test/CodeGen/PowerPC/aantidep-def-ec.mir
llvm/test/CodeGen/PowerPC/addisdtprelha-nonr3.mir
llvm/test/CodeGen/PowerPC/no-rlwimi-trivial-commute.mir
llvm/test/CodeGen/PowerPC/opt-sub-inst-cr0-live.mir
llvm/test/CodeGen/X86/implicit-null-checks.mir
llvm/test/DebugInfo/MIR/X86/live-debug-values-3preds.mir
llvm/test/DebugInfo/MIR/X86/live-debug-values.mir

index bf39247..6138af4 100644 (file)
@@ -390,7 +390,6 @@ struct MachineFunction {
   bool Selected = false;
   // Register information
   bool TracksRegLiveness = false;
-  bool TracksSubRegLiveness = false;
   std::vector<VirtualRegisterDefinition> VirtualRegisters;
   std::vector<MachineFunctionLiveIn> LiveIns;
   Optional<std::vector<FlowStringValue>> CalleeSavedRegisters;
@@ -415,7 +414,6 @@ template <> struct MappingTraits<MachineFunction> {
     YamlIO.mapOptional("regBankSelected", MF.RegBankSelected);
     YamlIO.mapOptional("selected", MF.Selected);
     YamlIO.mapOptional("tracksRegLiveness", MF.TracksRegLiveness);
-    YamlIO.mapOptional("tracksSubRegLiveness", MF.TracksSubRegLiveness);
     YamlIO.mapOptional("registers", MF.VirtualRegisters);
     YamlIO.mapOptional("liveins", MF.LiveIns);
     YamlIO.mapOptional("calleeSavedRegisters", MF.CalleeSavedRegisters);
index 74a49c7..a42c551 100644 (file)
@@ -51,7 +51,7 @@ private:
   Delegate *TheDelegate;
 
   /// True if subregister liveness is tracked.
-  bool TracksSubRegLiveness;
+  const bool TracksSubRegLiveness;
 
   /// VRegInfo - Information we keep for each virtual register.
   ///
@@ -199,10 +199,6 @@ public:
     return TracksSubRegLiveness;
   }
 
-  void enableSubRegLiveness(bool Enable = true) {
-    TracksSubRegLiveness = Enable;
-  }
-
   //===--------------------------------------------------------------------===//
   // Register Info
   //===--------------------------------------------------------------------===//
index 98fd80a..3965971 100644 (file)
@@ -218,6 +218,8 @@ public:
   }
 
   /// Enable tracking of subregister liveness in register allocator.
+  /// Please use MachineRegisterInfo::subRegLivenessEnabled() instead where
+  /// possible.
   virtual bool enableSubRegLiveness() const { return false; }
 };
 
index 1d9e79c..931624b 100644 (file)
@@ -577,12 +577,12 @@ bool DetectDeadLanes::runOnMachineFunction(MachineFunction &MF) {
   // register coalescer cannot deal with hidden dead defs. However without
   // subregister liveness enabled, the expected benefits of this pass are small
   // so we safe the compile time.
-  if (!MF.getSubtarget().enableSubRegLiveness()) {
+  MRI = &MF.getRegInfo();
+  if (!MRI->subRegLivenessEnabled()) {
     DEBUG(dbgs() << "Skipping Detect dead lanes pass\n");
     return false;
   }
 
-  MRI = &MF.getRegInfo();
   TRI = MRI->getTargetRegisterInfo();
 
   unsigned NumVirtRegs = MRI->getNumVirtRegs();
index 574684b..ba34d76 100644 (file)
@@ -58,10 +58,6 @@ static cl::opt<bool> EnablePrecomputePhysRegs(
 static bool EnablePrecomputePhysRegs = false;
 #endif // NDEBUG
 
-static cl::opt<bool> EnableSubRegLiveness(
-  "enable-subreg-liveness", cl::Hidden, cl::init(true),
-  cl::desc("Enable subregister liveness tracking."));
-
 namespace llvm {
 cl::opt<bool> UseSegmentSetForPhysRegs(
     "use-segment-set-for-physregs", cl::Hidden, cl::init(true),
@@ -119,9 +115,6 @@ bool LiveIntervals::runOnMachineFunction(MachineFunction &fn) {
   Indexes = &getAnalysis<SlotIndexes>();
   DomTree = &getAnalysis<MachineDominatorTree>();
 
-  if (EnableSubRegLiveness && MF->getSubtarget().enableSubRegLiveness())
-    MRI->enableSubRegLiveness(true);
-
   if (!LRCalc)
     LRCalc = new LiveRangeCalc();
 
index 4a7dba6..f61b3c9 100644 (file)
@@ -401,7 +401,6 @@ bool MIRParserImpl::initializeRegisterInfo(PerFunctionMIParsingState &PFS,
   assert(RegInfo.tracksLiveness());
   if (!YamlMF.TracksRegLiveness)
     RegInfo.invalidateLiveness();
-  RegInfo.enableSubRegLiveness(YamlMF.TracksSubRegLiveness);
 
   SMDiagnostic Error;
   // Parse the virtual register information.
index 78de88f..795f1ca 100644 (file)
@@ -213,7 +213,6 @@ void MIRPrinter::convert(yaml::MachineFunction &MF,
                          const MachineRegisterInfo &RegInfo,
                          const TargetRegisterInfo *TRI) {
   MF.TracksRegLiveness = RegInfo.tracksLiveness();
-  MF.TracksSubRegLiveness = RegInfo.subRegLivenessEnabled();
 
   // Print the virtual register definitions.
   for (unsigned I = 0, E = RegInfo.getNumVirtRegs(); I < E; ++I) {
index 886de80..6e6c9f7 100644 (file)
 
 using namespace llvm;
 
+static cl::opt<bool> EnableSubRegLiveness("enable-subreg-liveness", cl::Hidden,
+  cl::init(true), cl::desc("Enable subregister liveness tracking."));
+
 // Pin the vtable to this file.
 void MachineRegisterInfo::Delegate::anchor() {}
 
 MachineRegisterInfo::MachineRegisterInfo(MachineFunction *MF)
-    : MF(MF), TheDelegate(nullptr), TracksSubRegLiveness(false) {
+    : MF(MF), TheDelegate(nullptr),
+      TracksSubRegLiveness(MF->getSubtarget().enableSubRegLiveness() &&
+                           EnableSubRegLiveness) {
   unsigned NumRegs = getTargetRegisterInfo()->getNumRegs();
   VRegInfo.reserve(256);
   RegAllocHints.reserve(256);
index 9c189f9..73323fc 100644 (file)
@@ -363,14 +363,14 @@ void RenameIndependentSubregs::computeMainRangesFixFlags(
 
 bool RenameIndependentSubregs::runOnMachineFunction(MachineFunction &MF) {
   // Skip renaming if liveness of subregister is not tracked.
-  if (!MF.getSubtarget().enableSubRegLiveness())
+  MRI = &MF.getRegInfo();
+  if (!MRI->subRegLivenessEnabled())
     return false;
 
   DEBUG(dbgs() << "Renaming independent subregister live ranges in "
         << MF.getName() << '\n');
 
   LIS = &getAnalysis<LiveIntervals>();
-  MRI = &MF.getRegInfo();
   TII = MF.getSubtarget().getInstrInfo();
 
   // Iterate over all vregs. Note that we query getNumVirtRegs() the newly
index ecec1a3..bb9bdb0 100644 (file)
@@ -31,7 +31,6 @@ exposesReturnsTwice: false
 hasInlineAsm:    false
 allVRegsAllocated: true
 tracksRegLiveness: false
-tracksSubRegLiveness: false
 liveins:         
   - { reg: '%x0' }
   - { reg: '%w1' }
@@ -88,7 +87,6 @@ exposesReturnsTwice: false
 hasInlineAsm:    false
 allVRegsAllocated: true
 tracksRegLiveness: false
-tracksSubRegLiveness: false
 liveins:         
   - { reg: '%x0' }
   - { reg: '%w1' }
index 7fb9ba6..1264f26 100644 (file)
@@ -18,7 +18,6 @@ exposesReturnsTwice: false
 hasInlineAsm:    false
 allVRegsAllocated: true
 tracksRegLiveness: false
-tracksSubRegLiveness: false
 frameInfo:
   isFrameAddressTaken: false
   isReturnAddressTaken: false
index fa58c16..2682daa 100644 (file)
@@ -82,7 +82,6 @@ exposesReturnsTwice: false
 hasInlineAsm:    false
 allVRegsAllocated: true
 tracksRegLiveness: true
-tracksSubRegLiveness: false
 liveins:
   - { reg: '%r0' }
   - { reg: '%r1' }
index a074998..588ec5d 100644 (file)
@@ -36,7 +36,6 @@ exposesReturnsTwice: false
 hasInlineAsm:    false
 allVRegsAllocated: true
 tracksRegLiveness: false
-tracksSubRegLiveness: false
 liveins:
   - { reg: '%w0' }
 frameInfo:
index d4d2ae1..47f0e16 100644 (file)
@@ -32,8 +32,7 @@
 
 ...
 ---
-name:            float
-tracksSubRegLiveness: true
+name: float
 liveins:
   - { reg: '%sgpr0_sgpr1' }
 frameInfo:
index 1b67edc..d735032 100644 (file)
@@ -32,8 +32,7 @@
 
 ...
 ---
-name:            float
-tracksSubRegLiveness: true
+name: float
 liveins:
   - { reg: '%sgpr0_sgpr1' }
 frameInfo:
index b0b7ea4..e15da09 100644 (file)
@@ -41,8 +41,7 @@
 
 ...
 ---
-name:            float
-tracksSubRegLiveness: true
+name: float
 liveins:
   - { reg: '%sgpr0_sgpr1' }
 frameInfo:
@@ -72,8 +71,7 @@ body: |
     S_ENDPGM
 ...
 ---
-name:            float2
-tracksSubRegLiveness: true
+name: float2
 liveins:
   - { reg: '%sgpr0_sgpr1' }
 frameInfo:
index 21b64c1..ca330cb 100644 (file)
@@ -93,7 +93,6 @@ exposesReturnsTwice: false
 hasInlineAsm:    false
 allVRegsAllocated: true
 tracksRegLiveness: true
-tracksSubRegLiveness: false
 liveins:
   - { reg: '%r0' }
   - { reg: '%r1' }
index 97a6593..af3f44f 100644 (file)
@@ -18,7 +18,6 @@
 ---
 # CHECK: name: foo
 # CHECK: tracksRegLiveness: false
-# CHECK-NEXT: tracksSubRegLiveness: false
 # CHECK: ...
 name:            foo
 body: |
@@ -27,11 +26,9 @@ body: |
 ---
 # CHECK: name: bar
 # CHECK: tracksRegLiveness: true
-# CHECK-NEXT: tracksSubRegLiveness: true
 # CHECK: ...
 name: bar
 tracksRegLiveness: true
-tracksSubRegLiveness: true
 body: |
   bb.0:
 ...
index 1f2ebe5..ddf4212 100644 (file)
@@ -178,7 +178,6 @@ exposesReturnsTwice: false
 hasInlineAsm:    false
 allVRegsAllocated: false
 tracksRegLiveness: true
-tracksSubRegLiveness: false
 registers:       
   - { id: 0, class: gpr }
   - { id: 1, class: gpr }
@@ -225,7 +224,6 @@ exposesReturnsTwice: false
 hasInlineAsm:    false
 allVRegsAllocated: false
 tracksRegLiveness: true
-tracksSubRegLiveness: false
 registers:       
   - { id: 0, class: gpr }
   - { id: 1, class: gpr }
@@ -270,7 +268,6 @@ exposesReturnsTwice: false
 hasInlineAsm:    false
 allVRegsAllocated: false
 tracksRegLiveness: true
-tracksSubRegLiveness: false
 registers:       
   - { id: 0, class: gpr }
   - { id: 1, class: gpr }
@@ -319,7 +316,6 @@ exposesReturnsTwice: false
 hasInlineAsm:    false
 allVRegsAllocated: false
 tracksRegLiveness: true
-tracksSubRegLiveness: false
 registers:       
   - { id: 0, class: gpr }
   - { id: 1, class: gpr }
@@ -368,7 +364,6 @@ exposesReturnsTwice: false
 hasInlineAsm:    false
 allVRegsAllocated: false
 tracksRegLiveness: true
-tracksSubRegLiveness: false
 registers:       
   - { id: 0, class: gpr }
   - { id: 1, class: gpr }
@@ -417,7 +412,6 @@ exposesReturnsTwice: false
 hasInlineAsm:    false
 allVRegsAllocated: false
 tracksRegLiveness: true
-tracksSubRegLiveness: false
 registers:       
   - { id: 0, class: gpr }
   - { id: 1, class: gpr }
@@ -466,7 +460,6 @@ exposesReturnsTwice: false
 hasInlineAsm:    false
 allVRegsAllocated: false
 tracksRegLiveness: true
-tracksSubRegLiveness: false
 registers:       
   - { id: 0, class: gpr }
   - { id: 1, class: gpr }
@@ -515,7 +508,6 @@ exposesReturnsTwice: false
 hasInlineAsm:    false
 allVRegsAllocated: false
 tracksRegLiveness: true
-tracksSubRegLiveness: false
 registers:       
   - { id: 0, class: gpr }
   - { id: 1, class: gpr }
@@ -628,7 +620,6 @@ exposesReturnsTwice: false
 hasInlineAsm:    false
 allVRegsAllocated: false
 tracksRegLiveness: true
-tracksSubRegLiveness: false
 registers:       
   - { id: 0, class: gpr }
   - { id: 1, class: gpr }
index 31b256c..9e750eb 100644 (file)
@@ -47,7 +47,6 @@ exposesReturnsTwice: false
 hasInlineAsm:    true
 allVRegsAllocated: true
 tracksRegLiveness: true
-tracksSubRegLiveness: false
 liveins:         
   - { reg: '%x3' }
   - { reg: '%x4' }
index f157b47..0bf7b95 100644 (file)
@@ -29,7 +29,6 @@ exposesReturnsTwice: false
 hasInlineAsm:    false
 allVRegsAllocated: true
 tracksRegLiveness: true
-tracksSubRegLiveness: false
 frameInfo:       
   isFrameAddressTaken: false
   isReturnAddressTaken: false
index 479adbb..dce1e04 100644 (file)
@@ -41,7 +41,6 @@ alignment:       2
 exposesReturnsTwice: false
 hasInlineAsm:    false
 tracksRegLiveness: true
-tracksSubRegLiveness: false
 registers:       
   - { id: 0, class: g8rc_and_g8rc_nox0 }
   - { id: 1, class: g8rc_and_g8rc_nox0 }
index 942b44c..619954e 100644 (file)
@@ -35,7 +35,6 @@ exposesReturnsTwice: false
 hasInlineAsm:    false
 allVRegsAllocated: false
 tracksRegLiveness: true
-tracksSubRegLiveness: false
 registers:
   - { id: 0, class: g8rc }
   - { id: 1, class: g8rc }
index 9d54bcd..b2b7aca 100644 (file)
@@ -87,7 +87,6 @@ name:            imp_null_check_with_bitwise_op_0
 alignment:       4
 allVRegsAllocated: true
 tracksRegLiveness: true
-tracksSubRegLiveness: false
 liveins:
   - { reg: '%rdi' }
   - { reg: '%esi' }
@@ -131,7 +130,6 @@ name:            imp_null_check_with_bitwise_op_1
 alignment:       4
 allVRegsAllocated: true
 tracksRegLiveness: true
-tracksSubRegLiveness: false
 liveins:
   - { reg: '%rdi' }
   - { reg: '%esi' }
@@ -180,7 +178,6 @@ name:            imp_null_check_with_bitwise_op_2
 alignment:       4
 allVRegsAllocated: true
 tracksRegLiveness: true
-tracksSubRegLiveness: false
 liveins:
   - { reg: '%rdi' }
   - { reg: '%esi' }
@@ -225,7 +222,6 @@ name:            imp_null_check_with_bitwise_op_3
 alignment:       4
 allVRegsAllocated: true
 tracksRegLiveness: true
-tracksSubRegLiveness: false
 liveins:
   - { reg: '%rdi' }
   - { reg: '%rsi' }
index ff81975..aaf1284 100644 (file)
@@ -160,7 +160,6 @@ exposesReturnsTwice: false
 hasInlineAsm:    false
 allVRegsAllocated: true
 tracksRegLiveness: true
-tracksSubRegLiveness: false
 liveins:         
   - { reg: '%edi' }
   - { reg: '%esi' }
index dce88eb..750187e 100644 (file)
@@ -162,7 +162,6 @@ exposesReturnsTwice: false
 hasInlineAsm:    false
 allVRegsAllocated: true
 tracksRegLiveness: true
-tracksSubRegLiveness: false
 liveins:         
   - { reg: '%edi' }
   - { reg: '%rsi' }