1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-22 02:33:06 +01:00

[NFC] MemoryDependenceAnalysis cleanup.

1. Removed redundant includes,
2. Removed never defined and used `releaseMemory()`.
3. Fixed member functions names first letter case.
4. Renamed duplicate (in nested struct `NonLocalPointerInfo`) name
   `NonLocalDeps` to `NonLocalDepsMap`.

Reviewed By: nikic

Differential Revision: https://reviews.llvm.org/D102358
This commit is contained in:
Daniil Fukalov 2021-05-12 22:43:16 +03:00
parent 4f81b668e8
commit 47fca931a0
3 changed files with 21 additions and 33 deletions

View File

@ -20,17 +20,9 @@
#include "llvm/ADT/PointerSumType.h"
#include "llvm/ADT/SmallPtrSet.h"
#include "llvm/Analysis/MemoryLocation.h"
#include "llvm/IR/BasicBlock.h"
#include "llvm/IR/Metadata.h"
#include "llvm/IR/PassManager.h"
#include "llvm/IR/PredIteratorCache.h"
#include "llvm/IR/ValueHandle.h"
#include "llvm/Pass.h"
#include "llvm/Support/ErrorHandling.h"
#include <cassert>
#include <cstdint>
#include <utility>
#include <vector>
namespace llvm {
@ -38,13 +30,8 @@ class AAResults;
class AssumptionCache;
class BatchAAResults;
class DominatorTree;
class Function;
class Instruction;
class LoadInst;
class PHITransAddr;
class TargetLibraryInfo;
class PhiValues;
class Value;
/// A memory dependence query can return one of three different answers.
class MemDepResult {
@ -344,7 +331,7 @@ private:
// A map from instructions to their non-local dependencies.
using NonLocalDepMapType = DenseMap<Instruction *, PerInstNLInfo>;
NonLocalDepMapType NonLocalDeps;
NonLocalDepMapType NonLocalDepsMap;
// A reverse mapping from dependencies to the dependees. This is
// used when removing instructions to keep the cache coherent.
@ -501,13 +488,13 @@ private:
DenseMap<BasicBlock *, Value *> &Visited,
bool SkipFirstBlock = false,
bool IsIncomplete = false);
MemDepResult GetNonLocalInfoForBlock(Instruction *QueryInst,
MemDepResult getNonLocalInfoForBlock(Instruction *QueryInst,
const MemoryLocation &Loc, bool isLoad,
BasicBlock *BB, NonLocalDepInfo *Cache,
unsigned NumSortedEntries,
BatchAAResults &BatchAA);
void RemoveCachedNonLocalPointerDependencies(ValueIsLoadPair P);
void removeCachedNonLocalPointerDependencies(ValueIsLoadPair P);
void verifyRemoved(Instruction *Inst) const;
};

View File

@ -21,7 +21,6 @@
#include "llvm/ADT/SetVector.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/Analysis/InstructionPrecedenceTracking.h"
#include "llvm/Analysis/MemoryDependenceAnalysis.h"
#include "llvm/IR/Dominators.h"
#include "llvm/IR/InstrTypes.h"
#include "llvm/IR/PassManager.h"
@ -47,8 +46,11 @@ class FunctionPass;
class IntrinsicInst;
class LoadInst;
class LoopInfo;
class MemDepResult;
class MemoryDependenceResults;
class MemorySSA;
class MemorySSAUpdater;
class NonLocalDepResult;
class OptimizationRemarkEmitter;
class PHINode;
class TargetLibraryInfo;

View File

@ -717,7 +717,7 @@ MemoryDependenceResults::getNonLocalCallDependency(CallBase *QueryCall) {
assert(getDependency(QueryCall).isNonLocal() &&
"getNonLocalCallDependency should only be used on calls with "
"non-local deps!");
PerInstNLInfo &CacheP = NonLocalDeps[QueryCall];
PerInstNLInfo &CacheP = NonLocalDepsMap[QueryCall];
NonLocalDepInfo &Cache = CacheP.first;
// This is the set of blocks that need to be recomputed. In the cached case,
@ -902,7 +902,7 @@ void MemoryDependenceResults::getNonLocalPointerDependency(
/// info if available).
///
/// If we do a lookup, add the result to the cache.
MemDepResult MemoryDependenceResults::GetNonLocalInfoForBlock(
MemDepResult MemoryDependenceResults::getNonLocalInfoForBlock(
Instruction *QueryInst, const MemoryLocation &Loc, bool isLoad,
BasicBlock *BB, NonLocalDepInfo *Cache, unsigned NumSortedEntries,
BatchAAResults &BatchAA) {
@ -1228,9 +1228,8 @@ bool MemoryDependenceResults::getNonLocalPointerDepFromBB(
// Get the dependency info for Pointer in BB. If we have cached
// information, we will use it, otherwise we compute it.
LLVM_DEBUG(AssertSorted(*Cache, NumSortedEntries));
MemDepResult Dep = GetNonLocalInfoForBlock(QueryInst, Loc, isLoad, BB,
Cache, NumSortedEntries,
BatchAA);
MemDepResult Dep = getNonLocalInfoForBlock(
QueryInst, Loc, isLoad, BB, Cache, NumSortedEntries, BatchAA);
// If we got a Def or Clobber, add this to the list of results.
if (!Dep.isNonLocal()) {
@ -1452,7 +1451,7 @@ bool MemoryDependenceResults::getNonLocalPointerDepFromBB(
}
/// If P exists in CachedNonLocalPointerInfo or NonLocalDefsCache, remove it.
void MemoryDependenceResults::RemoveCachedNonLocalPointerDependencies(
void MemoryDependenceResults::removeCachedNonLocalPointerDependencies(
ValueIsLoadPair P) {
// Most of the time this cache is empty.
@ -1501,9 +1500,9 @@ void MemoryDependenceResults::invalidateCachedPointerInfo(Value *Ptr) {
if (!Ptr->getType()->isPointerTy())
return;
// Flush store info for the pointer.
RemoveCachedNonLocalPointerDependencies(ValueIsLoadPair(Ptr, false));
removeCachedNonLocalPointerDependencies(ValueIsLoadPair(Ptr, false));
// Flush load info for the pointer.
RemoveCachedNonLocalPointerDependencies(ValueIsLoadPair(Ptr, true));
removeCachedNonLocalPointerDependencies(ValueIsLoadPair(Ptr, true));
// Invalidate phis that use the pointer.
PV.invalidateValue(Ptr);
}
@ -1515,13 +1514,13 @@ void MemoryDependenceResults::invalidateCachedPredecessors() {
void MemoryDependenceResults::removeInstruction(Instruction *RemInst) {
// Walk through the Non-local dependencies, removing this one as the value
// for any cached queries.
NonLocalDepMapType::iterator NLDI = NonLocalDeps.find(RemInst);
if (NLDI != NonLocalDeps.end()) {
NonLocalDepMapType::iterator NLDI = NonLocalDepsMap.find(RemInst);
if (NLDI != NonLocalDepsMap.end()) {
NonLocalDepInfo &BlockMap = NLDI->second.first;
for (auto &Entry : BlockMap)
if (Instruction *Inst = Entry.getResult().getInst())
RemoveFromReverseMap(ReverseNonLocalDeps, Inst, RemInst);
NonLocalDeps.erase(NLDI);
NonLocalDepsMap.erase(NLDI);
}
// If we have a cached local dependence query for this instruction, remove it.
@ -1541,8 +1540,8 @@ void MemoryDependenceResults::removeInstruction(Instruction *RemInst) {
// If the instruction is a pointer, remove it from both the load info and the
// store info.
if (RemInst->getType()->isPointerTy()) {
RemoveCachedNonLocalPointerDependencies(ValueIsLoadPair(RemInst, false));
RemoveCachedNonLocalPointerDependencies(ValueIsLoadPair(RemInst, true));
removeCachedNonLocalPointerDependencies(ValueIsLoadPair(RemInst, false));
removeCachedNonLocalPointerDependencies(ValueIsLoadPair(RemInst, true));
} else {
// Otherwise, if the instructions is in the map directly, it must be a load.
// Remove it.
@ -1605,7 +1604,7 @@ void MemoryDependenceResults::removeInstruction(Instruction *RemInst) {
for (Instruction *I : ReverseDepIt->second) {
assert(I != RemInst && "Already removed NonLocalDep info for RemInst");
PerInstNLInfo &INLD = NonLocalDeps[I];
PerInstNLInfo &INLD = NonLocalDepsMap[I];
// The information is now dirty!
INLD.second = true;
@ -1677,7 +1676,7 @@ void MemoryDependenceResults::removeInstruction(Instruction *RemInst) {
// Invalidate phis that use the removed instruction.
PV.invalidateValue(RemInst);
assert(!NonLocalDeps.count(RemInst) && "RemInst got reinserted?");
assert(!NonLocalDepsMap.count(RemInst) && "RemInst got reinserted?");
LLVM_DEBUG(verifyRemoved(RemInst));
}
@ -1698,7 +1697,7 @@ void MemoryDependenceResults::verifyRemoved(Instruction *D) const {
assert(Entry.getResult().getInst() != D && "Inst occurs as NLPD value");
}
for (const auto &DepKV : NonLocalDeps) {
for (const auto &DepKV : NonLocalDepsMap) {
assert(DepKV.first != D && "Inst occurs in data structures");
const PerInstNLInfo &INLD = DepKV.second;
for (const auto &Entry : INLD.first)