X-Git-Url: http://demsky.eecs.uci.edu/git/?a=blobdiff_plain;f=lib%2FCodeGen%2FStackMapLivenessAnalysis.cpp;h=767f43a420fd932e0ea6f5cd85d84906a67fc220;hb=6de0a12927845ca49cd5cb1da9206fe503b565ec;hp=788b83416badab7ded48c34cbb640475dfe37727;hpb=539e93120cdbb66f651fc55a810416f3175adc8f;p=oota-llvm.git diff --git a/lib/CodeGen/StackMapLivenessAnalysis.cpp b/lib/CodeGen/StackMapLivenessAnalysis.cpp index 788b83416ba..767f43a420f 100644 --- a/lib/CodeGen/StackMapLivenessAnalysis.cpp +++ b/lib/CodeGen/StackMapLivenessAnalysis.cpp @@ -13,17 +13,25 @@ // //===----------------------------------------------------------------------===// -#define DEBUG_TYPE "stackmaps" #include "llvm/ADT/Statistic.h" #include "llvm/CodeGen/MachineFrameInfo.h" #include "llvm/CodeGen/MachineFunction.h" #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" +#include "llvm/Target/TargetSubtargetInfo.h" using namespace llvm; +#define DEBUG_TYPE "stackmaps" + +namespace llvm { +cl::opt EnablePatchPointLiveness("enable-patchpoint-liveness", + cl::Hidden, cl::init(true), + cl::desc("Enable PatchPoint Liveness Analysis Pass")); +} STATISTIC(NumStackMapFuncVisited, "Number of functions visited"); STATISTIC(NumStackMapFuncSkipped, "Number of functions skipped"); @@ -53,14 +61,17 @@ void StackMapLiveness::getAnalysisUsage(AnalysisUsage &AU) const { /// Calculate the liveness information for the given machine function. bool StackMapLiveness::runOnMachineFunction(MachineFunction &_MF) { + if (!EnablePatchPointLiveness) + return false; + DEBUG(dbgs() << "********** COMPUTING STACKMAP LIVENESS: " << _MF.getName() << " **********\n"); MF = &_MF; - TRI = MF->getTarget().getRegisterInfo(); + TRI = MF->getSubtarget().getRegisterInfo(); ++NumStackMapFuncVisited; - // Skip this function if there are no stackmaps. - if (!MF->getFrameInfo()->hasStackMap()) { + // Skip this function if there are no patchpoints to process. + if (!MF->getFrameInfo()->hasPatchPoint()) { ++NumStackMapFuncSkipped; return false; } @@ -78,17 +89,16 @@ bool StackMapLiveness::calculateLiveness() { LiveRegs.addLiveOuts(MBBI); bool HasStackMap = false; // Reverse iterate over all instructions and add the current live register - // set to an instruction if we encounter a stackmap or patchpoint - // instruction. + // set to an instruction if we encounter a patchpoint instruction. for (MachineBasicBlock::reverse_iterator I = MBBI->rbegin(), E = MBBI->rend(); I != E; ++I) { - if (I->getOpcode() == TargetOpcode::STACKMAP || - I->getOpcode() == TargetOpcode::PATCHPOINT) { + if (I->getOpcode() == TargetOpcode::PATCHPOINT) { addLiveOutSetToMI(*I); HasChanged = true; HasStackMap = true; ++NumStackMaps; } + DEBUG(dbgs() << " " << LiveRegs << " " << *I); LiveRegs.stepBackward(*I); } ++NumBBsVisited; @@ -103,8 +113,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 @@ -115,14 +123,7 @@ uint32_t *StackMapLiveness::createRegisterMask() const { for (LivePhysRegs::const_iterator RI = LiveRegs.begin(), RE = LiveRegs.end(); RI != RE; ++RI) 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"; + TRI->adjustStackMapLiveOutMask(Mask); + return Mask; }