Chris, Can't we just change this part of ConstantInt:
/// getTrue/getFalse - Return the singleton true/false values. static inline ConstantInt *getTrue() { if (TheTrueVal) return TheTrueVal; return CreateTrueFalseVals(true); } static inline ConstantInt *getFalse() { if (TheFalseVal) return TheFalseVal; return CreateTrueFalseVals(false); } into: /// getTrue/getFalse - Return the singleton true/false values. static inline ConstantInt *getTrue() { return get(Type::Int1Ty, 1); } static inline ConstantInt *getFalse() { return get(Type::Int1Ty, 0); } and get rid of all the special handling of true/false values? Or have we provided this simply as an optimization on frequently obtained integer values? Reid. On Tue, 2007-02-27 at 11:34 -0800, Reid Spencer wrote: > On Tue, 2007-02-27 at 09:10 -0800, Chris Lattner wrote: > > > Index: llvm/lib/VMCore/Constants.cpp > > > diff -u llvm/lib/VMCore/Constants.cpp:1.222 llvm/lib/VMCore/ > > > Constants.cpp:1.223 > > > --- llvm/lib/VMCore/Constants.cpp:1.222 Mon Feb 26 21:05:06 2007 > > > +++ llvm/lib/VMCore/Constants.cpp Tue Feb 27 01:57:53 2007 > > > @@ -118,7 +118,7 @@ > > > if (ITy->getBitWidth() == 1) > > > return ConstantInt::getTrue(); > > > else > > > - return ConstantInt::get(Ty, int64_t(-1)); > > > + return ConstantInt::get(Ty, APInt::getAllOnesValue(ITy- > > > >getBitWidth())); > > > return 0; > > > } > > > > The special case for 'i1' can be removed, right? > > I assumed the special case was because of this mess: > > > ConstantInt *ConstantInt::TheTrueVal = 0; > > ConstantInt *ConstantInt::TheFalseVal = 0; > > > > namespace llvm { > > void CleanupTrueFalse(void *) { > > ConstantInt::ResetTrueFalse(); > > } > > } > > > > static ManagedCleanup<llvm::CleanupTrueFalse> TrueFalseCleanup; > > > > ConstantInt *ConstantInt::CreateTrueFalseVals(bool WhichOne) { > > assert(TheTrueVal == 0 && TheFalseVal == 0); > > TheTrueVal = get(Type::Int1Ty, 1); > > TheFalseVal = get(Type::Int1Ty, 0); > > > > // Ensure that llvm_shutdown nulls out TheTrueVal/TheFalseVal. > > TrueFalseCleanup.Register(); > > > > return WhichOne ? TheTrueVal : TheFalseVal; > > } > > why do we need this? > > > > > -Chris > > _______________________________________________ > llvm-commits mailing list > llvm-commits@cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits _______________________________________________ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits