diff options
author | Rafael Espindola <rafael.espindola@gmail.com> | 2014-09-10 21:27:43 +0000 |
---|---|---|
committer | Rafael Espindola <rafael.espindola@gmail.com> | 2014-09-10 21:27:43 +0000 |
commit | c435adcde045fc739ea18e798ceb32b552fd6827 (patch) | |
tree | c6566d0cfd3af5e1403be4682c25b036fd5a0ff4 /llvm/lib/IR/DataLayout.cpp | |
parent | 4de669f5b3de09096b55cf1e70ea0b1ea9ad421b (diff) | |
download | bcm5719-llvm-c435adcde045fc739ea18e798ceb32b552fd6827.tar.gz bcm5719-llvm-c435adcde045fc739ea18e798ceb32b552fd6827.zip |
Add doInitialization/doFinalization to DataLayoutPass.
With this a DataLayoutPass can be reused for multiple modules.
Once we have doInitialization/doFinalization, it doesn't seem necessary to pass
a Module to the constructor.
Overall this change seems in line with the idea of making DataLayout a required
part of Module. With it the only way of having a DataLayout used is to add it
to the Module.
llvm-svn: 217548
Diffstat (limited to 'llvm/lib/IR/DataLayout.cpp')
-rw-r--r-- | llvm/lib/IR/DataLayout.cpp | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/llvm/lib/IR/DataLayout.cpp b/llvm/lib/IR/DataLayout.cpp index dea05fbef4a..38873538670 100644 --- a/llvm/lib/IR/DataLayout.cpp +++ b/llvm/lib/IR/DataLayout.cpp @@ -345,6 +345,10 @@ void DataLayout::parseSpecifier(StringRef Desc) { } DataLayout::DataLayout(const Module *M) : LayoutMap(nullptr) { + init(M); +} + +void DataLayout::init(const Module *M) { const DataLayout *Other = M->getDataLayout(); if (Other) *this = *Other; @@ -796,17 +800,17 @@ unsigned DataLayout::getPreferredAlignmentLog(const GlobalVariable *GV) const { } DataLayoutPass::DataLayoutPass() : ImmutablePass(ID), DL("") { - report_fatal_error("Bad DataLayoutPass ctor used. Tool did not specify a " - "DataLayout to use?"); + initializeDataLayoutPassPass(*PassRegistry::getPassRegistry()); } DataLayoutPass::~DataLayoutPass() {} -DataLayoutPass::DataLayoutPass(const DataLayout &DL) - : ImmutablePass(ID), DL(DL) { - initializeDataLayoutPassPass(*PassRegistry::getPassRegistry()); +bool DataLayoutPass::doInitialization(Module &M) { + DL.init(&M); + return false; } -DataLayoutPass::DataLayoutPass(const Module *M) : ImmutablePass(ID), DL(M) { - initializeDataLayoutPassPass(*PassRegistry::getPassRegistry()); +bool DataLayoutPass::doFinalization(Module &M) { + DL.reset(""); + return false; } |