summaryrefslogtreecommitdiffstats
path: root/llvm/lib/CodeGen/AsmPrinter/DebugLocEntry.h
diff options
context:
space:
mode:
authorAdrian Prantl <aprantl@apple.com>2014-08-11 21:05:55 +0000
committerAdrian Prantl <aprantl@apple.com>2014-08-11 21:05:55 +0000
commit293dd93f95c1e6c9965a10e5787dc31778bc31c7 (patch)
tree4ee462a0d9feace2f8f0c151ed67a2e9e869c46a /llvm/lib/CodeGen/AsmPrinter/DebugLocEntry.h
parente09ee3faaf3d74af842133b8e00a9ea3ff0edff7 (diff)
downloadbcm5719-llvm-293dd93f95c1e6c9965a10e5787dc31778bc31c7.tar.gz
bcm5719-llvm-293dd93f95c1e6c9965a10e5787dc31778bc31c7.zip
Debug Info: Move the sorting and uniqueing of pieces from emitLocPieces()
into buildLocationList(). By keeping the list of Values sorted, DebugLocEntry::Merge can also merge multi-piece entries. llvm-svn: 215384
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