diff options
author | Dan Gohman <sunfish@google.com> | 2014-02-12 18:07:57 -0800 |
---|---|---|
committer | Dan Gohman <sunfish@google.com> | 2014-02-12 18:16:37 -0800 |
commit | 625038688e352404d1a5bffc591c0bf6835b5321 (patch) | |
tree | 9a3d057efe98777fd77a0fa605950d17388223c6 | |
parent | 01a17832dee4fbbf06c9f18f5e70a6714594e847 (diff) |
Use the LLVM pass-manager infrastructure for DataLayout.
-rw-r--r-- | lib/Target/JSBackend/JSBackend.cpp | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/lib/Target/JSBackend/JSBackend.cpp b/lib/Target/JSBackend/JSBackend.cpp index 8255518293..b6895f14b0 100644 --- a/lib/Target/JSBackend/JSBackend.cpp +++ b/lib/Target/JSBackend/JSBackend.cpp @@ -117,6 +117,7 @@ namespace { bool UsesSIMD; int InvokeState; // cycles between 0, 1 after preInvoke, 2 after call, 0 again after postInvoke. hackish, no argument there. + DataLayout *DL; #include "CallHandlers.h" @@ -126,7 +127,13 @@ namespace { virtual const char *getPassName() const { return "JavaScript backend"; } - bool runOnModule(Module &M); + virtual bool runOnModule(Module &M); + + virtual void getAnalysisUsage(AnalysisUsage &AU) const { + AU.setPreservesAll(); + AU.addRequired<DataLayout>(); + ModulePass::getAnalysisUsage(AU); + } void printProgram(const std::string& fname, const std::string& modName ); void printModule(const std::string& fname, const std::string& modName ); @@ -1916,8 +1923,7 @@ void JSWriter::parseConstant(const std::string& name, const Constant* CV, bool c assert(false && "Unlowered ConstantPointerNull"); } else if (isa<ConstantAggregateZero>(CV)) { if (calculate) { - DataLayout DL(TheModule); - unsigned Bytes = DL.getTypeStoreSize(CV->getType()); + unsigned Bytes = DL->getTypeStoreSize(CV->getType()); // FIXME: assume full 64-bit alignment for now Bytes = memAlign(Bytes); HeapData *GlobalData = allocateAddress(name); @@ -1955,8 +1961,7 @@ void JSWriter::parseConstant(const std::string& name, const Constant* CV, bool c } } else if (calculate) { HeapData *GlobalData = allocateAddress(name); - DataLayout DL(TheModule); - unsigned Bytes = DL.getTypeStoreSize(CV->getType()); + unsigned Bytes = DL->getTypeStoreSize(CV->getType()); for (unsigned i = 0; i < Bytes; ++i) { GlobalData->push_back(0); } @@ -1972,8 +1977,7 @@ void JSWriter::parseConstant(const std::string& name, const Constant* CV, bool c for (unsigned i = 0; i < Num; i++) { const Constant* C = CS->getOperand(i); if (isa<ConstantAggregateZero>(C)) { - DataLayout DL(TheModule); - unsigned Bytes = DL.getTypeStoreSize(C->getType()); + unsigned Bytes = DL->getTypeStoreSize(C->getType()); Offset += Bytes; // zeros, so just skip } else if (const ConstantExpr *CE = dyn_cast<ConstantExpr>(C)) { Value *V = CE->getOperand(0); @@ -2115,6 +2119,7 @@ void JSWriter::printModule(const std::string& fname, bool JSWriter::runOnModule(Module &M) { TheModule = &M; + DL = &getAnalysis<DataLayout>(); setupCallHandlers(); |