summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Analysis/DataStructure/Local.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2003-11-02 22:27:28 +0000
committerChris Lattner <sabre@nondot.org>2003-11-02 22:27:28 +0000
commit2b9926fc8eceb304bafe0e77a8876579d392f7bb (patch)
treef17c6c36c737dfeaca0e91a6d553fa3a1a2077d3 /llvm/lib/Analysis/DataStructure/Local.cpp
parent53e8fab411da7e738b4c8f069d14168c4e8c4ff6 (diff)
downloadbcm5719-llvm-2b9926fc8eceb304bafe0e77a8876579d392f7bb.tar.gz
bcm5719-llvm-2b9926fc8eceb304bafe0e77a8876579d392f7bb.zip
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. llvm-svn: 9659
Diffstat (limited to 'llvm/lib/Analysis/DataStructure/Local.cpp')
-rw-r--r--llvm/lib/Analysis/DataStructure/Local.cpp20
1 files changed, 11 insertions, 9 deletions
diff --git a/llvm/lib/Analysis/DataStructure/Local.cpp b/llvm/lib/Analysis/DataStructure/Local.cpp
index fcaadf3755f..689373ee7d2 100644
--- a/llvm/lib/Analysis/DataStructure/Local.cpp
+++ b/llvm/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);
OpenPOWER on IntegriCloud