#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");
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;
}
// 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;
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
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";
-}