2015-12-16 11:09:48 +00:00
|
|
|
//===------ LiveDebugValues.cpp - Tracking Debug Value MIs ----------------===//
|
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
///
|
|
|
|
/// This pass implements a data flow analysis that propagates debug location
|
|
|
|
/// information by inserting additional DBG_VALUE instructions into the machine
|
|
|
|
/// instruction stream. The pass internally builds debug location liveness
|
|
|
|
/// ranges to determine the points where additional DBG_VALUEs need to be
|
|
|
|
/// inserted.
|
|
|
|
///
|
|
|
|
/// This is a separate pass from DbgValueHistoryCalculator to facilitate
|
|
|
|
/// testing and improve modularity.
|
|
|
|
///
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
2016-01-10 18:08:32 +00:00
|
|
|
#include "llvm/ADT/PostOrderIterator.h"
|
|
|
|
#include "llvm/ADT/SmallPtrSet.h"
|
2016-05-25 22:21:12 +00:00
|
|
|
#include "llvm/ADT/SparseBitVector.h"
|
2016-04-18 09:17:29 +00:00
|
|
|
#include "llvm/ADT/Statistic.h"
|
2016-05-25 22:21:12 +00:00
|
|
|
#include "llvm/ADT/UniqueVector.h"
|
2016-09-28 17:51:14 +00:00
|
|
|
#include "llvm/CodeGen/LexicalScopes.h"
|
2017-02-14 19:08:45 +00:00
|
|
|
#include "llvm/CodeGen/MachineFrameInfo.h"
|
2015-12-16 11:09:48 +00:00
|
|
|
#include "llvm/CodeGen/MachineFunction.h"
|
|
|
|
#include "llvm/CodeGen/MachineFunctionPass.h"
|
|
|
|
#include "llvm/CodeGen/MachineInstrBuilder.h"
|
2017-02-14 19:08:45 +00:00
|
|
|
#include "llvm/CodeGen/MachineMemOperand.h"
|
2015-12-16 11:09:48 +00:00
|
|
|
#include "llvm/CodeGen/Passes.h"
|
2016-04-14 18:29:59 +00:00
|
|
|
#include "llvm/IR/DebugInfo.h"
|
2015-12-16 11:09:48 +00:00
|
|
|
#include "llvm/Support/Debug.h"
|
|
|
|
#include "llvm/Support/raw_ostream.h"
|
2017-02-14 19:08:45 +00:00
|
|
|
#include "llvm/Target/TargetFrameLowering.h"
|
2015-12-16 11:09:48 +00:00
|
|
|
#include "llvm/Target/TargetInstrInfo.h"
|
2016-03-25 17:54:46 +00:00
|
|
|
#include "llvm/Target/TargetLowering.h"
|
2015-12-16 11:09:48 +00:00
|
|
|
#include "llvm/Target/TargetRegisterInfo.h"
|
|
|
|
#include "llvm/Target/TargetSubtargetInfo.h"
|
|
|
|
#include <list>
|
2016-04-18 09:17:29 +00:00
|
|
|
#include <queue>
|
2015-12-16 11:09:48 +00:00
|
|
|
|
|
|
|
using namespace llvm;
|
|
|
|
|
|
|
|
#define DEBUG_TYPE "live-debug-values"
|
|
|
|
|
|
|
|
STATISTIC(NumInserted, "Number of DBG_VALUE instructions inserted");
|
|
|
|
|
|
|
|
namespace {
|
|
|
|
|
2016-05-25 22:21:12 +00:00
|
|
|
// \brief If @MI is a DBG_VALUE with debug value described by a defined
|
|
|
|
// register, returns the number of this register. In the other case, returns 0.
|
2016-05-25 22:37:29 +00:00
|
|
|
static unsigned isDbgValueDescribedByReg(const MachineInstr &MI) {
|
2016-05-25 22:21:12 +00:00
|
|
|
assert(MI.isDebugValue() && "expected a DBG_VALUE");
|
|
|
|
assert(MI.getNumOperands() == 4 && "malformed DBG_VALUE");
|
|
|
|
// If location of variable is described using a register (directly
|
|
|
|
// or indirectly), this register is always a first operand.
|
|
|
|
return MI.getOperand(0).isReg() ? MI.getOperand(0).getReg() : 0;
|
|
|
|
}
|
|
|
|
|
2015-12-16 11:09:48 +00:00
|
|
|
class LiveDebugValues : public MachineFunctionPass {
|
|
|
|
|
|
|
|
private:
|
|
|
|
const TargetRegisterInfo *TRI;
|
|
|
|
const TargetInstrInfo *TII;
|
2017-02-14 19:08:45 +00:00
|
|
|
const TargetFrameLowering *TFI;
|
2016-09-28 17:51:14 +00:00
|
|
|
LexicalScopes LS;
|
|
|
|
|
|
|
|
/// Keeps track of lexical scopes associated with a user value's source
|
|
|
|
/// location.
|
|
|
|
class UserValueScopes {
|
|
|
|
DebugLoc DL;
|
|
|
|
LexicalScopes &LS;
|
|
|
|
SmallPtrSet<const MachineBasicBlock *, 4> LBlocks;
|
|
|
|
|
|
|
|
public:
|
|
|
|
UserValueScopes(DebugLoc D, LexicalScopes &L) : DL(std::move(D)), LS(L) {}
|
|
|
|
|
|
|
|
/// Return true if current scope dominates at least one machine
|
|
|
|
/// instruction in a given machine basic block.
|
|
|
|
bool dominates(MachineBasicBlock *MBB) {
|
|
|
|
if (LBlocks.empty())
|
|
|
|
LS.getMachineBasicBlocks(DL, LBlocks);
|
|
|
|
return LBlocks.count(MBB) != 0 || LS.dominates(DL, MBB);
|
|
|
|
}
|
|
|
|
};
|
2015-12-16 11:09:48 +00:00
|
|
|
|
2016-05-26 21:42:47 +00:00
|
|
|
/// Based on std::pair so it can be used as an index into a DenseMap.
|
2015-12-16 11:09:48 +00:00
|
|
|
typedef std::pair<const DILocalVariable *, const DILocation *>
|
2016-05-26 21:42:47 +00:00
|
|
|
DebugVariableBase;
|
2015-12-16 11:09:48 +00:00
|
|
|
/// A potentially inlined instance of a variable.
|
2016-05-26 21:42:47 +00:00
|
|
|
struct DebugVariable : public DebugVariableBase {
|
|
|
|
DebugVariable(const DILocalVariable *Var, const DILocation *InlinedAt)
|
|
|
|
: DebugVariableBase(Var, InlinedAt) {}
|
2015-12-16 11:09:48 +00:00
|
|
|
|
2016-05-26 21:42:47 +00:00
|
|
|
const DILocalVariable *getVar() const { return this->first; };
|
|
|
|
const DILocation *getInlinedAt() const { return this->second; };
|
2015-12-16 11:09:48 +00:00
|
|
|
|
2016-05-25 22:21:12 +00:00
|
|
|
bool operator<(const DebugVariable &DV) const {
|
2016-05-26 21:42:47 +00:00
|
|
|
if (getVar() == DV.getVar())
|
|
|
|
return getInlinedAt() < DV.getInlinedAt();
|
|
|
|
return getVar() < DV.getVar();
|
2015-12-16 11:09:48 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2016-05-25 22:21:12 +00:00
|
|
|
/// A pair of debug variable and value location.
|
2015-12-16 11:09:48 +00:00
|
|
|
struct VarLoc {
|
2016-05-25 22:21:12 +00:00
|
|
|
const DebugVariable Var;
|
|
|
|
const MachineInstr &MI; ///< Only used for cloning a new DBG_VALUE.
|
2016-09-28 17:51:14 +00:00
|
|
|
mutable UserValueScopes UVS;
|
2016-05-25 22:21:12 +00:00
|
|
|
enum { InvalidKind = 0, RegisterKind } Kind;
|
|
|
|
|
|
|
|
/// The value location. Stored separately to avoid repeatedly
|
|
|
|
/// extracting it from MI.
|
|
|
|
union {
|
|
|
|
struct {
|
|
|
|
uint32_t RegNo;
|
|
|
|
uint32_t Offset;
|
|
|
|
} RegisterLoc;
|
|
|
|
uint64_t Hash;
|
|
|
|
} Loc;
|
|
|
|
|
2016-09-28 17:51:14 +00:00
|
|
|
VarLoc(const MachineInstr &MI, LexicalScopes &LS)
|
2016-05-25 22:21:12 +00:00
|
|
|
: Var(MI.getDebugVariable(), MI.getDebugLoc()->getInlinedAt()), MI(MI),
|
2016-09-28 17:51:14 +00:00
|
|
|
UVS(MI.getDebugLoc(), LS), Kind(InvalidKind) {
|
2016-05-25 22:21:12 +00:00
|
|
|
static_assert((sizeof(Loc) == sizeof(uint64_t)),
|
|
|
|
"hash does not cover all members of Loc");
|
|
|
|
assert(MI.isDebugValue() && "not a DBG_VALUE");
|
|
|
|
assert(MI.getNumOperands() == 4 && "malformed DBG_VALUE");
|
2016-05-25 22:37:29 +00:00
|
|
|
if (int RegNo = isDbgValueDescribedByReg(MI)) {
|
2016-05-25 22:21:12 +00:00
|
|
|
Kind = RegisterKind;
|
|
|
|
Loc.RegisterLoc.RegNo = RegNo;
|
2017-02-14 19:08:45 +00:00
|
|
|
int64_t Offset =
|
2016-05-25 22:21:12 +00:00
|
|
|
MI.isIndirectDebugValue() ? MI.getOperand(1).getImm() : 0;
|
|
|
|
// We don't support offsets larger than 4GiB here. They are
|
|
|
|
// slated to be replaced with DIExpressions anyway.
|
2017-02-14 19:08:45 +00:00
|
|
|
// With indirect debug values used for spill locations, Offset
|
|
|
|
// can be negative.
|
|
|
|
if (Offset == INT64_MIN || std::abs(Offset) >= (1LL << 32))
|
2016-05-25 22:21:12 +00:00
|
|
|
Kind = InvalidKind;
|
|
|
|
else
|
|
|
|
Loc.RegisterLoc.Offset = Offset;
|
|
|
|
}
|
|
|
|
}
|
2015-12-16 11:09:48 +00:00
|
|
|
|
2016-05-25 22:21:12 +00:00
|
|
|
/// If this variable is described by a register, return it,
|
|
|
|
/// otherwise return 0.
|
|
|
|
unsigned isDescribedByReg() const {
|
|
|
|
if (Kind == RegisterKind)
|
|
|
|
return Loc.RegisterLoc.RegNo;
|
|
|
|
return 0;
|
|
|
|
}
|
2015-12-16 11:09:48 +00:00
|
|
|
|
2016-09-28 17:51:14 +00:00
|
|
|
/// Determine whether the lexical scope of this value's debug location
|
|
|
|
/// dominates MBB.
|
|
|
|
bool dominates(MachineBasicBlock &MBB) const { return UVS.dominates(&MBB); }
|
|
|
|
|
2017-01-28 06:53:55 +00:00
|
|
|
#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
|
|
|
|
LLVM_DUMP_METHOD void dump() const { MI.dump(); }
|
|
|
|
#endif
|
2016-05-25 22:21:12 +00:00
|
|
|
|
|
|
|
bool operator==(const VarLoc &Other) const {
|
|
|
|
return Var == Other.Var && Loc.Hash == Other.Loc.Hash;
|
|
|
|
}
|
|
|
|
|
2016-05-26 21:42:47 +00:00
|
|
|
/// This operator guarantees that VarLocs are sorted by Variable first.
|
2016-05-25 22:21:12 +00:00
|
|
|
bool operator<(const VarLoc &Other) const {
|
|
|
|
if (Var == Other.Var)
|
|
|
|
return Loc.Hash < Other.Loc.Hash;
|
|
|
|
return Var < Other.Var;
|
|
|
|
}
|
2015-12-16 11:09:48 +00:00
|
|
|
};
|
|
|
|
|
2016-05-25 22:21:12 +00:00
|
|
|
typedef UniqueVector<VarLoc> VarLocMap;
|
|
|
|
typedef SparseBitVector<> VarLocSet;
|
|
|
|
typedef SmallDenseMap<const MachineBasicBlock *, VarLocSet> VarLocInMBB;
|
2017-02-14 19:08:45 +00:00
|
|
|
struct SpillDebugPair {
|
|
|
|
MachineInstr *SpillInst;
|
|
|
|
MachineInstr *DebugInst;
|
|
|
|
};
|
|
|
|
typedef SmallVector<SpillDebugPair, 4> SpillMap;
|
2015-12-16 11:09:48 +00:00
|
|
|
|
2016-05-26 21:42:47 +00:00
|
|
|
/// This holds the working set of currently open ranges. For fast
|
|
|
|
/// access, this is done both as a set of VarLocIDs, and a map of
|
|
|
|
/// DebugVariable to recent VarLocID. Note that a DBG_VALUE ends all
|
|
|
|
/// previous open ranges for the same variable.
|
|
|
|
class OpenRangesSet {
|
|
|
|
VarLocSet VarLocs;
|
|
|
|
SmallDenseMap<DebugVariableBase, unsigned, 8> Vars;
|
|
|
|
|
|
|
|
public:
|
|
|
|
const VarLocSet &getVarLocs() const { return VarLocs; }
|
|
|
|
|
|
|
|
/// Terminate all open ranges for Var by removing it from the set.
|
|
|
|
void erase(DebugVariable Var) {
|
|
|
|
auto It = Vars.find(Var);
|
|
|
|
if (It != Vars.end()) {
|
|
|
|
unsigned ID = It->second;
|
|
|
|
VarLocs.reset(ID);
|
|
|
|
Vars.erase(It);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/// Terminate all open ranges listed in \c KillSet by removing
|
|
|
|
/// them from the set.
|
|
|
|
void erase(const VarLocSet &KillSet, const VarLocMap &VarLocIDs) {
|
|
|
|
VarLocs.intersectWithComplement(KillSet);
|
|
|
|
for (unsigned ID : KillSet)
|
|
|
|
Vars.erase(VarLocIDs[ID].Var);
|
|
|
|
}
|
|
|
|
|
|
|
|
/// Insert a new range into the set.
|
|
|
|
void insert(unsigned VarLocID, DebugVariableBase Var) {
|
|
|
|
VarLocs.set(VarLocID);
|
|
|
|
Vars.insert({Var, VarLocID});
|
|
|
|
}
|
|
|
|
|
|
|
|
/// Empty the set.
|
|
|
|
void clear() {
|
|
|
|
VarLocs.clear();
|
|
|
|
Vars.clear();
|
|
|
|
}
|
|
|
|
|
|
|
|
/// Return whether the set is empty or not.
|
|
|
|
bool empty() const {
|
|
|
|
assert(Vars.empty() == VarLocs.empty() && "open ranges are inconsistent");
|
|
|
|
return VarLocs.empty();
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2017-02-14 19:08:45 +00:00
|
|
|
bool isSpillInstruction(const MachineInstr &MI, MachineFunction *MF,
|
|
|
|
unsigned &Reg);
|
|
|
|
int extractSpillBaseRegAndOffset(const MachineInstr &MI, unsigned &Reg);
|
|
|
|
|
2016-05-26 21:42:47 +00:00
|
|
|
void transferDebugValue(const MachineInstr &MI, OpenRangesSet &OpenRanges,
|
2016-05-25 22:21:12 +00:00
|
|
|
VarLocMap &VarLocIDs);
|
2017-02-14 19:08:45 +00:00
|
|
|
void transferSpillInst(MachineInstr &MI, OpenRangesSet &OpenRanges,
|
|
|
|
VarLocMap &VarLocIDs, SpillMap &Spills);
|
2016-05-26 21:42:47 +00:00
|
|
|
void transferRegisterDef(MachineInstr &MI, OpenRangesSet &OpenRanges,
|
2016-05-25 22:21:12 +00:00
|
|
|
const VarLocMap &VarLocIDs);
|
2016-05-26 21:42:47 +00:00
|
|
|
bool transferTerminatorInst(MachineInstr &MI, OpenRangesSet &OpenRanges,
|
2016-05-25 22:21:12 +00:00
|
|
|
VarLocInMBB &OutLocs, const VarLocMap &VarLocIDs);
|
2016-05-26 21:42:47 +00:00
|
|
|
bool transfer(MachineInstr &MI, OpenRangesSet &OpenRanges,
|
2017-02-14 19:08:45 +00:00
|
|
|
VarLocInMBB &OutLocs, VarLocMap &VarLocIDs, SpillMap &Spills,
|
|
|
|
bool transferSpills);
|
2015-12-16 11:09:48 +00:00
|
|
|
|
2016-05-25 22:21:12 +00:00
|
|
|
bool join(MachineBasicBlock &MBB, VarLocInMBB &OutLocs, VarLocInMBB &InLocs,
|
2016-09-27 16:46:07 +00:00
|
|
|
const VarLocMap &VarLocIDs,
|
|
|
|
SmallPtrSet<const MachineBasicBlock *, 16> &Visited);
|
2015-12-16 11:09:48 +00:00
|
|
|
|
|
|
|
bool ExtendRanges(MachineFunction &MF);
|
|
|
|
|
|
|
|
public:
|
|
|
|
static char ID;
|
|
|
|
|
|
|
|
/// Default construct and initialize the pass.
|
|
|
|
LiveDebugValues();
|
|
|
|
|
|
|
|
/// Tell the pass manager which passes we depend on and what
|
|
|
|
/// information we preserve.
|
|
|
|
void getAnalysisUsage(AnalysisUsage &AU) const override;
|
|
|
|
|
2016-03-28 17:05:30 +00:00
|
|
|
MachineFunctionProperties getRequiredProperties() const override {
|
|
|
|
return MachineFunctionProperties().set(
|
2016-08-25 01:27:13 +00:00
|
|
|
MachineFunctionProperties::Property::NoVRegs);
|
2016-03-28 17:05:30 +00:00
|
|
|
}
|
|
|
|
|
2015-12-16 11:09:48 +00:00
|
|
|
/// Print to ostream with a message.
|
2016-05-25 22:21:12 +00:00
|
|
|
void printVarLocInMBB(const MachineFunction &MF, const VarLocInMBB &V,
|
|
|
|
const VarLocMap &VarLocIDs, const char *msg,
|
2015-12-16 11:09:48 +00:00
|
|
|
raw_ostream &Out) const;
|
|
|
|
|
|
|
|
/// Calculate the liveness information for the given machine function.
|
|
|
|
bool runOnMachineFunction(MachineFunction &MF) override;
|
|
|
|
};
|
2016-09-28 17:51:14 +00:00
|
|
|
|
2015-12-16 11:09:48 +00:00
|
|
|
} // namespace
|
|
|
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
// Implementation
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
char LiveDebugValues::ID = 0;
|
|
|
|
char &llvm::LiveDebugValuesID = LiveDebugValues::ID;
|
|
|
|
INITIALIZE_PASS(LiveDebugValues, "livedebugvalues", "Live DEBUG_VALUE analysis",
|
|
|
|
false, false)
|
|
|
|
|
|
|
|
/// Default construct and initialize the pass.
|
|
|
|
LiveDebugValues::LiveDebugValues() : MachineFunctionPass(ID) {
|
|
|
|
initializeLiveDebugValuesPass(*PassRegistry::getPassRegistry());
|
|
|
|
}
|
|
|
|
|
|
|
|
/// Tell the pass manager which passes we depend on and what information we
|
|
|
|
/// preserve.
|
|
|
|
void LiveDebugValues::getAnalysisUsage(AnalysisUsage &AU) const {
|
2016-06-08 05:18:01 +00:00
|
|
|
AU.setPreservesCFG();
|
2015-12-16 11:09:48 +00:00
|
|
|
MachineFunctionPass::getAnalysisUsage(AU);
|
|
|
|
}
|
|
|
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
// Debug Range Extension Implementation
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
2017-01-28 06:53:55 +00:00
|
|
|
#ifndef NDEBUG
|
2016-05-25 22:21:12 +00:00
|
|
|
void LiveDebugValues::printVarLocInMBB(const MachineFunction &MF,
|
|
|
|
const VarLocInMBB &V,
|
|
|
|
const VarLocMap &VarLocIDs,
|
|
|
|
const char *msg,
|
2015-12-16 11:09:48 +00:00
|
|
|
raw_ostream &Out) const {
|
2016-09-20 16:04:31 +00:00
|
|
|
Out << '\n' << msg << '\n';
|
2016-05-25 22:21:12 +00:00
|
|
|
for (const MachineBasicBlock &BB : MF) {
|
|
|
|
const auto &L = V.lookup(&BB);
|
|
|
|
Out << "MBB: " << BB.getName() << ":\n";
|
|
|
|
for (unsigned VLL : L) {
|
|
|
|
const VarLoc &VL = VarLocIDs[VLL];
|
2016-05-26 21:42:47 +00:00
|
|
|
Out << " Var: " << VL.Var.getVar()->getName();
|
2015-12-16 11:09:48 +00:00
|
|
|
Out << " MI: ";
|
2016-05-25 22:21:12 +00:00
|
|
|
VL.dump();
|
2015-12-16 11:09:48 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
Out << "\n";
|
|
|
|
}
|
2017-01-28 06:53:55 +00:00
|
|
|
#endif
|
2015-12-16 11:09:48 +00:00
|
|
|
|
2017-02-14 19:08:45 +00:00
|
|
|
/// Given a spill instruction, extract the register and offset used to
|
|
|
|
/// address the spill location in a target independent way.
|
|
|
|
int LiveDebugValues::extractSpillBaseRegAndOffset(const MachineInstr &MI,
|
|
|
|
unsigned &Reg) {
|
|
|
|
assert(MI.hasOneMemOperand() &&
|
|
|
|
"Spill instruction does not have exactly one memory operand?");
|
|
|
|
auto MMOI = MI.memoperands_begin();
|
|
|
|
const PseudoSourceValue *PVal = (*MMOI)->getPseudoValue();
|
|
|
|
assert(PVal->kind() == PseudoSourceValue::FixedStack &&
|
|
|
|
"Inconsistent memory operand in spill instruction");
|
|
|
|
int FI = cast<FixedStackPseudoSourceValue>(PVal)->getFrameIndex();
|
|
|
|
const MachineBasicBlock *MBB = MI.getParent();
|
|
|
|
return TFI->getFrameIndexReference(*MBB->getParent(), FI, Reg);
|
|
|
|
}
|
|
|
|
|
2015-12-16 11:09:48 +00:00
|
|
|
/// End all previous ranges related to @MI and start a new range from @MI
|
|
|
|
/// if it is a DBG_VALUE instr.
|
2016-05-25 22:21:12 +00:00
|
|
|
void LiveDebugValues::transferDebugValue(const MachineInstr &MI,
|
2016-05-26 21:42:47 +00:00
|
|
|
OpenRangesSet &OpenRanges,
|
2016-05-25 22:21:12 +00:00
|
|
|
VarLocMap &VarLocIDs) {
|
2015-12-16 11:09:48 +00:00
|
|
|
if (!MI.isDebugValue())
|
|
|
|
return;
|
2016-05-25 22:21:12 +00:00
|
|
|
const DILocalVariable *Var = MI.getDebugVariable();
|
|
|
|
const DILocation *DebugLoc = MI.getDebugLoc();
|
|
|
|
const DILocation *InlinedAt = DebugLoc->getInlinedAt();
|
|
|
|
assert(Var->isValidLocationForIntrinsic(DebugLoc) &&
|
2015-12-16 11:09:48 +00:00
|
|
|
"Expected inlined-at fields to agree");
|
|
|
|
|
|
|
|
// End all previous ranges of Var.
|
2016-05-26 21:42:47 +00:00
|
|
|
DebugVariable V(Var, InlinedAt);
|
|
|
|
OpenRanges.erase(V);
|
2015-12-16 11:09:48 +00:00
|
|
|
|
2016-05-25 22:21:12 +00:00
|
|
|
// Add the VarLoc to OpenRanges from this DBG_VALUE.
|
2015-12-16 11:09:48 +00:00
|
|
|
// TODO: Currently handles DBG_VALUE which has only reg as location.
|
2016-05-26 21:42:47 +00:00
|
|
|
if (isDbgValueDescribedByReg(MI)) {
|
2016-09-28 17:51:14 +00:00
|
|
|
VarLoc VL(MI, LS);
|
2016-05-26 21:42:47 +00:00
|
|
|
unsigned ID = VarLocIDs.insert(VL);
|
|
|
|
OpenRanges.insert(ID, VL.Var);
|
|
|
|
}
|
2015-12-16 11:09:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/// A definition of a register may mark the end of a range.
|
|
|
|
void LiveDebugValues::transferRegisterDef(MachineInstr &MI,
|
2016-05-26 21:42:47 +00:00
|
|
|
OpenRangesSet &OpenRanges,
|
2016-05-25 22:21:12 +00:00
|
|
|
const VarLocMap &VarLocIDs) {
|
2016-03-25 17:54:46 +00:00
|
|
|
MachineFunction *MF = MI.getParent()->getParent();
|
|
|
|
const TargetLowering *TLI = MF->getSubtarget().getTargetLowering();
|
|
|
|
unsigned SP = TLI->getStackPointerRegisterToSaveRestore();
|
2016-05-25 22:21:12 +00:00
|
|
|
SparseBitVector<> KillSet;
|
2015-12-16 11:09:48 +00:00
|
|
|
for (const MachineOperand &MO : MI.operands()) {
|
2017-03-03 01:08:25 +00:00
|
|
|
// Determine whether the operand is a register def. Assume that call
|
|
|
|
// instructions never clobber SP, because some backends (e.g., AArch64)
|
|
|
|
// never list SP in the regmask.
|
2016-03-25 17:54:46 +00:00
|
|
|
if (MO.isReg() && MO.isDef() && MO.getReg() &&
|
2017-03-03 01:08:25 +00:00
|
|
|
TRI->isPhysicalRegister(MO.getReg()) &&
|
|
|
|
!(MI.isCall() && MO.getReg() == SP)) {
|
2016-03-25 17:54:46 +00:00
|
|
|
// Remove ranges of all aliased registers.
|
|
|
|
for (MCRegAliasIterator RAI(MO.getReg(), TRI, true); RAI.isValid(); ++RAI)
|
2016-05-26 21:42:47 +00:00
|
|
|
for (unsigned ID : OpenRanges.getVarLocs())
|
2016-05-25 22:21:12 +00:00
|
|
|
if (VarLocIDs[ID].isDescribedByReg() == *RAI)
|
|
|
|
KillSet.set(ID);
|
2016-03-25 17:54:46 +00:00
|
|
|
} else if (MO.isRegMask()) {
|
|
|
|
// Remove ranges of all clobbered registers. Register masks don't usually
|
|
|
|
// list SP as preserved. While the debug info may be off for an
|
|
|
|
// instruction or two around callee-cleanup calls, transferring the
|
|
|
|
// DEBUG_VALUE across the call is still a better user experience.
|
2016-05-26 21:42:47 +00:00
|
|
|
for (unsigned ID : OpenRanges.getVarLocs()) {
|
2016-05-25 22:21:12 +00:00
|
|
|
unsigned Reg = VarLocIDs[ID].isDescribedByReg();
|
|
|
|
if (Reg && Reg != SP && MO.clobbersPhysReg(Reg))
|
|
|
|
KillSet.set(ID);
|
|
|
|
}
|
2016-03-25 17:54:46 +00:00
|
|
|
}
|
2015-12-16 11:09:48 +00:00
|
|
|
}
|
2016-05-26 21:42:47 +00:00
|
|
|
OpenRanges.erase(KillSet, VarLocIDs);
|
2015-12-16 11:09:48 +00:00
|
|
|
}
|
|
|
|
|
2017-02-14 19:08:45 +00:00
|
|
|
/// Decide if @MI is a spill instruction and return true if it is. We use 2
|
|
|
|
/// criteria to make this decision:
|
|
|
|
/// - Is this instruction a store to a spill slot?
|
|
|
|
/// - Is there a register operand that is both used and killed?
|
|
|
|
/// TODO: Store optimization can fold spills into other stores (including
|
|
|
|
/// other spills). We do not handle this yet (more than one memory operand).
|
|
|
|
bool LiveDebugValues::isSpillInstruction(const MachineInstr &MI,
|
|
|
|
MachineFunction *MF, unsigned &Reg) {
|
|
|
|
const MachineFrameInfo &FrameInfo = MF->getFrameInfo();
|
|
|
|
int FI;
|
|
|
|
const MachineMemOperand *MMO;
|
|
|
|
|
|
|
|
// TODO: Handle multiple stores folded into one.
|
|
|
|
if (!MI.hasOneMemOperand())
|
|
|
|
return false;
|
|
|
|
|
|
|
|
// To identify a spill instruction, use the same criteria as in AsmPrinter.
|
|
|
|
if (!((TII->isStoreToStackSlotPostFE(MI, FI) ||
|
|
|
|
TII->hasStoreToStackSlot(MI, MMO, FI)) &&
|
|
|
|
FrameInfo.isSpillSlotObjectIndex(FI)))
|
|
|
|
return false;
|
|
|
|
|
|
|
|
// In a spill instruction generated by the InlineSpiller the spilled register
|
|
|
|
// has its kill flag set. Return false if we don't find such a register.
|
|
|
|
Reg = 0;
|
|
|
|
for (const MachineOperand &MO : MI.operands()) {
|
|
|
|
if (MO.isReg() && MO.isUse() && MO.isKill()) {
|
|
|
|
Reg = MO.getReg();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return Reg != 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/// A spilled register may indicate that we have to end the current range of
|
|
|
|
/// a variable and create a new one for the spill location.
|
|
|
|
/// We don't want to insert any instructions in transfer(), so we just create
|
|
|
|
/// the DBG_VALUE witout inserting it and keep track of it in @Spills.
|
|
|
|
/// It will be inserted into the BB when we're done iterating over the
|
|
|
|
/// instructions.
|
|
|
|
void LiveDebugValues::transferSpillInst(MachineInstr &MI,
|
|
|
|
OpenRangesSet &OpenRanges,
|
|
|
|
VarLocMap &VarLocIDs,
|
|
|
|
SpillMap &Spills) {
|
|
|
|
unsigned Reg;
|
|
|
|
MachineFunction *MF = MI.getParent()->getParent();
|
|
|
|
if (!isSpillInstruction(MI, MF, Reg))
|
|
|
|
return;
|
|
|
|
|
|
|
|
// Check if the register is the location of a debug value.
|
|
|
|
for (unsigned ID : OpenRanges.getVarLocs()) {
|
|
|
|
if (VarLocIDs[ID].isDescribedByReg() == Reg) {
|
|
|
|
DEBUG(dbgs() << "Spilling Register " << PrintReg(Reg, TRI) << '('
|
|
|
|
<< VarLocIDs[ID].Var.getVar()->getName() << ")\n");
|
|
|
|
|
|
|
|
// Create a DBG_VALUE instruction to describe the Var in its spilled
|
|
|
|
// location, but don't insert it yet to avoid invalidating the
|
|
|
|
// iterator in our caller.
|
|
|
|
unsigned SpillBase;
|
|
|
|
int SpillOffset = extractSpillBaseRegAndOffset(MI, SpillBase);
|
|
|
|
const MachineInstr *DMI = &VarLocIDs[ID].MI;
|
|
|
|
MachineInstr *SpDMI =
|
|
|
|
BuildMI(*MF, DMI->getDebugLoc(), DMI->getDesc(), true, SpillBase, 0,
|
|
|
|
DMI->getDebugVariable(), DMI->getDebugExpression());
|
|
|
|
SpDMI->getOperand(1).setImm(SpillOffset);
|
|
|
|
DEBUG(dbgs() << "Creating DBG_VALUE inst for spill: ";
|
|
|
|
SpDMI->print(dbgs(), false, TII));
|
|
|
|
|
|
|
|
// The newly created DBG_VALUE instruction SpDMI must be inserted after
|
|
|
|
// MI. Keep track of the pairing.
|
|
|
|
SpillDebugPair MIP = {&MI, SpDMI};
|
|
|
|
Spills.push_back(MIP);
|
|
|
|
|
|
|
|
// End all previous ranges of Var.
|
|
|
|
OpenRanges.erase(VarLocIDs[ID].Var);
|
|
|
|
|
|
|
|
// Add the VarLoc to OpenRanges.
|
|
|
|
VarLoc VL(*SpDMI, LS);
|
|
|
|
unsigned SpillLocID = VarLocIDs.insert(VL);
|
|
|
|
OpenRanges.insert(SpillLocID, VL.Var);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-12-16 11:09:48 +00:00
|
|
|
/// Terminate all open ranges at the end of the current basic block.
|
2016-01-10 03:25:42 +00:00
|
|
|
bool LiveDebugValues::transferTerminatorInst(MachineInstr &MI,
|
2016-05-26 21:42:47 +00:00
|
|
|
OpenRangesSet &OpenRanges,
|
2016-05-25 22:21:12 +00:00
|
|
|
VarLocInMBB &OutLocs,
|
|
|
|
const VarLocMap &VarLocIDs) {
|
2016-01-10 03:25:42 +00:00
|
|
|
bool Changed = false;
|
2015-12-16 11:09:48 +00:00
|
|
|
const MachineBasicBlock *CurMBB = MI.getParent();
|
|
|
|
if (!(MI.isTerminator() || (&MI == &CurMBB->instr_back())))
|
2016-01-10 03:25:42 +00:00
|
|
|
return false;
|
2015-12-16 11:09:48 +00:00
|
|
|
|
|
|
|
if (OpenRanges.empty())
|
2016-01-10 03:25:42 +00:00
|
|
|
return false;
|
2015-12-16 11:09:48 +00:00
|
|
|
|
2016-05-26 21:42:47 +00:00
|
|
|
DEBUG(for (unsigned ID : OpenRanges.getVarLocs()) {
|
|
|
|
// Copy OpenRanges to OutLocs, if not already present.
|
|
|
|
dbgs() << "Add to OutLocs: "; VarLocIDs[ID].dump();
|
|
|
|
});
|
2016-05-25 22:21:12 +00:00
|
|
|
VarLocSet &VLS = OutLocs[CurMBB];
|
2016-05-26 21:42:47 +00:00
|
|
|
Changed = VLS |= OpenRanges.getVarLocs();
|
2015-12-16 11:09:48 +00:00
|
|
|
OpenRanges.clear();
|
2016-01-10 03:25:42 +00:00
|
|
|
return Changed;
|
2015-12-16 11:09:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/// This routine creates OpenRanges and OutLocs.
|
2016-05-26 21:42:47 +00:00
|
|
|
bool LiveDebugValues::transfer(MachineInstr &MI, OpenRangesSet &OpenRanges,
|
2017-02-14 19:08:45 +00:00
|
|
|
VarLocInMBB &OutLocs, VarLocMap &VarLocIDs,
|
|
|
|
SpillMap &Spills, bool transferSpills) {
|
2016-01-10 03:25:42 +00:00
|
|
|
bool Changed = false;
|
2016-05-25 22:21:12 +00:00
|
|
|
transferDebugValue(MI, OpenRanges, VarLocIDs);
|
|
|
|
transferRegisterDef(MI, OpenRanges, VarLocIDs);
|
2017-02-14 19:08:45 +00:00
|
|
|
if (transferSpills)
|
|
|
|
transferSpillInst(MI, OpenRanges, VarLocIDs, Spills);
|
2016-05-25 22:21:12 +00:00
|
|
|
Changed = transferTerminatorInst(MI, OpenRanges, OutLocs, VarLocIDs);
|
2016-01-10 03:25:42 +00:00
|
|
|
return Changed;
|
2015-12-16 11:09:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/// This routine joins the analysis results of all incoming edges in @MBB by
|
|
|
|
/// inserting a new DBG_VALUE instruction at the start of the @MBB - if the same
|
|
|
|
/// source variable in all the predecessors of @MBB reside in the same location.
|
2016-01-10 03:25:42 +00:00
|
|
|
bool LiveDebugValues::join(MachineBasicBlock &MBB, VarLocInMBB &OutLocs,
|
2016-09-27 16:46:07 +00:00
|
|
|
VarLocInMBB &InLocs, const VarLocMap &VarLocIDs,
|
|
|
|
SmallPtrSet<const MachineBasicBlock *, 16> &Visited) {
|
2015-12-16 11:09:48 +00:00
|
|
|
DEBUG(dbgs() << "join MBB: " << MBB.getName() << "\n");
|
2016-01-10 03:25:42 +00:00
|
|
|
bool Changed = false;
|
2015-12-16 11:09:48 +00:00
|
|
|
|
2016-05-25 22:21:12 +00:00
|
|
|
VarLocSet InLocsT; // Temporary incoming locations.
|
2015-12-16 11:09:48 +00:00
|
|
|
|
2016-05-25 22:21:12 +00:00
|
|
|
// For all predecessors of this MBB, find the set of VarLocs that
|
|
|
|
// can be joined.
|
2016-09-27 16:46:07 +00:00
|
|
|
int NumVisited = 0;
|
2015-12-16 11:09:48 +00:00
|
|
|
for (auto p : MBB.predecessors()) {
|
2016-09-27 16:46:07 +00:00
|
|
|
// Ignore unvisited predecessor blocks. As we are processing
|
|
|
|
// the blocks in reverse post-order any unvisited block can
|
|
|
|
// be considered to not remove any incoming values.
|
|
|
|
if (!Visited.count(p))
|
|
|
|
continue;
|
2015-12-16 11:09:48 +00:00
|
|
|
auto OL = OutLocs.find(p);
|
|
|
|
// Join is null in case of empty OutLocs from any of the pred.
|
|
|
|
if (OL == OutLocs.end())
|
2016-01-10 03:25:42 +00:00
|
|
|
return false;
|
2015-12-16 11:09:48 +00:00
|
|
|
|
2016-09-27 16:46:07 +00:00
|
|
|
// Just copy over the Out locs to incoming locs for the first visited
|
|
|
|
// predecessor, and for all other predecessors join the Out locs.
|
|
|
|
if (!NumVisited)
|
2015-12-16 11:09:48 +00:00
|
|
|
InLocsT = OL->second;
|
2016-09-27 16:46:07 +00:00
|
|
|
else
|
|
|
|
InLocsT &= OL->second;
|
|
|
|
NumVisited++;
|
2015-12-16 11:09:48 +00:00
|
|
|
}
|
|
|
|
|
2016-09-28 17:51:14 +00:00
|
|
|
// Filter out DBG_VALUES that are out of scope.
|
|
|
|
VarLocSet KillSet;
|
|
|
|
for (auto ID : InLocsT)
|
|
|
|
if (!VarLocIDs[ID].dominates(MBB))
|
|
|
|
KillSet.set(ID);
|
|
|
|
InLocsT.intersectWithComplement(KillSet);
|
|
|
|
|
2016-09-27 16:46:07 +00:00
|
|
|
// As we are processing blocks in reverse post-order we
|
|
|
|
// should have processed at least one predecessor, unless it
|
|
|
|
// is the entry block which has no predecessor.
|
|
|
|
assert((NumVisited || MBB.pred_empty()) &&
|
|
|
|
"Should have processed at least one predecessor");
|
2015-12-16 11:09:48 +00:00
|
|
|
if (InLocsT.empty())
|
2016-01-10 03:25:42 +00:00
|
|
|
return false;
|
2015-12-16 11:09:48 +00:00
|
|
|
|
2016-05-25 22:21:12 +00:00
|
|
|
VarLocSet &ILS = InLocs[&MBB];
|
2015-12-16 11:09:48 +00:00
|
|
|
|
|
|
|
// Insert DBG_VALUE instructions, if not already inserted.
|
2016-05-25 22:21:12 +00:00
|
|
|
VarLocSet Diff = InLocsT;
|
|
|
|
Diff.intersectWithComplement(ILS);
|
|
|
|
for (auto ID : Diff) {
|
|
|
|
// This VarLoc is not found in InLocs i.e. it is not yet inserted. So, a
|
|
|
|
// new range is started for the var from the mbb's beginning by inserting
|
|
|
|
// a new DBG_VALUE. transfer() will end this range however appropriate.
|
|
|
|
const VarLoc &DiffIt = VarLocIDs[ID];
|
|
|
|
const MachineInstr *DMI = &DiffIt.MI;
|
|
|
|
MachineInstr *MI =
|
|
|
|
BuildMI(MBB, MBB.instr_begin(), DMI->getDebugLoc(), DMI->getDesc(),
|
|
|
|
DMI->isIndirectDebugValue(), DMI->getOperand(0).getReg(), 0,
|
|
|
|
DMI->getDebugVariable(), DMI->getDebugExpression());
|
|
|
|
if (DMI->isIndirectDebugValue())
|
|
|
|
MI->getOperand(1).setImm(DMI->getOperand(1).getImm());
|
|
|
|
DEBUG(dbgs() << "Inserted: "; MI->dump(););
|
|
|
|
ILS.set(ID);
|
|
|
|
++NumInserted;
|
|
|
|
Changed = true;
|
2015-12-16 11:09:48 +00:00
|
|
|
}
|
2016-01-10 03:25:42 +00:00
|
|
|
return Changed;
|
2015-12-16 11:09:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/// Calculate the liveness information for the given machine function and
|
|
|
|
/// extend ranges across basic blocks.
|
|
|
|
bool LiveDebugValues::ExtendRanges(MachineFunction &MF) {
|
|
|
|
|
|
|
|
DEBUG(dbgs() << "\nDebug Range Extension\n");
|
|
|
|
|
|
|
|
bool Changed = false;
|
2016-01-10 03:25:42 +00:00
|
|
|
bool OLChanged = false;
|
|
|
|
bool MBBJoined = false;
|
2015-12-16 11:09:48 +00:00
|
|
|
|
2017-02-14 19:08:45 +00:00
|
|
|
VarLocMap VarLocIDs; // Map VarLoc<>unique ID for use in bitvectors.
|
2016-05-26 21:42:47 +00:00
|
|
|
OpenRangesSet OpenRanges; // Ranges that are open until end of bb.
|
2017-02-14 19:08:45 +00:00
|
|
|
VarLocInMBB OutLocs; // Ranges that exist beyond bb.
|
|
|
|
VarLocInMBB InLocs; // Ranges that are incoming after joining.
|
|
|
|
SpillMap Spills; // DBG_VALUEs associated with spills.
|
2015-12-16 11:09:48 +00:00
|
|
|
|
2016-01-10 18:08:32 +00:00
|
|
|
DenseMap<unsigned int, MachineBasicBlock *> OrderToBB;
|
|
|
|
DenseMap<MachineBasicBlock *, unsigned int> BBToOrder;
|
|
|
|
std::priority_queue<unsigned int, std::vector<unsigned int>,
|
2016-05-25 22:21:12 +00:00
|
|
|
std::greater<unsigned int>>
|
|
|
|
Worklist;
|
2016-01-10 18:08:32 +00:00
|
|
|
std::priority_queue<unsigned int, std::vector<unsigned int>,
|
2016-05-25 22:21:12 +00:00
|
|
|
std::greater<unsigned int>>
|
|
|
|
Pending;
|
|
|
|
|
2015-12-16 11:09:48 +00:00
|
|
|
// Initialize every mbb with OutLocs.
|
2017-02-14 19:08:45 +00:00
|
|
|
// We are not looking at any spill instructions during the initial pass
|
|
|
|
// over the BBs. The LiveDebugVariables pass has already created DBG_VALUE
|
|
|
|
// instructions for spills of registers that are known to be user variables
|
|
|
|
// within the BB in which the spill occurs.
|
2015-12-16 11:09:48 +00:00
|
|
|
for (auto &MBB : MF)
|
|
|
|
for (auto &MI : MBB)
|
2017-02-14 19:08:45 +00:00
|
|
|
transfer(MI, OpenRanges, OutLocs, VarLocIDs, Spills,
|
|
|
|
/*transferSpills=*/false);
|
2016-05-25 22:21:12 +00:00
|
|
|
|
|
|
|
DEBUG(printVarLocInMBB(MF, OutLocs, VarLocIDs, "OutLocs after initialization",
|
|
|
|
dbgs()));
|
2015-12-16 11:09:48 +00:00
|
|
|
|
2016-01-10 18:08:32 +00:00
|
|
|
ReversePostOrderTraversal<MachineFunction *> RPOT(&MF);
|
|
|
|
unsigned int RPONumber = 0;
|
|
|
|
for (auto RI = RPOT.begin(), RE = RPOT.end(); RI != RE; ++RI) {
|
|
|
|
OrderToBB[RPONumber] = *RI;
|
|
|
|
BBToOrder[*RI] = RPONumber;
|
|
|
|
Worklist.push(RPONumber);
|
|
|
|
++RPONumber;
|
|
|
|
}
|
|
|
|
// This is a standard "union of predecessor outs" dataflow problem.
|
|
|
|
// To solve it, we perform join() and transfer() using the two worklist method
|
|
|
|
// until the ranges converge.
|
|
|
|
// Ranges have converged when both worklists are empty.
|
2016-09-27 16:46:07 +00:00
|
|
|
SmallPtrSet<const MachineBasicBlock *, 16> Visited;
|
2016-01-10 18:08:32 +00:00
|
|
|
while (!Worklist.empty() || !Pending.empty()) {
|
|
|
|
// We track what is on the pending worklist to avoid inserting the same
|
|
|
|
// thing twice. We could avoid this with a custom priority queue, but this
|
|
|
|
// is probably not worth it.
|
|
|
|
SmallPtrSet<MachineBasicBlock *, 16> OnPending;
|
2016-09-20 16:04:31 +00:00
|
|
|
DEBUG(dbgs() << "Processing Worklist\n");
|
2016-01-10 18:08:32 +00:00
|
|
|
while (!Worklist.empty()) {
|
|
|
|
MachineBasicBlock *MBB = OrderToBB[Worklist.top()];
|
|
|
|
Worklist.pop();
|
2016-09-27 16:46:07 +00:00
|
|
|
MBBJoined = join(*MBB, OutLocs, InLocs, VarLocIDs, Visited);
|
|
|
|
Visited.insert(MBB);
|
2016-01-10 18:08:32 +00:00
|
|
|
if (MBBJoined) {
|
|
|
|
MBBJoined = false;
|
|
|
|
Changed = true;
|
2017-02-14 19:08:45 +00:00
|
|
|
// Now that we have started to extend ranges across BBs we need to
|
|
|
|
// examine spill instructions to see whether they spill registers that
|
|
|
|
// correspond to user variables.
|
2016-01-10 18:08:32 +00:00
|
|
|
for (auto &MI : *MBB)
|
2017-02-14 19:08:45 +00:00
|
|
|
OLChanged |= transfer(MI, OpenRanges, OutLocs, VarLocIDs, Spills,
|
|
|
|
/*transferSpills=*/true);
|
|
|
|
|
|
|
|
// Add any DBG_VALUE instructions necessitated by spills.
|
|
|
|
for (auto &SP : Spills)
|
|
|
|
MBB->insertAfter(MachineBasicBlock::iterator(*SP.SpillInst),
|
|
|
|
SP.DebugInst);
|
|
|
|
Spills.clear();
|
2016-05-25 22:21:12 +00:00
|
|
|
|
|
|
|
DEBUG(printVarLocInMBB(MF, OutLocs, VarLocIDs,
|
|
|
|
"OutLocs after propagating", dbgs()));
|
|
|
|
DEBUG(printVarLocInMBB(MF, InLocs, VarLocIDs,
|
|
|
|
"InLocs after propagating", dbgs()));
|
2016-01-10 18:08:32 +00:00
|
|
|
|
|
|
|
if (OLChanged) {
|
|
|
|
OLChanged = false;
|
|
|
|
for (auto s : MBB->successors())
|
2016-06-17 18:59:41 +00:00
|
|
|
if (OnPending.insert(s).second) {
|
2016-01-10 18:08:32 +00:00
|
|
|
Pending.push(BBToOrder[s]);
|
|
|
|
}
|
|
|
|
}
|
2015-12-16 11:09:48 +00:00
|
|
|
}
|
|
|
|
}
|
2016-01-10 18:08:32 +00:00
|
|
|
Worklist.swap(Pending);
|
|
|
|
// At this point, pending must be empty, since it was just the empty
|
|
|
|
// worklist
|
|
|
|
assert(Pending.empty() && "Pending should be empty");
|
2015-12-16 11:09:48 +00:00
|
|
|
}
|
2016-01-10 18:08:32 +00:00
|
|
|
|
2016-05-25 22:21:12 +00:00
|
|
|
DEBUG(printVarLocInMBB(MF, OutLocs, VarLocIDs, "Final OutLocs", dbgs()));
|
|
|
|
DEBUG(printVarLocInMBB(MF, InLocs, VarLocIDs, "Final InLocs", dbgs()));
|
2015-12-16 11:09:48 +00:00
|
|
|
return Changed;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool LiveDebugValues::runOnMachineFunction(MachineFunction &MF) {
|
2016-09-28 17:51:14 +00:00
|
|
|
if (!MF.getFunction()->getSubprogram())
|
|
|
|
// LiveDebugValues will already have removed all DBG_VALUEs.
|
|
|
|
return false;
|
|
|
|
|
2015-12-16 11:09:48 +00:00
|
|
|
TRI = MF.getSubtarget().getRegisterInfo();
|
|
|
|
TII = MF.getSubtarget().getInstrInfo();
|
2017-02-14 19:08:45 +00:00
|
|
|
TFI = MF.getSubtarget().getFrameLowering();
|
2016-09-28 17:51:14 +00:00
|
|
|
LS.initialize(MF);
|
2015-12-16 11:09:48 +00:00
|
|
|
|
2016-09-28 17:51:14 +00:00
|
|
|
bool Changed = ExtendRanges(MF);
|
2015-12-16 11:09:48 +00:00
|
|
|
return Changed;
|
|
|
|
}
|