mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2025-04-12 20:48:17 +00:00

Here is a theoretical example that illustrates why the placement is important. tmp1 = store tmp1 -> x ... tmp2 = add ... ... call ... store tmp2 -> x Now mem2reg comes along: tmp1 = dbg_value (tmp1 -> x) ... tmp2 = add ... ... call ... dbg_value (tmp2 -> x) When the debugger examine the value of x after the add instruction but before the call, it should have the value of tmp1. Furthermore, for dbg_value's that reference constants, they should not be emitted at the beginning of the block (since they do not have "producers"). This patch also cleans up how SDISel manages DbgValue nodes. It allow a SDNode to be referenced by multiple SDDbgValue nodes. When a SDNode is deleted, it uses the information to find the SDDbgValues and invalidate them. They are not deleted until the corresponding SelectionDAG is destroyed. llvm-svn: 99469
113 lines
3.2 KiB
C++
113 lines
3.2 KiB
C++
//===-- llvm/CodeGen/SDNodeDbgValue.h - SelectionDAG dbg_value --*- C++ -*-===//
|
|
//
|
|
// The LLVM Compiler Infrastructure
|
|
//
|
|
// This file is distributed under the University of Illinois Open Source
|
|
// License. See LICENSE.TXT for details.
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
//
|
|
// This file declares the SDDbgValue class.
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
#ifndef LLVM_CODEGEN_SDNODEDBGVALUE_H
|
|
#define LLVM_CODEGEN_SDNODEDBGVALUE_H
|
|
|
|
#include "llvm/ADT/SmallVector.h"
|
|
#include "llvm/Support/DebugLoc.h"
|
|
|
|
namespace llvm {
|
|
|
|
class MDNode;
|
|
class SDNode;
|
|
class Value;
|
|
|
|
/// SDDbgValue - Holds the information from a dbg_value node through SDISel.
|
|
/// We do not use SDValue here to avoid including its header.
|
|
|
|
class SDDbgValue {
|
|
public:
|
|
enum DbgValueKind {
|
|
SDNODE = 0, // value is the result of an expression
|
|
CONST = 1, // value is a constant
|
|
FRAMEIX = 2 // value is contents of a stack location
|
|
};
|
|
private:
|
|
enum DbgValueKind kind;
|
|
union {
|
|
struct {
|
|
SDNode *Node; // valid for expressions
|
|
unsigned ResNo; // valid for expressions
|
|
} s;
|
|
Value *Const; // valid for constants
|
|
unsigned FrameIx; // valid for stack objects
|
|
} u;
|
|
MDNode *mdPtr;
|
|
uint64_t Offset;
|
|
DebugLoc DL;
|
|
unsigned Order;
|
|
bool Invalid;
|
|
public:
|
|
// Constructor for non-constants.
|
|
SDDbgValue(MDNode *mdP, SDNode *N, unsigned R, uint64_t off, DebugLoc dl,
|
|
unsigned O) : mdPtr(mdP), Offset(off), DL(dl), Order(O),
|
|
Invalid(false) {
|
|
kind = SDNODE;
|
|
u.s.Node = N;
|
|
u.s.ResNo = R;
|
|
}
|
|
|
|
// Constructor for constants.
|
|
SDDbgValue(MDNode *mdP, Value *C, uint64_t off, DebugLoc dl, unsigned O) :
|
|
mdPtr(mdP), Offset(off), DL(dl), Order(O) {
|
|
kind = CONST;
|
|
u.Const = C;
|
|
}
|
|
|
|
// Constructor for frame indices.
|
|
SDDbgValue(MDNode *mdP, unsigned FI, uint64_t off, DebugLoc dl, unsigned O) :
|
|
mdPtr(mdP), Offset(off), DL(dl), Order(O) {
|
|
kind = FRAMEIX;
|
|
u.FrameIx = FI;
|
|
}
|
|
|
|
// Returns the kind.
|
|
DbgValueKind getKind() { return kind; }
|
|
|
|
// Returns the MDNode pointer.
|
|
MDNode *getMDPtr() { return mdPtr; }
|
|
|
|
// Returns the SDNode* for a register ref
|
|
SDNode *getSDNode() { assert (kind==SDNODE); return u.s.Node; }
|
|
|
|
// Returns the ResNo for a register ref
|
|
unsigned getResNo() { assert (kind==SDNODE); return u.s.ResNo; }
|
|
|
|
// Returns the Value* for a constant
|
|
Value *getConst() { assert (kind==CONST); return u.Const; }
|
|
|
|
// Returns the FrameIx for a stack object
|
|
unsigned getFrameIx() { assert (kind==FRAMEIX); return u.FrameIx; }
|
|
|
|
// Returns the offset.
|
|
uint64_t getOffset() { return Offset; }
|
|
|
|
// Returns the DebugLoc.
|
|
DebugLoc getDebugLoc() { return DL; }
|
|
|
|
// Returns the SDNodeOrder. This is the order of the preceding node in the
|
|
// input.
|
|
unsigned getOrder() { return Order; }
|
|
|
|
// setIsInvalidated / isInvalidated - Setter / getter of the "Invalidated"
|
|
// property. A SDDbgValue is invalid if the SDNode that produces the value is
|
|
// deleted.
|
|
void setIsInvalidated() { Invalid = true; }
|
|
bool isInvalidated() { return Invalid; }
|
|
};
|
|
|
|
} // end llvm namespace
|
|
|
|
#endif
|