forked from OSchip/llvm-project
RewriteStatepointsForGC: Move details into anonymous namespaces. NFC.
While there reduce the number of duplicated std::map lookups. llvm-svn: 230012
This commit is contained in:
parent
a0ef4f36c8
commit
6f66545ae6
|
@ -55,6 +55,7 @@ static cl::opt<bool> PrintLiveSetSize("spp-print-liveset-size",
|
||||||
static cl::opt<bool> PrintBasePointers("spp-print-base-pointers",
|
static cl::opt<bool> PrintBasePointers("spp-print-base-pointers",
|
||||||
cl::Hidden, cl::init(false));
|
cl::Hidden, cl::init(false));
|
||||||
|
|
||||||
|
namespace {
|
||||||
struct RewriteStatepointsForGC : public FunctionPass {
|
struct RewriteStatepointsForGC : public FunctionPass {
|
||||||
static char ID; // Pass identification, replacement for typeid
|
static char ID; // Pass identification, replacement for typeid
|
||||||
|
|
||||||
|
@ -69,6 +70,7 @@ struct RewriteStatepointsForGC : public FunctionPass {
|
||||||
AU.addRequired<DominatorTreeWrapperPass>();
|
AU.addRequired<DominatorTreeWrapperPass>();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
} // namespace
|
||||||
|
|
||||||
char RewriteStatepointsForGC::ID = 0;
|
char RewriteStatepointsForGC::ID = 0;
|
||||||
|
|
||||||
|
@ -94,9 +96,7 @@ namespace {
|
||||||
// base relation will remain. Internally, we add a mixture of the two
|
// base relation will remain. Internally, we add a mixture of the two
|
||||||
// types, then update all the second type to the first type
|
// types, then update all the second type to the first type
|
||||||
typedef std::map<Value *, Value *> DefiningValueMapTy;
|
typedef std::map<Value *, Value *> DefiningValueMapTy;
|
||||||
}
|
|
||||||
|
|
||||||
namespace {
|
|
||||||
struct PartiallyConstructedSafepointRecord {
|
struct PartiallyConstructedSafepointRecord {
|
||||||
/// The set of values known to be live accross this safepoint
|
/// The set of values known to be live accross this safepoint
|
||||||
std::set<llvm::Value *> liveset;
|
std::set<llvm::Value *> liveset;
|
||||||
|
@ -503,26 +503,28 @@ static Value *findBaseDefiningValue(Value *I) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns the base defining value for this value.
|
/// Returns the base defining value for this value.
|
||||||
Value *findBaseDefiningValueCached(Value *I, DefiningValueMapTy &cache) {
|
static Value *findBaseDefiningValueCached(Value *I, DefiningValueMapTy &cache) {
|
||||||
if (cache.find(I) == cache.end()) {
|
Value *&Cached = cache[I];
|
||||||
cache[I] = findBaseDefiningValue(I);
|
if (!Cached) {
|
||||||
|
Cached = findBaseDefiningValue(I);
|
||||||
}
|
}
|
||||||
assert(cache.find(I) != cache.end());
|
assert(cache[I] != nullptr);
|
||||||
|
|
||||||
if (TraceLSP) {
|
if (TraceLSP) {
|
||||||
errs() << "fBDV-cached: " << I->getName() << " -> " << cache[I]->getName()
|
errs() << "fBDV-cached: " << I->getName() << " -> " << Cached->getName()
|
||||||
<< "\n";
|
<< "\n";
|
||||||
}
|
}
|
||||||
return cache[I];
|
return Cached;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Return a base pointer for this value if known. Otherwise, return it's
|
/// Return a base pointer for this value if known. Otherwise, return it's
|
||||||
/// base defining value.
|
/// base defining value.
|
||||||
static Value *findBaseOrBDV(Value *I, DefiningValueMapTy &cache) {
|
static Value *findBaseOrBDV(Value *I, DefiningValueMapTy &cache) {
|
||||||
Value *def = findBaseDefiningValueCached(I, cache);
|
Value *def = findBaseDefiningValueCached(I, cache);
|
||||||
if (cache.count(def)) {
|
auto Found = cache.find(def);
|
||||||
|
if (Found != cache.end()) {
|
||||||
// Either a base-of relation, or a self reference. Caller must check.
|
// Either a base-of relation, or a self reference. Caller must check.
|
||||||
return cache[def];
|
return Found->second;
|
||||||
}
|
}
|
||||||
// Only a BDV available
|
// Only a BDV available
|
||||||
return def;
|
return def;
|
||||||
|
|
Loading…
Reference in New Issue