Remove the unused dbg.value offset from SelectionDAG (NFC)

Followup to r309426.
rdar://problem/33580047

llvm-svn: 309436
This commit is contained in:
Adrian Prantl 2017-07-28 21:27:35 +00:00
parent 67de34897c
commit a617576bb1
6 changed files with 46 additions and 68 deletions

View File

@ -1167,17 +1167,15 @@ public:
/// Creates a SDDbgValue node.
SDDbgValue *getDbgValue(MDNode *Var, MDNode *Expr, SDNode *N, unsigned R,
bool IsIndirect, uint64_t Off, const DebugLoc &DL,
unsigned O);
bool IsIndirect, const DebugLoc &DL, unsigned O);
/// Constant
SDDbgValue *getConstantDbgValue(MDNode *Var, MDNode *Expr, const Value *C,
uint64_t Off, const DebugLoc &DL, unsigned O);
const DebugLoc &DL, unsigned O);
/// FrameIndex
SDDbgValue *getFrameIndexDbgValue(MDNode *Var, MDNode *Expr, unsigned FI,
uint64_t Off, const DebugLoc &DL,
unsigned O);
const DebugLoc &DL, unsigned O);
/// Remove the specified node from the system. If any of its
/// operands then becomes dead, remove them as well. Inform UpdateListener

View File

@ -673,7 +673,6 @@ void InstrEmitter::EmitRegSequence(SDNode *Node,
MachineInstr *
InstrEmitter::EmitDbgValue(SDDbgValue *SD,
DenseMap<SDValue, unsigned> &VRBaseMap) {
uint64_t Offset = SD->getOffset();
MDNode *Var = SD->getVariable();
MDNode *Expr = SD->getExpression();
DebugLoc DL = SD->getDebugLoc();
@ -685,7 +684,7 @@ InstrEmitter::EmitDbgValue(SDDbgValue *SD,
// EmitTargetCodeForFrameDebugValue is responsible for allocation.
return BuildMI(*MF, DL, TII->get(TargetOpcode::DBG_VALUE))
.addFrameIndex(SD->getFrameIx())
.addImm(Offset)
.addImm(0)
.addMetadata(Var)
.addMetadata(Expr);
}
@ -727,11 +726,9 @@ InstrEmitter::EmitDbgValue(SDDbgValue *SD,
// Indirect addressing is indicated by an Imm as the second parameter.
if (SD->isIndirect())
MIB.addImm(Offset);
else {
assert(Offset == 0 && "direct value cannot have an offset");
MIB.addImm(0U);
else
MIB.addReg(0U, RegState::Debug);
}
MIB.addMetadata(Var);
MIB.addMetadata(Expr);

View File

@ -45,7 +45,6 @@ private:
} u;
MDNode *Var;
MDNode *Expr;
uint64_t Offset;
DebugLoc DL;
unsigned Order;
enum DbgValueKind kind;
@ -55,28 +54,23 @@ private:
public:
// Constructor for non-constants.
SDDbgValue(MDNode *Var, MDNode *Expr, SDNode *N, unsigned R, bool indir,
uint64_t off, DebugLoc dl, unsigned O)
: Var(Var), Expr(Expr), Offset(off), DL(std::move(dl)), Order(O),
IsIndirect(indir) {
DebugLoc dl, unsigned O)
: Var(Var), Expr(Expr), DL(std::move(dl)), Order(O), IsIndirect(indir) {
kind = SDNODE;
u.s.Node = N;
u.s.ResNo = R;
}
// Constructor for constants.
SDDbgValue(MDNode *Var, MDNode *Expr, const Value *C, uint64_t off,
DebugLoc dl, unsigned O)
: Var(Var), Expr(Expr), Offset(off), DL(std::move(dl)), Order(O),
IsIndirect(false) {
SDDbgValue(MDNode *Var, MDNode *Expr, const Value *C, DebugLoc dl, unsigned O)
: Var(Var), Expr(Expr), DL(std::move(dl)), Order(O), IsIndirect(false) {
kind = CONST;
u.Const = C;
}
// Constructor for frame indices.
SDDbgValue(MDNode *Var, MDNode *Expr, unsigned FI, uint64_t off, DebugLoc dl,
unsigned O)
: Var(Var), Expr(Expr), Offset(off), DL(std::move(dl)), Order(O),
IsIndirect(false) {
SDDbgValue(MDNode *Var, MDNode *Expr, unsigned FI, DebugLoc dl, unsigned O)
: Var(Var), Expr(Expr), DL(std::move(dl)), Order(O), IsIndirect(false) {
kind = FRAMEIX;
u.FrameIx = FI;
}
@ -105,9 +99,6 @@ public:
// Returns whether this is an indirect value.
bool isIndirect() const { return IsIndirect; }
// Returns the offset.
uint64_t getOffset() const { return Offset; }
// Returns the DebugLoc.
DebugLoc getDebugLoc() const { return DL; }

View File

@ -6843,31 +6843,30 @@ SDNode *SelectionDAG::getNodeIfExists(unsigned Opcode, SDVTList VTList,
///
/// SDNode
SDDbgValue *SelectionDAG::getDbgValue(MDNode *Var, MDNode *Expr, SDNode *N,
unsigned R, bool IsIndirect, uint64_t Off,
unsigned R, bool IsIndirect,
const DebugLoc &DL, unsigned O) {
assert(cast<DILocalVariable>(Var)->isValidLocationForIntrinsic(DL) &&
"Expected inlined-at fields to agree");
return new (DbgInfo->getAlloc())
SDDbgValue(Var, Expr, N, R, IsIndirect, Off, DL, O);
SDDbgValue(Var, Expr, N, R, IsIndirect, DL, O);
}
/// Constant
SDDbgValue *SelectionDAG::getConstantDbgValue(MDNode *Var, MDNode *Expr,
const Value *C, uint64_t Off,
const Value *C,
const DebugLoc &DL, unsigned O) {
assert(cast<DILocalVariable>(Var)->isValidLocationForIntrinsic(DL) &&
"Expected inlined-at fields to agree");
return new (DbgInfo->getAlloc()) SDDbgValue(Var, Expr, C, Off, DL, O);
return new (DbgInfo->getAlloc()) SDDbgValue(Var, Expr, C, DL, O);
}
/// FrameIndex
SDDbgValue *SelectionDAG::getFrameIndexDbgValue(MDNode *Var, MDNode *Expr,
unsigned FI, uint64_t Off,
const DebugLoc &DL,
unsigned FI, const DebugLoc &DL,
unsigned O) {
assert(cast<DILocalVariable>(Var)->isValidLocationForIntrinsic(DL) &&
"Expected inlined-at fields to agree");
return new (DbgInfo->getAlloc()) SDDbgValue(Var, Expr, FI, Off, DL, O);
return new (DbgInfo->getAlloc()) SDDbgValue(Var, Expr, FI, DL, O);
}
namespace {
@ -7301,9 +7300,8 @@ void SelectionDAG::TransferDbgValues(SDValue From, SDValue To) {
Dbg->getResNo() == From.getResNo() && !Dbg->isInvalidated()) {
assert(FromNode != ToNode &&
"Should not transfer Debug Values intranode");
SDDbgValue *Clone =
getDbgValue(Dbg->getVariable(), Dbg->getExpression(), ToNode,
To.getResNo(), Dbg->isIndirect(), Dbg->getOffset(),
SDDbgValue *Clone = getDbgValue(Dbg->getVariable(), Dbg->getExpression(),
ToNode, To.getResNo(), Dbg->isIndirect(),
Dbg->getDebugLoc(), Dbg->getOrder());
ClonedDVs.push_back(Clone);
Dbg->setIsInvalidated();

View File

@ -1004,12 +1004,10 @@ void SelectionDAGBuilder::resolveDanglingDebugInfo(const Value *V,
DIExpression *Expr = DI->getExpression();
assert(Variable->isValidLocationForIntrinsic(dl) &&
"Expected inlined-at fields to agree");
uint64_t Offset = 0;
SDDbgValue *SDV;
if (Val.getNode()) {
if (!EmitFuncArgumentDbgValue(V, Variable, Expr, dl, Offset, false,
Val)) {
SDV = getDbgValue(Val, Variable, Expr, Offset, dl, DbgSDNodeOrder);
if (!EmitFuncArgumentDbgValue(V, Variable, Expr, dl, false, Val)) {
SDV = getDbgValue(Val, Variable, Expr, dl, DbgSDNodeOrder);
DAG.AddDbgValue(SDV, Val.getNode(), false);
}
} else
@ -4753,12 +4751,12 @@ static unsigned getUnderlyingArgReg(const SDValue &N) {
}
}
/// EmitFuncArgumentDbgValue - If the DbgValueInst is a dbg_value of a function
/// argument, create the corresponding DBG_VALUE machine instruction for it now.
/// At the end of instruction selection, they will be inserted to the entry BB.
/// If the DbgValueInst is a dbg_value of a function argument, create the
/// corresponding DBG_VALUE machine instruction for it now. At the end of
/// instruction selection, they will be inserted to the entry BB.
bool SelectionDAGBuilder::EmitFuncArgumentDbgValue(
const Value *V, DILocalVariable *Variable, DIExpression *Expr,
DILocation *DL, int64_t Offset, bool IsDbgDeclare, const SDValue &N) {
DILocation *DL, bool IsDbgDeclare, const SDValue &N) {
const Argument *Arg = dyn_cast<Argument>(V);
if (!Arg)
return false;
@ -4817,12 +4815,12 @@ bool SelectionDAGBuilder::EmitFuncArgumentDbgValue(
if (Op->isReg())
FuncInfo.ArgDbgValues.push_back(
BuildMI(MF, DL, TII->get(TargetOpcode::DBG_VALUE), IsIndirect,
Op->getReg(), Offset, Variable, Expr));
Op->getReg(), 0, Variable, Expr));
else
FuncInfo.ArgDbgValues.push_back(
BuildMI(MF, DL, TII->get(TargetOpcode::DBG_VALUE))
.add(*Op)
.addImm(Offset)
.addImm(0)
.addMetadata(Variable)
.addMetadata(Expr));
@ -4832,18 +4830,18 @@ bool SelectionDAGBuilder::EmitFuncArgumentDbgValue(
/// Return the appropriate SDDbgValue based on N.
SDDbgValue *SelectionDAGBuilder::getDbgValue(SDValue N,
DILocalVariable *Variable,
DIExpression *Expr, int64_t Offset,
DIExpression *Expr,
const DebugLoc &dl,
unsigned DbgSDNodeOrder) {
if (auto *FISDN = dyn_cast<FrameIndexSDNode>(N.getNode())) {
// Construct a FrameIndexDbgValue for FrameIndexSDNodes so we can describe
// stack slot locations as such instead of as indirectly addressed
// locations.
return DAG.getFrameIndexDbgValue(Variable, Expr, FISDN->getIndex(), 0, dl,
return DAG.getFrameIndexDbgValue(Variable, Expr, FISDN->getIndex(), dl,
DbgSDNodeOrder);
}
return DAG.getDbgValue(Variable, Expr, N.getNode(), N.getResNo(), false,
Offset, dl, DbgSDNodeOrder);
return DAG.getDbgValue(Variable, Expr, N.getNode(), N.getResNo(), false, dl,
DbgSDNodeOrder);
}
// VisualStudio defines setjmp as _setjmp
@ -5112,21 +5110,21 @@ SelectionDAGBuilder::visitIntrinsicCall(const CallInst &I, unsigned Intrinsic) {
if (isParameter && FINode) {
// Byval parameter. We have a frame index at this point.
SDV = DAG.getFrameIndexDbgValue(Variable, Expression,
FINode->getIndex(), 0, dl, SDNodeOrder);
FINode->getIndex(), dl, SDNodeOrder);
} else if (isa<Argument>(Address)) {
// Address is an argument, so try to emit its dbg value using
// virtual register info from the FuncInfo.ValueMap.
EmitFuncArgumentDbgValue(Address, Variable, Expression, dl, 0, true, N);
EmitFuncArgumentDbgValue(Address, Variable, Expression, dl, true, N);
return nullptr;
} else {
SDV = DAG.getDbgValue(Variable, Expression, N.getNode(), N.getResNo(),
true, 0, dl, SDNodeOrder);
true, dl, SDNodeOrder);
}
DAG.AddDbgValue(SDV, N.getNode(), isParameter);
} else {
// If Address is an argument then try to emit its dbg value using
// virtual register info from the FuncInfo.ValueMap.
if (!EmitFuncArgumentDbgValue(Address, Variable, Expression, dl, 0, true,
if (!EmitFuncArgumentDbgValue(Address, Variable, Expression, dl, true,
N)) {
DEBUG(dbgs() << "Dropping debug info for " << DI << "\n");
}
@ -5139,15 +5137,13 @@ SelectionDAGBuilder::visitIntrinsicCall(const CallInst &I, unsigned Intrinsic) {
DILocalVariable *Variable = DI.getVariable();
DIExpression *Expression = DI.getExpression();
uint64_t Offset = 0;
const Value *V = DI.getValue();
if (!V)
return nullptr;
SDDbgValue *SDV;
if (isa<ConstantInt>(V) || isa<ConstantFP>(V) || isa<UndefValue>(V)) {
SDV = DAG.getConstantDbgValue(Variable, Expression, V, Offset, dl,
SDNodeOrder);
SDV = DAG.getConstantDbgValue(Variable, Expression, V, dl, SDNodeOrder);
DAG.AddDbgValue(SDV, nullptr, false);
return nullptr;
}
@ -5158,10 +5154,9 @@ SelectionDAGBuilder::visitIntrinsicCall(const CallInst &I, unsigned Intrinsic) {
if (!N.getNode() && isa<Argument>(V)) // Check unused arguments map.
N = UnusedArgNodeMap[V];
if (N.getNode()) {
if (EmitFuncArgumentDbgValue(V, Variable, Expression, dl, Offset, false,
N))
if (EmitFuncArgumentDbgValue(V, Variable, Expression, dl, false, N))
return nullptr;
SDV = getDbgValue(N, Variable, Expression, Offset, dl, SDNodeOrder);
SDV = getDbgValue(N, Variable, Expression, dl, SDNodeOrder);
DAG.AddDbgValue(SDV, N.getNode(), false);
return nullptr;
}

View File

@ -923,13 +923,12 @@ private:
void emitInlineAsmError(ImmutableCallSite CS, const Twine &Message);
/// EmitFuncArgumentDbgValue - If V is an function argument then create
/// corresponding DBG_VALUE machine instruction for it now. At the end of
/// instruction selection, they will be inserted to the entry BB.
/// If V is an function argument then create corresponding DBG_VALUE machine
/// instruction for it now. At the end of instruction selection, they will be
/// inserted to the entry BB.
bool EmitFuncArgumentDbgValue(const Value *V, DILocalVariable *Variable,
DIExpression *Expr, DILocation *DL,
int64_t Offset, bool IsDbgDeclare,
const SDValue &N);
bool IsDbgDeclare, const SDValue &N);
/// Return the next block after MBB, or nullptr if there is none.
MachineBasicBlock *NextBlock(MachineBasicBlock *MBB);
@ -940,8 +939,8 @@ private:
/// Return the appropriate SDDbgValue based on N.
SDDbgValue *getDbgValue(SDValue N, DILocalVariable *Variable,
DIExpression *Expr, int64_t Offset,
const DebugLoc &dl, unsigned DbgSDNodeOrder);
DIExpression *Expr, const DebugLoc &dl,
unsigned DbgSDNodeOrder);
};
/// RegsForValue - This struct represents the registers (physical or virtual)