diff options
author | Chris Lattner <sabre@nondot.org> | 2003-11-02 22:27:28 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2003-11-02 22:27:28 +0000 |
commit | 15869aa2c717c356f62c04d85b73450aaabfee16 (patch) | |
tree | 2914724bfba1432a239d96ddedd9b535276aea1c /lib/Analysis/DataStructure/Local.cpp | |
parent | dbfe36e51eff9324ad5abf7af9a852de07f04ef9 (diff) |
All DSGraphs keep a reference to the targetdata they are created with. This is
used to eliminate the hard coded, hacked in, sparc specific, global TargetData.
Changing the TargetData used to actually match the code fixes problems, and
eliminates a crash.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@9659 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Analysis/DataStructure/Local.cpp')
-rw-r--r-- | lib/Analysis/DataStructure/Local.cpp | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/lib/Analysis/DataStructure/Local.cpp b/lib/Analysis/DataStructure/Local.cpp index fcaadf3755..689373ee7d 100644 --- a/lib/Analysis/DataStructure/Local.cpp +++ b/lib/Analysis/DataStructure/Local.cpp @@ -16,8 +16,6 @@ #include "llvm/Analysis/DSGraph.h" #include "llvm/Constants.h" #include "llvm/DerivedTypes.h" -#include "llvm/Function.h" -#include "llvm/GlobalVariable.h" #include "llvm/Instructions.h" #include "llvm/Support/InstVisitor.h" #include "llvm/Target/TargetData.h" @@ -34,9 +32,6 @@ static RegisterAnalysis<LocalDataStructures> X("datastructure", "Local Data Structure Analysis"); namespace DS { - // FIXME: Do something smarter with target data! - TargetData TD("temp-td"); - // isPointerType - Return true if this type is big enough to hold a pointer. bool isPointerType(const Type *Ty) { if (isa<PointerType>(Ty)) @@ -152,7 +147,8 @@ namespace { //===----------------------------------------------------------------------===// // DSGraph constructor - Simply use the GraphBuilder to construct the local // graph. -DSGraph::DSGraph(Function &F, DSGraph *GG) : GlobalsGraph(GG) { +DSGraph::DSGraph(const TargetData &td, Function &F, DSGraph *GG) + : GlobalsGraph(GG), TD(td) { PrintAuxCalls = false; DEBUG(std::cerr << " [Loc] Calculating graph for: " << F.getName() << "\n"); @@ -311,6 +307,8 @@ void GraphBuilder::visitGetElementPtrInst(User &GEP) { return; } + const TargetData &TD = Value.getNode()->getTargetData(); + #if 0 // Handle the pointer index specially... if (GEP.getNumOperands() > 1 && @@ -531,7 +529,9 @@ void GraphBuilder::MergeConstantInitIntoNode(DSNodeHandle &NH, Constant *C) { NH.addEdgeTo(getValueDest(*C)); return; } - + + const TargetData &TD = NH.getNode()->getTargetData(); + if (ConstantArray *CA = dyn_cast<ConstantArray>(C)) { for (unsigned i = 0, e = CA->getNumOperands(); i != e; ++i) // We don't currently do any indexing for arrays... @@ -556,12 +556,14 @@ void GraphBuilder::mergeInGlobalInitializer(GlobalVariable *GV) { bool LocalDataStructures::run(Module &M) { - GlobalsGraph = new DSGraph(); + GlobalsGraph = new DSGraph(getAnalysis<TargetData>()); + + const TargetData &TD = getAnalysis<TargetData>(); // Calculate all of the graphs... for (Module::iterator I = M.begin(), E = M.end(); I != E; ++I) if (!I->isExternal()) - DSInfo.insert(std::make_pair(I, new DSGraph(*I, GlobalsGraph))); + DSInfo.insert(std::make_pair(I, new DSGraph(TD, *I, GlobalsGraph))); GraphBuilder GGB(*GlobalsGraph); |