aboutsummaryrefslogtreecommitdiffstats
path: root/lib/VMCore/LLVMContextImpl.cpp
diff options
context:
space:
mode:
authorTalin <viridia@gmail.com>2012-02-05 20:54:10 +0000
committerTalin <viridia@gmail.com>2012-02-05 20:54:10 +0000
commit2cb395eae71dacda49ca3fe758618fc3e0701659 (patch)
treec8abaa03940a385892716e78e1b80dcac0629880 /lib/VMCore/LLVMContextImpl.cpp
parentfad4d40f3792b0d9e101c40738e1f691131007d2 (diff)
downloadexternal_llvm-2cb395eae71dacda49ca3fe758618fc3e0701659.zip
external_llvm-2cb395eae71dacda49ca3fe758618fc3e0701659.tar.gz
external_llvm-2cb395eae71dacda49ca3fe758618fc3e0701659.tar.bz2
Efficient Constant Uniquing.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@149848 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/VMCore/LLVMContextImpl.cpp')
-rw-r--r--lib/VMCore/LLVMContextImpl.cpp16
1 files changed, 13 insertions, 3 deletions
diff --git a/lib/VMCore/LLVMContextImpl.cpp b/lib/VMCore/LLVMContextImpl.cpp
index 15c5c24..6279bb8 100644
--- a/lib/VMCore/LLVMContextImpl.cpp
+++ b/lib/VMCore/LLVMContextImpl.cpp
@@ -48,6 +48,16 @@ struct DropReferences {
P.second->dropAllReferences();
}
};
+
+// Temporary - drops pair.first instead of second.
+struct DropFirst {
+ // Takes the value_type of a ConstantUniqueMap's internal map, whose 'second'
+ // is a Constant*.
+ template<typename PairT>
+ void operator()(const PairT &P) {
+ P.first->dropAllReferences();
+ }
+};
}
LLVMContextImpl::~LLVMContextImpl() {
@@ -63,11 +73,11 @@ LLVMContextImpl::~LLVMContextImpl() {
std::for_each(ExprConstants.map_begin(), ExprConstants.map_end(),
DropReferences());
std::for_each(ArrayConstants.map_begin(), ArrayConstants.map_end(),
- DropReferences());
+ DropFirst());
std::for_each(StructConstants.map_begin(), StructConstants.map_end(),
- DropReferences());
+ DropFirst());
std::for_each(VectorConstants.map_begin(), VectorConstants.map_end(),
- DropReferences());
+ DropFirst());
ExprConstants.freeConstants();
ArrayConstants.freeConstants();
StructConstants.freeConstants();