Progress towards shepherding debug info through SelectionDAG.

No functional effect yet.  This is still evolving and should
not be viewed as final.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@98195 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Dale Johannesen
2010-03-10 22:13:47 +00:00
parent 6663670359
commit bfdf7f3852
10 changed files with 276 additions and 40 deletions

View File

@@ -227,6 +227,7 @@ namespace llvm {
private:
SDNode *Node; // Representative node.
MachineInstr *Instr; // Alternatively, a MachineInstr.
MachineInstr *DbgInstr; // A dbg_value referencing this.
public:
SUnit *OrigNode; // If not this, the node from which
// this node was cloned.
@@ -269,10 +270,10 @@ namespace llvm {
/// SUnit - Construct an SUnit for pre-regalloc scheduling to represent
/// an SDNode and any nodes flagged to it.
SUnit(SDNode *node, unsigned nodenum)
: Node(node), Instr(0), OrigNode(0), NodeNum(nodenum), NodeQueueId(0),
Latency(0), NumPreds(0), NumSuccs(0), NumPredsLeft(0), NumSuccsLeft(0),
isTwoAddress(false), isCommutable(false), hasPhysRegDefs(false),
hasPhysRegClobbers(false),
: Node(node), Instr(0), DbgInstr(0), OrigNode(0), NodeNum(nodenum),
NodeQueueId(0), Latency(0), NumPreds(0), NumSuccs(0), NumPredsLeft(0),
NumSuccsLeft(0), isTwoAddress(false), isCommutable(false),
hasPhysRegDefs(false), hasPhysRegClobbers(false),
isPending(false), isAvailable(false), isScheduled(false),
isScheduleHigh(false), isCloned(false),
isDepthCurrent(false), isHeightCurrent(false), Depth(0), Height(0),
@@ -281,10 +282,10 @@ namespace llvm {
/// SUnit - Construct an SUnit for post-regalloc scheduling to represent
/// a MachineInstr.
SUnit(MachineInstr *instr, unsigned nodenum)
: Node(0), Instr(instr), OrigNode(0), NodeNum(nodenum), NodeQueueId(0),
Latency(0), NumPreds(0), NumSuccs(0), NumPredsLeft(0), NumSuccsLeft(0),
isTwoAddress(false), isCommutable(false), hasPhysRegDefs(false),
hasPhysRegClobbers(false),
: Node(0), Instr(instr), DbgInstr(0), OrigNode(0), NodeNum(nodenum),
NodeQueueId(0), Latency(0), NumPreds(0), NumSuccs(0), NumPredsLeft(0),
NumSuccsLeft(0), isTwoAddress(false), isCommutable(false),
hasPhysRegDefs(false), hasPhysRegClobbers(false),
isPending(false), isAvailable(false), isScheduled(false),
isScheduleHigh(false), isCloned(false),
isDepthCurrent(false), isHeightCurrent(false), Depth(0), Height(0),
@@ -292,10 +293,10 @@ namespace llvm {
/// SUnit - Construct a placeholder SUnit.
SUnit()
: Node(0), Instr(0), OrigNode(0), NodeNum(~0u), NodeQueueId(0),
Latency(0), NumPreds(0), NumSuccs(0), NumPredsLeft(0), NumSuccsLeft(0),
isTwoAddress(false), isCommutable(false), hasPhysRegDefs(false),
hasPhysRegClobbers(false),
: Node(0), Instr(0), DbgInstr(0), OrigNode(0), NodeNum(~0u),
NodeQueueId(0), Latency(0), NumPreds(0), NumSuccs(0), NumPredsLeft(0),
NumSuccsLeft(0), isTwoAddress(false), isCommutable(false),
hasPhysRegDefs(false), hasPhysRegClobbers(false),
isPending(false), isAvailable(false), isScheduled(false),
isScheduleHigh(false), isCloned(false),
isDepthCurrent(false), isHeightCurrent(false), Depth(0), Height(0),
@@ -329,6 +330,20 @@ namespace llvm {
return Instr;
}
/// setDbgInstr - Assign the debug instruction for the SUnit.
/// This may be used during post-regalloc scheduling.
void setDbgInstr(MachineInstr *MI) {
assert(!Node && "Setting debug MachineInstr of SUnit with SDNode!");
DbgInstr = MI;
}
/// getDbgInstr - Return the debug MachineInstr for this SUnit.
/// This may be used during post-regalloc scheduling.
MachineInstr *getDbgInstr() const {
assert(!Node && "Reading debug MachineInstr of SUnit with SDNode!");
return DbgInstr;
}
/// addPred - This adds the specified edge as a pred of the current node if
/// not already. It also adds the current node as a successor of the
/// specified node.

View File

@@ -35,6 +35,7 @@ class MachineConstantPoolValue;
class MachineFunction;
class MachineModuleInfo;
class SDNodeOrdering;
class SDDbgValue;
class TargetLowering;
template<> struct ilist_traits<SDNode> : public ilist_default_traits<SDNode> {
@@ -57,6 +58,46 @@ private:
static void createNode(const SDNode &);
};
/// SDDbgInfo - Keeps track of dbg_value information through SDISel. We do
/// not build SDNodes for these so as not to perturb the generated code;
/// instead the info is kept off to the side in this structure. SDNodes may
/// have an associated dbg_value entry in DbgValMap. Debug info that is not
/// associated with any SDNode is held in DbgConstMap. It is possible for
/// optimizations to change a variable to a constant, in which case the
/// corresponding debug info is moved from the variable to the constant table
/// (NYI).
class SDDbgInfo {
DenseMap<const SDNode*, SDDbgValue*> DbgVblMap;
SmallVector<SDDbgValue*, 4> DbgConstMap;
void operator=(const SDDbgInfo&); // Do not implement.
SDDbgInfo(const SDDbgInfo&); // Do not implement.
public:
SDDbgInfo() {}
void add(const SDNode *Node, SDDbgValue *V) {
DbgVblMap[Node] = V;
}
void add(SDDbgValue *V) { DbgConstMap.push_back(V); }
void remove(const SDNode *Node) {
DenseMap<const SDNode*, SDDbgValue*>::iterator Itr =
DbgVblMap.find(Node);
if (Itr != DbgVblMap.end())
DbgVblMap.erase(Itr);
}
// No need to remove a constant.
void clear() {
DbgVblMap.clear();
DbgConstMap.clear();
}
SDDbgValue *getSDDbgValue(const SDNode *Node) {
return DbgVblMap[Node];
}
typedef SmallVector<SDDbgValue*, 4>::iterator ConstDbgIterator;
ConstDbgIterator DbgConstBegin() { return DbgConstMap.begin(); }
ConstDbgIterator DbgConstEnd() { return DbgConstMap.end(); }
};
enum CombineLevel {
Unrestricted, // Combine may create illegal operations and illegal types.
NoIllegalTypes, // Combine may create illegal operations but no illegal types.
@@ -119,6 +160,9 @@ class SelectionDAG {
/// the ordering of the original LLVM instructions.
SDNodeOrdering *Ordering;
/// DbgInfo - Tracks dbg_value information through SDISel.
SDDbgInfo *DbgInfo;
/// VerifyNode - Sanity check the given node. Aborts if it is invalid.
void VerifyNode(SDNode *N);
@@ -828,6 +872,20 @@ public:
/// GetOrdering - Get the order for the SDNode.
unsigned GetOrdering(const SDNode *SD) const;
/// AssignDbgInfo - Assign debug info to the SDNode.
void AssignDbgInfo(SDNode *SD, SDDbgValue *db);
/// RememberDbgInfo - Remember debug info with no associated SDNode.
void RememberDbgInfo(SDDbgValue *db);
/// GetDbgInfo - Get the debug info for the SDNode.
SDDbgValue *GetDbgInfo(const SDNode* SD);
SDDbgInfo::ConstDbgIterator DbgConstBegin() {
return DbgInfo->DbgConstBegin();
}
SDDbgInfo::ConstDbgIterator DbgConstEnd() { return DbgInfo->DbgConstEnd(); }
void dump() const;
/// CreateStackTemporary - Create a stack temporary, suitable for holding the