Branch folding may invalidate liveness.
authorJakob Stoklund Olesen <stoklund@2pi.dk>
Tue, 27 Mar 2012 17:06:09 +0000 (17:06 +0000)
committerJakob Stoklund Olesen <stoklund@2pi.dk>
Tue, 27 Mar 2012 17:06:09 +0000 (17:06 +0000)
Branch folding can use a register scavenger to update liveness
information when required. Don't do that if liveness information is
already invalid.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@153517 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/BranchFolding.cpp

index f57f4a8e28109ae451dcc936e6164844eca0cece..ef1d2baed9ce8d25e4146291d0c4330b9a510e95 100644 (file)
@@ -23,6 +23,7 @@
 #include "llvm/CodeGen/MachineModuleInfo.h"
 #include "llvm/CodeGen/MachineFunctionPass.h"
 #include "llvm/CodeGen/MachineJumpTableInfo.h"
+#include "llvm/CodeGen/MachineRegisterInfo.h"
 #include "llvm/CodeGen/RegisterScavenging.h"
 #include "llvm/Target/TargetInstrInfo.h"
 #include "llvm/Target/TargetMachine.h"
@@ -183,8 +184,14 @@ bool BranchFolder::OptimizeFunction(MachineFunction &MF,
   TII = tii;
   TRI = tri;
   MMI = mmi;
-
-  RS = TRI->requiresRegisterScavenging(MF) ? new RegScavenger() : NULL;
+  RS = NULL;
+
+  // Use a RegScavenger to help update liveness when required.
+  MachineRegisterInfo &MRI = MF.getRegInfo();
+  if (MRI.tracksLiveness() && TRI->requiresRegisterScavenging(MF))
+    RS = new RegScavenger();
+  else
+    MRI.invalidateLiveness();
 
   // Fix CFG.  The later algorithms expect it to be right.
   bool MadeChange = false;