DebugInfo: Omit pubnames/pubtypes when compiling with -gmlt
[oota-llvm.git] / lib / CodeGen / StackMapLivenessAnalysis.cpp
index 788b83416badab7ded48c34cbb640475dfe37727..a374417a90e7583a9d3249c87fa2ddc22061c62b 100644 (file)
 #include "llvm/CodeGen/MachineFunctionAnalysis.h"
 #include "llvm/CodeGen/Passes.h"
 #include "llvm/CodeGen/StackMapLivenessAnalysis.h"
+#include "llvm/Support/CommandLine.h"
 #include "llvm/Support/Debug.h"
 
+
 using namespace llvm;
 
+namespace llvm {
+cl::opt<bool> EnableStackMapLiveness("enable-stackmap-liveness",
+  cl::Hidden, cl::desc("Enable StackMap Liveness Analysis Pass"));
+cl::opt<bool> EnablePatchPointLiveness("enable-patchpoint-liveness",
+  cl::Hidden, cl::desc("Enable PatchPoint Liveness Analysis Pass"));
+}
 
 STATISTIC(NumStackMapFuncVisited, "Number of functions visited");
 STATISTIC(NumStackMapFuncSkipped, "Number of functions skipped");
@@ -59,8 +67,9 @@ bool StackMapLiveness::runOnMachineFunction(MachineFunction &_MF) {
   TRI = MF->getTarget().getRegisterInfo();
   ++NumStackMapFuncVisited;
 
-  // Skip this function if there are no stackmaps.
-  if (!MF->getFrameInfo()->hasStackMap()) {
+  // Skip this function if there are no stackmaps or patchpoints to process.
+  if (!((MF->getFrameInfo()->hasStackMap() && EnableStackMapLiveness) ||
+        (MF->getFrameInfo()->hasPatchPoint() && EnablePatchPointLiveness))) {
     ++NumStackMapFuncSkipped;
     return false;
   }
@@ -82,13 +91,15 @@ bool StackMapLiveness::calculateLiveness() {
     // instruction.
     for (MachineBasicBlock::reverse_iterator I = MBBI->rbegin(),
          E = MBBI->rend(); I != E; ++I) {
-      if (I->getOpcode() == TargetOpcode::STACKMAP ||
-          I->getOpcode() == TargetOpcode::PATCHPOINT) {
+      int Opc = I->getOpcode();
+      if ((EnableStackMapLiveness && (Opc == TargetOpcode::STACKMAP)) ||
+          (EnablePatchPointLiveness && (Opc == TargetOpcode::PATCHPOINT))) {
         addLiveOutSetToMI(*I);
         HasChanged = true;
         HasStackMap = true;
         ++NumStackMaps;
       }
+      DEBUG(dbgs() << "   " << *I << "   " << LiveRegs);
       LiveRegs.stepBackward(*I);
     }
     ++NumBBsVisited;
@@ -103,8 +114,6 @@ void StackMapLiveness::addLiveOutSetToMI(MachineInstr &MI) {
   uint32_t *Mask = createRegisterMask();
   MachineOperand MO = MachineOperand::CreateRegLiveOut(Mask);
   MI.addOperand(*MF, MO);
-  DEBUG(dbgs() << "   " << MI);
-  DEBUG(printLiveOutSet(dbgs()));
 }
 
 /// Create a register mask and initialize it with the registers from the
@@ -117,12 +126,3 @@ uint32_t *StackMapLiveness::createRegisterMask() const {
     Mask[*RI / 32] |= 1U << (*RI % 32);
   return Mask;
 }
-
-/// Print the current register live set for debugging.
-void StackMapLiveness::printLiveOutSet(raw_ostream &OS) const {
-  OS << "   Register live-out:";
-  for (LivePhysRegs::const_iterator RI = LiveRegs.begin(), RE = LiveRegs.end();
-       RI != RE; ++RI)
-    OS << " " << TRI->getName(*RI);
-  OS << "\n";
-}