AsmPrinter: Stop storing MDLocalVariable in DebugLocEntry

Stop storing the `MDLocalVariable` in the `DebugLocEntry::Value`s.  We
generate the list of `DebugLocEntry`s separately for each
variable/inlined-at pair, so the variable never actually changes here.

This is effectively NFC (aside from saving some memory and CPU time).

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@235202 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Duncan P. N. Exon Smith 2015-04-17 16:33:37 +00:00
parent 7c554b51ea
commit f98df953fb
2 changed files with 19 additions and 31 deletions

View File

@ -28,27 +28,23 @@ class DebugLocEntry {
public:
/// \brief A single location or constant.
struct Value {
Value(const MDNode *Var, const MDNode *Expr, int64_t i)
: Variable(Var), Expression(Expr), EntryKind(E_Integer) {
Value(const MDNode *Expr, int64_t i)
: Expression(Expr), EntryKind(E_Integer) {
Constant.Int = i;
}
Value(const MDNode *Var, const MDNode *Expr, const ConstantFP *CFP)
: Variable(Var), Expression(Expr), EntryKind(E_ConstantFP) {
Value(const MDNode *Expr, const ConstantFP *CFP)
: Expression(Expr), EntryKind(E_ConstantFP) {
Constant.CFP = CFP;
}
Value(const MDNode *Var, const MDNode *Expr, const ConstantInt *CIP)
: Variable(Var), Expression(Expr), EntryKind(E_ConstantInt) {
Value(const MDNode *Expr, const ConstantInt *CIP)
: Expression(Expr), EntryKind(E_ConstantInt) {
Constant.CIP = CIP;
}
Value(const MDNode *Var, const MDNode *Expr, MachineLocation Loc)
: Variable(Var), Expression(Expr), EntryKind(E_Location), Loc(Loc) {
assert(isa<MDLocalVariable>(Var));
Value(const MDNode *Expr, MachineLocation Loc)
: Expression(Expr), EntryKind(E_Location), Loc(Loc) {
assert(cast<MDExpression>(Expr)->isValid());
}
/// The variable to which this location entry corresponds.
const MDNode *Variable;
/// Any complex address location expression for this Value.
const MDNode *Expression;
@ -74,7 +70,6 @@ public:
const ConstantFP *getConstantFP() const { return Constant.CFP; }
const ConstantInt *getConstantInt() const { return Constant.CIP; }
MachineLocation getLoc() const { return Loc; }
DIVariable getVariable() const { return cast<MDLocalVariable>(Variable); }
bool isBitPiece() const { return getExpression()->isBitPiece(); }
DIExpression getExpression() const {
return cast_or_null<MDExpression>(Expression);
@ -103,11 +98,9 @@ public:
bool MergeValues(const DebugLocEntry &Next) {
if (Begin == Next.Begin) {
DIExpression Expr = cast_or_null<MDExpression>(Values[0].Expression);
DIVariable Var = cast_or_null<MDLocalVariable>(Values[0].Variable);
DIExpression NextExpr =
cast_or_null<MDExpression>(Next.Values[0].Expression);
DIVariable NextVar = cast_or_null<MDLocalVariable>(Next.Values[0].Variable);
if (Var == NextVar && Expr->isBitPiece() && NextExpr->isBitPiece()) {
if (Expr->isBitPiece() && NextExpr->isBitPiece()) {
addValues(Next.Values);
End = Next.End;
return true;
@ -144,12 +137,12 @@ public:
// Remove any duplicate entries by dropping all but the first.
void sortUniqueValues() {
std::sort(Values.begin(), Values.end());
Values.erase(std::unique(Values.begin(), Values.end(),
[](const Value &A, const Value &B) {
return A.getVariable() == B.getVariable() &&
A.getExpression() == B.getExpression();
}),
Values.end());
Values.erase(
std::unique(
Values.begin(), Values.end(), [](const Value &A, const Value &B) {
return A.getExpression() == B.getExpression();
}),
Values.end());
}
/// \brief Lower this entry into a DWARF expression.
@ -170,9 +163,6 @@ inline bool operator==(const DebugLocEntry::Value &A,
if (A.Expression != B.Expression)
return false;
if (A.Variable != B.Variable)
return false;
switch (A.EntryKind) {
case DebugLocEntry::Value::E_Location:
return A.Loc == B.Loc;

View File

@ -734,7 +734,6 @@ void DwarfDebug::collectVariableInfoFromMMITable(
// Get .debug_loc entry for the instruction range starting at MI.
static DebugLocEntry::Value getDebugLocValue(const MachineInstr *MI) {
const MDNode *Expr = MI->getDebugExpression();
const MDNode *Var = MI->getDebugVariable();
assert(MI->getNumOperands() == 4);
if (MI->getOperand(0).isReg()) {
@ -745,14 +744,14 @@ static DebugLocEntry::Value getDebugLocValue(const MachineInstr *MI) {
MLoc.set(MI->getOperand(0).getReg());
else
MLoc.set(MI->getOperand(0).getReg(), MI->getOperand(1).getImm());
return DebugLocEntry::Value(Var, Expr, MLoc);
return DebugLocEntry::Value(Expr, MLoc);
}
if (MI->getOperand(0).isImm())
return DebugLocEntry::Value(Var, Expr, MI->getOperand(0).getImm());
return DebugLocEntry::Value(Expr, MI->getOperand(0).getImm());
if (MI->getOperand(0).isFPImm())
return DebugLocEntry::Value(Var, Expr, MI->getOperand(0).getFPImm());
return DebugLocEntry::Value(Expr, MI->getOperand(0).getFPImm());
if (MI->getOperand(0).isCImm())
return DebugLocEntry::Value(Var, Expr, MI->getOperand(0).getCImm());
return DebugLocEntry::Value(Expr, MI->getOperand(0).getCImm());
llvm_unreachable("Unexpected 4-operand DBG_VALUE instruction!");
}
@ -865,7 +864,6 @@ DwarfDebug::buildLocationList(SmallVectorImpl<DebugLocEntry> &DebugLoc,
DEBUG({
dbgs() << CurEntry->getValues().size() << " Values:\n";
for (auto Value : CurEntry->getValues()) {
Value.getVariable()->dump();
Value.getExpression()->dump();
}
dbgs() << "-----\n";