mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-23 11:13:28 +01:00
Instead of keeping two Value*->id# mappings, keep one Value->Value mapping and
one Value set. This is faster because we only need to use the set when there isn't already an entry in the map. No functionality change! llvm-svn: 126076
This commit is contained in:
parent
568548ce13
commit
cd05f2a659
@ -156,7 +156,7 @@ class FunctionComparator {
|
|||||||
public:
|
public:
|
||||||
FunctionComparator(const TargetData *TD, const Function *F1,
|
FunctionComparator(const TargetData *TD, const Function *F1,
|
||||||
const Function *F2)
|
const Function *F2)
|
||||||
: F1(F1), F2(F2), TD(TD), IDMap1Count(0), IDMap2Count(0) {}
|
: F1(F1), F2(F2), TD(TD) {}
|
||||||
|
|
||||||
/// Test whether the two functions have equivalent behaviour.
|
/// Test whether the two functions have equivalent behaviour.
|
||||||
bool compare();
|
bool compare();
|
||||||
@ -191,9 +191,8 @@ private:
|
|||||||
|
|
||||||
const TargetData *TD;
|
const TargetData *TD;
|
||||||
|
|
||||||
typedef DenseMap<const Value *, unsigned long> IDMap;
|
DenseMap<const Value *, const Value *> id_map;
|
||||||
IDMap Map1, Map2;
|
DenseSet<const Value *> seen_values;
|
||||||
unsigned long IDMap1Count, IDMap2Count;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -397,15 +396,18 @@ bool FunctionComparator::enumerate(const Value *V1, const Value *V2) {
|
|||||||
if (isa<InlineAsm>(V1) || isa<InlineAsm>(V2))
|
if (isa<InlineAsm>(V1) || isa<InlineAsm>(V2))
|
||||||
return V1 == V2;
|
return V1 == V2;
|
||||||
|
|
||||||
unsigned long &ID1 = Map1[V1];
|
// Check that V1 maps to V2. If we find a value that V1 maps to then we simply
|
||||||
if (!ID1)
|
// check whether it's equal to V2. When there is no mapping then we need to
|
||||||
ID1 = ++IDMap1Count;
|
// ensure that V2 isn't already equivalent to something else. For this
|
||||||
|
// purpose, we track the V2 values in a set.
|
||||||
|
|
||||||
unsigned long &ID2 = Map2[V2];
|
const Value *&map_elem = id_map[V1];
|
||||||
if (!ID2)
|
if (map_elem)
|
||||||
ID2 = ++IDMap2Count;
|
return map_elem == V2;
|
||||||
|
if (!seen_values.insert(V2).second)
|
||||||
return ID1 == ID2;
|
return false;
|
||||||
|
map_elem = V2;
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Test whether two basic blocks have equivalent behaviour.
|
// Test whether two basic blocks have equivalent behaviour.
|
||||||
|
Loading…
Reference in New Issue
Block a user