Add the ability to "intern" FoldingSetNodeID data into a

BumpPtrAllocator-allocated region to allow it to be stored in a more
compact form and to avoid the need for a non-trivial destructor call.

Use this new mechanism in ScalarEvolution instead of
FastFoldingSetNode to avoid leaking memory in the case where a
FoldingSetNodeID uses heap storage, and to reduce overall memory
usage.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@98829 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Dan Gohman
2010-03-18 16:16:38 +00:00
parent 7c4a121110
commit c93b4cff89
5 changed files with 76 additions and 40 deletions

View File

@@ -49,7 +49,11 @@ namespace llvm {
/// are opaque objects that the client is not allowed to do much with
/// directly.
///
class SCEV : public FastFoldingSetNode {
class SCEV : public FoldingSetNode {
/// FastID - A reference to an Interned FoldingSetNodeID for this node.
/// The ScalarEvolution's BumpPtrAllocator holds the data.
FoldingSetNodeIDRef FastID;
// The SCEV baseclass this node corresponds to
const unsigned short SCEVType;
@@ -64,11 +68,14 @@ namespace llvm {
protected:
virtual ~SCEV();
public:
explicit SCEV(const FoldingSetNodeID &ID, unsigned SCEVTy) :
FastFoldingSetNode(ID), SCEVType(SCEVTy), SubclassData(0) {}
explicit SCEV(const FoldingSetNodeIDRef ID, unsigned SCEVTy) :
FastID(ID), SCEVType(SCEVTy), SubclassData(0) {}
unsigned getSCEVType() const { return SCEVType; }
/// Profile - FoldingSet support.
void Profile(FoldingSetNodeID& ID) { ID = FastID; }
/// isLoopInvariant - Return true if the value of this SCEV is unchanging in
/// the specified loop.
virtual bool isLoopInvariant(const Loop *L) const = 0;