#include "llvm/iOther.h"
#include "llvm/Support/InstVisitor.h"
#include "llvm/Support/CFG.h"
-#include "Support/TarjanSCCIterator.h"
+#include "Support/SCCIterator.h"
#include "Support/Statistic.h"
#include "Support/STLExtras.h"
#include "Support/hash_map"
/// not copied over from one table to another since it is no longer useful.
///--------------------------------------------------------------------------
-struct ModRefTable
-{
+struct ModRefTable {
typedef hash_map<Instruction*, ModRefInfo> ModRefMap;
typedef ModRefMap::const_iterator const_map_iterator;
typedef ModRefMap:: iterator map_iterator;
// class MemoryDepAnalysis: A dep. graph for load/store/call instructions
//----------------------------------------------------------------------------
-/// Basic dependence gathering algorithm, using TarjanSCCIterator on CFG:
+
+/// getAnalysisUsage - This does not modify anything. It uses the Top-Down DS
+/// Graph and IPModRef.
+///
+void MemoryDepAnalysis::getAnalysisUsage(AnalysisUsage &AU) const {
+ AU.setPreservesAll();
+ AU.addRequired<TDDataStructures>();
+ AU.addRequired<IPModRef>();
+}
+
+
+/// Basic dependence gathering algorithm, using scc_iterator on CFG:
///
/// for every SCC S in the CFG in PostOrder on the SCC DAG
/// {
/// }
///
///
-void MemoryDepAnalysis::ProcessSCC(SCC<Function*>& S,
- ModRefTable& ModRefAfter) {
+void MemoryDepAnalysis::ProcessSCC(std::vector<BasicBlock*> &S,
+ ModRefTable& ModRefAfter, bool hasLoop) {
ModRefTable ModRefCurrent;
ModRefTable::ModRefMap& mapCurrent = ModRefCurrent.modRefMap;
ModRefTable::ModRefMap& mapAfter = ModRefAfter.modRefMap;
- bool hasLoop = S.HasLoop();
-
// Builder class fills out a ModRefTable one instruction at a time.
// To use it, we just invoke it's visit function for each basic block:
//
// : Add I to ModRefCurrent.users if it uses any node
//
ModRefInfoBuilder builder(*funcGraph, *funcModRef, ModRefCurrent);
- for (SCC<Function*>::iterator BI=S.begin(), BE=S.end(); BI != BE; ++BI)
- // Note: BBs in the SCC<> created by TarjanSCCIterator are in postorder.
+ for (std::vector<BasicBlock*>::iterator BI = S.begin(), BE = S.end();
+ BI != BE; ++BI)
+ // Note: BBs in the SCC<> created by scc_iterator are in postorder.
for (BasicBlock::reverse_iterator II=(*BI)->rbegin(), IE=(*BI)->rend();
II != IE; ++II)
builder.visit(*II);
ModRefTable ModRefAfter;
- SCC<Function*>* nextSCC;
- for (TarjanSCC_iterator<Function*> I = tarj_begin(&F), E = tarj_end(&F);
- I != E; ++I)
- ProcessSCC(**I, ModRefAfter);
+ for (scc_iterator<Function*> I = scc_begin(&F), E = scc_end(&F); I != E; ++I)
+ ProcessSCC(*I, ModRefAfter, I.hasLoop());
return true;
}