mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-09-24 23:28:41 +00:00
[LoopAccesses] Create the analysis pass
This is a function pass that runs the analysis on demand. The analysis can be initiated by querying the loop access info via LAA::getInfo. It either returns the cached info or runs the analysis. Symbolic stride information continues to reside outside of this analysis pass. We may move it inside later but it's not a priority for me right now. The idea is that Loop Distribution won't support run-time stride checking at least initially. This means that when querying the analysis, symbolic stride information can be provided optionally. Whether stride information is used can invalidate the cache entry and rerun the analysis. Note that if the loop does not have any symbolic stride, the entry should be preserved across Loop Distribution and LV. Since currently the only user of the pass is LV, I just check that the symbolic stride information didn't change when using a cached result. On the LV side, LoopVectorizationLegality requests the info object corresponding to the loop from the analysis pass. A large chunk of the diff is due to LAI becoming a pointer from a reference. A test will be added as part of the -analyze patch. Also tested that with AVX, we generate identical assembly output for the testsuite (including the external testsuite) before and after. This is part of the patchset that converts LoopAccessAnalysis into an actual analysis pass. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@229626 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -22,6 +22,7 @@
|
||||
#include "llvm/Analysis/AliasSetTracker.h"
|
||||
#include "llvm/Analysis/ScalarEvolutionExpressions.h"
|
||||
#include "llvm/IR/ValueHandle.h"
|
||||
#include "llvm/Pass.h"
|
||||
#include "llvm/Support/raw_ostream.h"
|
||||
|
||||
namespace llvm {
|
||||
@@ -132,12 +133,7 @@ public:
|
||||
|
||||
LoopAccessInfo(Loop *L, ScalarEvolution *SE, const DataLayout *DL,
|
||||
const TargetLibraryInfo *TLI, AliasAnalysis *AA,
|
||||
DominatorTree *DT) :
|
||||
TheLoop(L), SE(SE), DL(DL), TLI(TLI), AA(AA), DT(DT), NumLoads(0),
|
||||
NumStores(0), MaxSafeDepDistBytes(-1U), CanVecMem(false) {}
|
||||
|
||||
/// \brief Analyze the loop. Replaces symbolic strides using Strides.
|
||||
void analyzeLoop(ValueToValueMap &Strides);
|
||||
DominatorTree *DT, ValueToValueMap &Strides);
|
||||
|
||||
/// Return true we can analyze the memory accesses in the loop and there are
|
||||
/// no memory dependence cycles.
|
||||
@@ -168,7 +164,15 @@ public:
|
||||
/// couldn't analyze the loop.
|
||||
Optional<VectorizationReport> &getReport() { return Report; }
|
||||
|
||||
/// \brief Used to ensure that if the analysis was run with speculating the
|
||||
/// value of symbolic strides, the client queries it with the same assumption.
|
||||
/// Only used in DEBUG build but we don't want NDEBUG-depedent ABI.
|
||||
unsigned NumSymbolicStrides;
|
||||
|
||||
private:
|
||||
/// \brief Analyze the loop. Substitute symbolic strides using Strides.
|
||||
void analyzeLoop(ValueToValueMap &Strides);
|
||||
|
||||
void emitAnalysis(VectorizationReport &Message);
|
||||
|
||||
/// We need to check that all of the pointers in this list are disjoint
|
||||
@@ -206,6 +210,49 @@ const SCEV *replaceSymbolicStrideSCEV(ScalarEvolution *SE,
|
||||
ValueToValueMap &PtrToStride,
|
||||
Value *Ptr, Value *OrigPtr = nullptr);
|
||||
|
||||
/// \brief This analysis provides dependence information for the memory accesses
|
||||
/// of a loop.
|
||||
///
|
||||
/// It runs the analysis for a loop on demand. This can be initiated by
|
||||
/// querying the loop access info via LAA::getInfo. getInfo return a
|
||||
/// LoopAccessInfo object. See this class for the specifics of what information
|
||||
/// is provided.
|
||||
class LoopAccessAnalysis : public FunctionPass {
|
||||
public:
|
||||
static char ID;
|
||||
|
||||
LoopAccessAnalysis() : FunctionPass(ID) {
|
||||
initializeLoopAccessAnalysisPass(*PassRegistry::getPassRegistry());
|
||||
}
|
||||
|
||||
bool runOnFunction(Function &F) override;
|
||||
|
||||
void getAnalysisUsage(AnalysisUsage &AU) const override;
|
||||
|
||||
/// \brief Query the result of the loop access information for the loop \p L.
|
||||
///
|
||||
/// If the client speculates (and then issues run-time checks) for the values
|
||||
/// of symbolic strides, \p Strides provides the mapping (see
|
||||
/// replaceSymbolicStrideSCEV). If there is no cached result available run
|
||||
/// the analysis.
|
||||
LoopAccessInfo &getInfo(Loop *L, ValueToValueMap &Strides);
|
||||
|
||||
void releaseMemory() override {
|
||||
// Invalidate the cache when the pass is freed.
|
||||
LoopAccessInfoMap.clear();
|
||||
}
|
||||
|
||||
private:
|
||||
/// \brief The cache.
|
||||
DenseMap<Loop *, std::unique_ptr<LoopAccessInfo>> LoopAccessInfoMap;
|
||||
|
||||
// The used analysis passes.
|
||||
ScalarEvolution *SE;
|
||||
const DataLayout *DL;
|
||||
const TargetLibraryInfo *TLI;
|
||||
AliasAnalysis *AA;
|
||||
DominatorTree *DT;
|
||||
};
|
||||
} // End llvm namespace
|
||||
|
||||
#endif
|
||||
|
Reference in New Issue
Block a user