summaryrefslogtreecommitdiffstats
path: root/llvm/lib/CodeGen/AsmPrinter/DebugLocEntry.h
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/lib/CodeGen/AsmPrinter/DebugLocEntry.h')
-rw-r--r--llvm/lib/CodeGen/AsmPrinter/DebugLocEntry.h18
1 files changed, 17 insertions, 1 deletions
diff --git a/llvm/lib/CodeGen/AsmPrinter/DebugLocEntry.h b/llvm/lib/CodeGen/AsmPrinter/DebugLocEntry.h
index 97f48aac3bb..41735fca376 100644
--- a/llvm/lib/CodeGen/AsmPrinter/DebugLocEntry.h
+++ b/llvm/lib/CodeGen/AsmPrinter/DebugLocEntry.h
@@ -76,6 +76,13 @@ public:
llvm_unreachable("unhandled EntryKind");
}
+ // Compare two pieces based on their offset.
+ bool operator<(const Value &other) const {
+ DIVariable Var(Variable);
+ DIVariable OtherVar(other.Variable);
+ return Var.getPieceOffset() < OtherVar.getPieceOffset();
+ }
+
bool isLocation() const { return EntryKind == E_Location; }
bool isInt() const { return EntryKind == E_Integer; }
bool isConstantFP() const { return EntryKind == E_ConstantFP; }
@@ -87,7 +94,7 @@ public:
const MDNode *getVariable() const { return Variable; }
};
private:
- /// A list of locations/constants belonging to this entry.
+ /// A list of locations/constants belonging to this entry, sorted by offset.
SmallVector<Value, 1> Values;
public:
@@ -108,6 +115,7 @@ public:
if (Var.getName() == NextVar.getName() &&
Var.isVariablePiece() && NextVar.isVariablePiece()) {
Values.append(Next.Values.begin(), Next.Values.end());
+ sortUniqueValues();
End = Next.End;
return true;
}
@@ -135,6 +143,14 @@ public:
assert(DIVariable(Val.Variable).isVariablePiece() &&
"multi-value DebugLocEntries must be pieces");
Values.push_back(Val);
+ sortUniqueValues();
+ }
+
+ // Sort the pieces by offset.
+ // 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()), Values.end());
}
};
OpenPOWER on IntegriCloud