/// different types can be represented by this single DSNode. This vector is
/// kept sorted.
///
- typedef std::pair<const Type *, unsigned> TypeRec;
+ struct TypeRec {
+ const Type *Ty;
+ unsigned Offset;
+
+ TypeRec() : Ty(0), Offset(0) {}
+ TypeRec(const Type *T, unsigned O) : Ty(T), Offset(O) {}
+
+ bool operator<(const TypeRec &TR) const {
+ // Sort first by offset!
+ return Offset < TR.Offset || (Offset == TR.Offset && Ty < TR.Ty);
+ }
+ bool operator==(const TypeRec &TR) const {
+ return Ty == TR.Ty && Offset == TR.Offset;
+ }
+ bool operator!=(const TypeRec &TR) const { return !operator==(TR); }
+ };
+
std::vector<TypeRec> TypeEntries;
/// Globals - The list of global values that are merged into this node.
/// different types can be represented by this single DSNode. This vector is
/// kept sorted.
///
- typedef std::pair<const Type *, unsigned> TypeRec;
+ struct TypeRec {
+ const Type *Ty;
+ unsigned Offset;
+
+ TypeRec() : Ty(0), Offset(0) {}
+ TypeRec(const Type *T, unsigned O) : Ty(T), Offset(O) {}
+
+ bool operator<(const TypeRec &TR) const {
+ // Sort first by offset!
+ return Offset < TR.Offset || (Offset == TR.Offset && Ty < TR.Ty);
+ }
+ bool operator==(const TypeRec &TR) const {
+ return Ty == TR.Ty && Offset == TR.Offset;
+ }
+ bool operator!=(const TypeRec &TR) const { return !operator==(TR); }
+ };
+
std::vector<TypeRec> TypeEntries;
/// Globals - The list of global values that are merged into this node.
}
}
- TypeEntries.push_back(std::make_pair(T, 0));
+ TypeEntries.push_back(TypeRec(T, 0));
}
// DSNode copy constructor... do not copy over the referrers list!
// If this merging into node has more than just void nodes in it, merge!
assert(!N->TypeEntries.empty() && "TypeEntries is empty for a node?");
- if (N->TypeEntries.size() != 1 || N->TypeEntries[0].first != Type::VoidTy) {
+ if (N->TypeEntries.size() != 1 || N->TypeEntries[0].Ty != Type::VoidTy) {
// If the current node just has a Void entry in it, remove it.
- if (TypeEntries.size() == 1 && TypeEntries[0].first == Type::VoidTy)
+ if (TypeEntries.size() == 1 && TypeEntries[0].Ty == Type::VoidTy)
TypeEntries.clear();
// Adjust all of the type entries we are merging in by the offset... and add
if (NOffset != 0) { // This case is common enough to optimize for
// Offset all of the TypeEntries in N with their new offset
for (unsigned i = 0, e = N->TypeEntries.size(); i != e; ++i)
- N->TypeEntries[i].second += NOffset;
+ N->TypeEntries[i].Offset += NOffset;
}
MergeSortedVectors(TypeEntries, N->TypeEntries);
DSInfo.insert(std::make_pair(I, new DSGraph(*I)));
return false;
}
-
Module *M = G && &G->getFunction() ? G->getFunction().getParent() : 0;
for (unsigned i = 0, e = N->getTypeEntries().size(); i != e; ++i) {
- WriteTypeSymbolic(OS, N->getTypeEntries()[i].first, M);
- if (N->getTypeEntries()[i].second)
- OS << "@" << N->getTypeEntries()[i].second;
+ WriteTypeSymbolic(OS, N->getTypeEntries()[i].Ty, M);
+ if (N->getTypeEntries()[i].Offset)
+ OS << "@" << N->getTypeEntries()[i].Offset;
OS << "\n";
}