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;
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);
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;
// 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.
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;
// 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()) {
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!");
}
DEBUG({
dbgs() << CurEntry->getValues().size() << " Values:\n";
for (auto Value : CurEntry->getValues()) {
- Value.getVariable()->dump();
Value.getExpression()->dump();
}
dbgs() << "-----\n";