Skip to content

Commit

Permalink
More code cleanup [NFC]
Browse files Browse the repository at this point in the history
Minor naming, one potentially unsafe cast



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@233359 91177308-0d34-0410-b5e6-96231b3b80d8
  • Loading branch information
preames committed Mar 27, 2015
1 parent c3bbff9 commit de15c8e
Showing 1 changed file with 13 additions and 12 deletions.
25 changes: 13 additions & 12 deletions lib/Transforms/Scalar/RewriteStatepointsForGC.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -432,41 +432,42 @@ static Value *findBaseDefiningValue(Value *I) {
}

/// Returns the base defining value for this value.
static Value *findBaseDefiningValueCached(Value *I, DefiningValueMapTy &cache) {
Value *&Cached = cache[I];
static Value *findBaseDefiningValueCached(Value *I, DefiningValueMapTy &Cache) {
Value *&Cached = Cache[I];
if (!Cached) {
Cached = findBaseDefiningValue(I);
}
assert(cache[I] != nullptr);
assert(Cache[I] != nullptr);

if (TraceLSP) {
errs() << "fBDV-cached: " << I->getName() << " -> " << Cached->getName()
dbgs() << "fBDV-cached: " << I->getName() << " -> " << Cached->getName()
<< "\n";
}
return Cached;
}

/// Return a base pointer for this value if known. Otherwise, return it's
/// base defining value.
static Value *findBaseOrBDV(Value *I, DefiningValueMapTy &cache) {
Value *def = findBaseDefiningValueCached(I, cache);
auto Found = cache.find(def);
if (Found != cache.end()) {
static Value *findBaseOrBDV(Value *I, DefiningValueMapTy &Cache) {
Value *Def = findBaseDefiningValueCached(I, Cache);
auto Found = Cache.find(Def);
if (Found != Cache.end()) {
// Either a base-of relation, or a self reference. Caller must check.
return Found->second;
}
// Only a BDV available
return def;
return Def;
}

/// Given the result of a call to findBaseDefiningValue, or findBaseOrBDV,
/// is it known to be a base pointer? Or do we need to continue searching.
static bool isKnownBaseResult(Value *v) {
if (!isa<PHINode>(v) && !isa<SelectInst>(v)) {
static bool isKnownBaseResult(Value *V) {
if (!isa<PHINode>(V) && !isa<SelectInst>(V)) {
// no recursion possible
return true;
}
if (cast<Instruction>(v)->getMetadata("is_base_value")) {
if (isa<Instruction>(V) &&
cast<Instruction>(V)->getMetadata("is_base_value")) {
// This is a previously inserted base phi or select. We know
// that this is a base value.
return true;
Expand Down

0 comments on commit de15c8e

Please sign in to comment.