[llvm] r263676 - Add optional allocator to YAML code to avoid leaking lld atoms.
Pete Cooper via llvm-commits
llvm-commits at lists.llvm.org
Wed Mar 16 16:29:32 PDT 2016
Author: pete
Date: Wed Mar 16 18:29:31 2016
New Revision: 263676
URL: http://llvm.org/viewvc/llvm-project?rev=263676&view=rev
Log:
Add optional allocator to YAML code to avoid leaking lld atoms.
In lld we allocate atoms on an allocator and so don't run their
destructors. This means we also shouldn't allocate memory inside
them without that also being on an allocator.
Reviewed by Lang Hames and Rafael Espindola.
Modified:
llvm/trunk/include/llvm/Support/YAMLTraits.h
Modified: llvm/trunk/include/llvm/Support/YAMLTraits.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/YAMLTraits.h?rev=263676&r1=263675&r2=263676&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Support/YAMLTraits.h (original)
+++ llvm/trunk/include/llvm/Support/YAMLTraits.h Wed Mar 16 18:29:31 2016
@@ -894,12 +894,16 @@ private:
// to [de]normalize an object for use with YAML conversion.
template <typename TNorm, typename TFinal>
struct MappingNormalizationHeap {
- MappingNormalizationHeap(IO &i_o, TFinal &Obj)
+ MappingNormalizationHeap(IO &i_o, TFinal &Obj,
+ llvm::BumpPtrAllocator *allocator = nullptr)
: io(i_o), BufPtr(nullptr), Result(Obj) {
if ( io.outputting() ) {
BufPtr = new (&Buffer) TNorm(io, Obj);
}
- else {
+ else if (allocator) {
+ BufPtr = allocator->Allocate<TNorm>();
+ new (BufPtr) TNorm(io);
+ } else {
BufPtr = new TNorm(io);
}
}
More information about the llvm-commits
mailing list