summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPete Cooper <peter_cooper@apple.com>2013-03-12 17:37:31 +0000
committerPete Cooper <peter_cooper@apple.com>2013-03-12 17:37:31 +0000
commit6308a828a3ffaaf8706428003e1d872f79183673 (patch)
treefd49ba76665c074a3915527cbd2c1bd1ddabaac0
parent6209366e812a4c0c47371762a1618c1c3a79193a (diff)
downloadbcm5719-llvm-6308a828a3ffaaf8706428003e1d872f79183673.tar.gz
bcm5719-llvm-6308a828a3ffaaf8706428003e1d872f79183673.zip
Add a doFinalization method to the DataLayout pass.
This pass is meant to be immutable, however it holds mutable state to cache StructLayouts. This method will allow the pass manager to clear the mutable state between runs. Note that unfortunately it is still necessary to have the destructor, even though it does the same thing as doFinalization. This is because most TargetMachines embed a DataLayout on which doFinalization isn't run as its never added to the pass manager. I also didn't think it was necessary to complication things with a deInit method for which doFinalization and ~DataLayout both call as there's only one field of mutable state. If we had more fields to finalize i'd have added this. llvm-svn: 176877
-rw-r--r--llvm/include/llvm/IR/DataLayout.h4
-rw-r--r--llvm/lib/IR/DataLayout.cpp6
2 files changed, 10 insertions, 0 deletions
diff --git a/llvm/include/llvm/IR/DataLayout.h b/llvm/include/llvm/IR/DataLayout.h
index 5eb186d5318..4d3016c72f2 100644
--- a/llvm/include/llvm/IR/DataLayout.h
+++ b/llvm/include/llvm/IR/DataLayout.h
@@ -181,6 +181,10 @@ public:
~DataLayout(); // Not virtual, do not subclass this class
+ /// DataLayout is an immutable pass, but holds state. This allows the pass
+ /// manager to clear its mutable state.
+ bool doFinalization(Module &M);
+
/// Parse a data layout string (with fallback to default values). Ensure that
/// the data layout pass is registered.
void init(StringRef LayoutDescription);
diff --git a/llvm/lib/IR/DataLayout.cpp b/llvm/lib/IR/DataLayout.cpp
index f09de3a7319..4100c4ff614 100644
--- a/llvm/lib/IR/DataLayout.cpp
+++ b/llvm/lib/IR/DataLayout.cpp
@@ -438,6 +438,12 @@ DataLayout::~DataLayout() {
delete static_cast<StructLayoutMap*>(LayoutMap);
}
+bool DataLayout::doFinalization(Module &M) {
+ delete static_cast<StructLayoutMap*>(LayoutMap);
+ LayoutMap = 0;
+ return false;
+}
+
const StructLayout *DataLayout::getStructLayout(StructType *Ty) const {
if (!LayoutMap)
LayoutMap = new StructLayoutMap();
OpenPOWER on IntegriCloud