/// be used by the DAGBuilder, the other to be used by others.
class SDLoc {
private:
- // Ptr could be used for either Instruction* or SDNode*. It is used for
- // Instruction* if IROrder is not -1.
- const void *Ptr;
- int IROrder;
+ DebugLoc DL;
+ int IROrder = 0;
public:
- SDLoc() : Ptr(nullptr), IROrder(0) {}
- SDLoc(const SDNode *N) : Ptr(N), IROrder(-1) {
- assert(N && "null SDNode");
- }
- SDLoc(const SDValue V) : Ptr(V.getNode()), IROrder(-1) {
- assert(Ptr && "null SDNode");
- }
- SDLoc(const Instruction *I, int Order) : Ptr(I), IROrder(Order) {
+ SDLoc() = default;
+ SDLoc(const SDNode *N) : DL(N->getDebugLoc()), IROrder(N->getIROrder()) {}
+ SDLoc(const SDValue V) : SDLoc(V.getNode()) {}
+ SDLoc(const Instruction *I, int Order) : IROrder(Order) {
assert(Order >= 0 && "bad IROrder");
+ if (I)
+ DL = I->getDebugLoc();
}
- unsigned getIROrder() {
- if (IROrder >= 0 || Ptr == nullptr) {
- return (unsigned)IROrder;
- }
- const SDNode *N = (const SDNode*)(Ptr);
- return N->getIROrder();
- }
- DebugLoc getDebugLoc() {
- if (!Ptr) {
- return DebugLoc();
- }
- if (IROrder >= 0) {
- const Instruction *I = (const Instruction*)(Ptr);
- return I->getDebugLoc();
- }
- const SDNode *N = (const SDNode*)(Ptr);
- return N->getDebugLoc();
- }
+ unsigned getIROrder() { return IROrder; }
+ DebugLoc getDebugLoc() { return DL; }
};