From 9ac3ec43b3eb2c18007542c1fe43d93519606c32 Mon Sep 17 00:00:00 2001 From: Philip Reames Date: Fri, 4 Dec 2015 23:06:33 +0000 Subject: [PATCH 1/1] Address a memory leak in 254760 The issue appears to have been that the copy constructor of the SmallVector was being invoked and this was somehow leading to leaked memory. This patch avoids the symptom, but likely doesn't address the underlying problem. I'm still investigating the root cause, but wanted to avoid the memory leak in the mean time. Even with the underlying fix, avoiding the redundant allocation is worthwhile. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@254795 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/IR/LegacyPassManagers.h | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/include/llvm/IR/LegacyPassManagers.h b/include/llvm/IR/LegacyPassManagers.h index af045585691..418702c0b78 100644 --- a/include/llvm/IR/LegacyPassManagers.h +++ b/include/llvm/IR/LegacyPassManagers.h @@ -264,12 +264,15 @@ private: // TODO: We could consider sorting the dependency arrays within the // AnalysisUsage (since they are conceptually unordered). ID.AddBoolean(AU.getPreservesAll()); - for (auto &Vec : {AU.getRequiredSet(), AU.getRequiredTransitiveSet(), - AU.getPreservedSet(), AU.getUsedSet()}) { + auto ProfileVec = [&](const SmallVectorImpl& Vec) { ID.AddInteger(Vec.size()); for(AnalysisID AID : Vec) ID.AddPointer(AID); - } + }; + ProfileVec(AU.getRequiredSet()); + ProfileVec(AU.getRequiredTransitiveSet()); + ProfileVec(AU.getPreservedSet()); + ProfileVec(AU.getUsedSet()); } }; -- 2.34.1