diff options
author | dim <dim@FreeBSD.org> | 2016-01-13 19:58:01 +0000 |
---|---|---|
committer | dim <dim@FreeBSD.org> | 2016-01-13 19:58:01 +0000 |
commit | e39b9e36e5f2d2dd312004cf5f84bb382be47dcd (patch) | |
tree | 7376a0c71aad05d327e5b1dcbceb3311a10f9f29 /lib/IR/Function.cpp | |
parent | ff2ba393a56d9d99dcb76ceada542233db28af9a (diff) | |
download | FreeBSD-src-e39b9e36e5f2d2dd312004cf5f84bb382be47dcd.zip FreeBSD-src-e39b9e36e5f2d2dd312004cf5f84bb382be47dcd.tar.gz |
Vendor import of llvm trunk r257626:
https://llvm.org/svn/llvm-project/llvm/trunk@257626
Diffstat (limited to 'lib/IR/Function.cpp')
-rw-r--r-- | lib/IR/Function.cpp | 44 |
1 files changed, 9 insertions, 35 deletions
diff --git a/lib/IR/Function.cpp b/lib/IR/Function.cpp index cfb40b1..cfdfc40 100644 --- a/lib/IR/Function.cpp +++ b/lib/IR/Function.cpp @@ -366,47 +366,21 @@ void Function::addDereferenceableOrNullAttr(unsigned i, uint64_t Bytes) { setAttributes(PAL); } -// Maintain the GC name for each function in an on-the-side table. This saves -// allocating an additional word in Function for programs which do not use GC -// (i.e., most programs) at the cost of increased overhead for clients which do -// use GC. -static DenseMap<const Function*,PooledStringPtr> *GCNames; -static StringPool *GCNamePool; -static ManagedStatic<sys::SmartRWMutex<true> > GCLock; - -bool Function::hasGC() const { - sys::SmartScopedReader<true> Reader(*GCLock); - return GCNames && GCNames->count(this); -} - -const char *Function::getGC() const { +const std::string &Function::getGC() const { assert(hasGC() && "Function has no collector"); - sys::SmartScopedReader<true> Reader(*GCLock); - return *(*GCNames)[this]; + return getContext().getGC(*this); } -void Function::setGC(const char *Str) { - sys::SmartScopedWriter<true> Writer(*GCLock); - if (!GCNamePool) - GCNamePool = new StringPool(); - if (!GCNames) - GCNames = new DenseMap<const Function*,PooledStringPtr>(); - (*GCNames)[this] = GCNamePool->intern(Str); +void Function::setGC(const std::string Str) { + setValueSubclassDataBit(14, !Str.empty()); + getContext().setGC(*this, std::move(Str)); } void Function::clearGC() { - sys::SmartScopedWriter<true> Writer(*GCLock); - if (GCNames) { - GCNames->erase(this); - if (GCNames->empty()) { - delete GCNames; - GCNames = nullptr; - if (GCNamePool->empty()) { - delete GCNamePool; - GCNamePool = nullptr; - } - } - } + if (!hasGC()) + return; + getContext().deleteGC(*this); + setValueSubclassDataBit(14, false); } /// Copy all additional attributes (those not needed to create a Function) from |