From 6a57baa295bb3dbd389581df968536f594709bdb Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Wed, 3 Oct 2001 15:39:36 +0000 Subject: [PATCH] Rename getNullPointer to getNull Allow sharing of null pointer constants git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@709 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/VMCore/ConstPoolVals.cpp | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/lib/VMCore/ConstPoolVals.cpp b/lib/VMCore/ConstPoolVals.cpp index 6c054e1ee07..eeb7a43069f 100644 --- a/lib/VMCore/ConstPoolVals.cpp +++ b/lib/VMCore/ConstPoolVals.cpp @@ -46,7 +46,7 @@ ConstPoolVal *ConstPoolVal::getNullConstant(const Type *Ty) { case Type::DoubleTyID: return ConstPoolFP::get(Ty, 0); case Type::PointerTyID: - return ConstPoolPointer::getNullPointer(cast(Ty)); + return ConstPoolPointer::getNull(cast(Ty)); default: return 0; } @@ -331,3 +331,15 @@ ConstPoolStruct *ConstPoolStruct::get(const StructType *Ty, StructConstants.add(Ty, V, Result = new ConstPoolStruct(Ty, V)); return Result; } + +//---- ConstPoolPointer::get() implementation... +// +static ValueMap NullPtrConstants; + +ConstPoolPointer *ConstPoolPointer::getNull(const PointerType *Ty) { + ConstPoolPointer *Result = NullPtrConstants.get(Ty, 0); + if (!Result) // If no preexisting value, create one now... + NullPtrConstants.add(Ty, 0, Result = new ConstPoolPointer(Ty)); + return Result; +} + -- 2.34.1