Newer
Older
/// Attempt to eliminate un-necessary PHIs on entry to a block. Examines the
/// live-in values coming from predecessors live-outs, and replaces any PHIs
/// already present in this blocks live-ins with a live-through value if the
/// PHI isn't needed.
/// \p LiveIn Old live-in value, overwritten with new one if live-in changes.
/// \returns true if any live-ins change value, either from value propagation
/// or PHI elimination.
bool vlocJoin(MachineBasicBlock &MBB, LiveIdxT &VLOCOutLocs,
SmallPtrSet<const MachineBasicBlock *, 8> &BlocksToExplore,
DbgValue &LiveIn);
/// For the given block and live-outs feeding into it, try to find a
/// machine location where all the variable values join together.
/// \returns Value ID of a machine PHI if an appropriate one is available.
Optional<ValueIDNum>
pickVPHILoc(const MachineBasicBlock &MBB, const DebugVariable &Var,
const LiveIdxT &LiveOuts, ValueIDNum **MOutLocs,
const SmallVectorImpl<const MachineBasicBlock *> &BlockOrders);
/// Given the solutions to the two dataflow problems, machine value locations
/// in \p MInLocs and live-in variable values in \p SavedLiveIns, runs the
/// TransferTracker class over the function to produce live-in and transfer
/// DBG_VALUEs, then inserts them. Groups of DBG_VALUEs are inserted in the
/// order given by AllVarsNumbering -- this could be any stable order, but
/// right now "order of appearence in function, when explored in RPO", so
/// that we can compare explictly against VarLocBasedImpl.
void emitLocations(MachineFunction &MF, LiveInsT SavedLiveIns,
ValueIDNum **MOutLocs, ValueIDNum **MInLocs,
DenseMap<DebugVariable, unsigned> &AllVarsNumbering,
const TargetPassConfig &TPC);
/// Boilerplate computation of some initial sets, artifical blocks and
/// RPOT block ordering.
void initialSetup(MachineFunction &MF);
bool ExtendRanges(MachineFunction &MF, MachineDominatorTree *DomTree,
TargetPassConfig *TPC, unsigned InputBBLimit,
unsigned InputDbgValLimit) override;
public:
/// Default construct and initialize the pass.
InstrRefBasedLDV();
LLVM_DUMP_METHOD
void dump_mloc_transfer(const MLocTransferMap &mloc_transfer) const;
bool isCalleeSaved(LocIdx L) const;
bool hasFoldedStackStore(const MachineInstr &MI) {
// Instruction must have a memory operand that's a stack slot, and isn't
// aliased, meaning it's a spill from regalloc instead of a variable.
// If it's aliased, we can't guarantee its value.
if (!MI.hasOneMemOperand())
return false;
auto *MemOperand = *MI.memoperands_begin();
return MemOperand->isStore() &&
MemOperand->getPseudoValue() &&
MemOperand->getPseudoValue()->kind() == PseudoSourceValue::FixedStack
&& !MemOperand->getPseudoValue()->isAliased(MFI);
}
Optional<LocIdx> findLocationForMemOperand(const MachineInstr &MI);
};
} // namespace LiveDebugValues
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
namespace llvm {
using namespace LiveDebugValues;
template <> struct DenseMapInfo<LocIdx> {
static inline LocIdx getEmptyKey() { return LocIdx::MakeIllegalLoc(); }
static inline LocIdx getTombstoneKey() { return LocIdx::MakeTombstoneLoc(); }
static unsigned getHashValue(const LocIdx &Loc) { return Loc.asU64(); }
static bool isEqual(const LocIdx &A, const LocIdx &B) { return A == B; }
};
template <> struct DenseMapInfo<ValueIDNum> {
static inline ValueIDNum getEmptyKey() { return ValueIDNum::EmptyValue; }
static inline ValueIDNum getTombstoneKey() {
return ValueIDNum::TombstoneValue;
}
static unsigned getHashValue(const ValueIDNum &Val) { return Val.asU64(); }
static bool isEqual(const ValueIDNum &A, const ValueIDNum &B) {
return A == B;
}
};
} // end namespace llvm
#endif /* LLVM_LIB_CODEGEN_LIVEDEBUGVALUES_INSTRREFBASEDLDV_H */