From: Chris Lattner Date: Fri, 13 Oct 2006 17:22:21 +0000 (+0000) Subject: Fix another dtor issue. The function local statics in this function were X-Git-Url: http://plrg.eecs.uci.edu/git/?a=commitdiff_plain;h=0eff5ad3db4bc85e84c85a7fbdc6b26653ff223d;p=oota-llvm.git Fix another dtor issue. The function local statics in this function were being destroyed at inconvenient times. Switch to using non-local ManagedStatic objects, which actually also speeds up ConstRules::get. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@30931 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/VMCore/ConstantFold.cpp b/lib/VMCore/ConstantFold.cpp index 9139adf9de5..ffc5ccaedcf 100644 --- a/lib/VMCore/ConstantFold.cpp +++ b/lib/VMCore/ConstantFold.cpp @@ -23,9 +23,10 @@ #include "llvm/Instructions.h" #include "llvm/DerivedTypes.h" #include "llvm/Function.h" +#include "llvm/Support/Compiler.h" #include "llvm/Support/GetElementPtrTypeIterator.h" +#include "llvm/Support/ManagedStatic.h" #include "llvm/Support/MathExtras.h" -#include "llvm/Support/Compiler.h" #include #include using namespace llvm; @@ -584,49 +585,58 @@ struct VISIBILITY_HIDDEN DirectFPRules }; } // end anonymous namespace +static ManagedStatic EmptyR; +static ManagedStatic BoolR; +static ManagedStatic NullPointerR; +static ManagedStatic ConstantPackedR; +static ManagedStatic GeneralPackedR; +static ManagedStatic > SByteR; +static ManagedStatic > UByteR; +static ManagedStatic > ShortR; +static ManagedStatic > UShortR; +static ManagedStatic > IntR; +static ManagedStatic > UIntR; +static ManagedStatic > LongR; +static ManagedStatic > ULongR; +static ManagedStatic > FloatR; +static ManagedStatic > DoubleR; /// ConstRules::get - This method returns the constant rules implementation that /// implements the semantics of the two specified constants. ConstRules &ConstRules::get(const Constant *V1, const Constant *V2) { - static EmptyRules EmptyR; - static BoolRules BoolR; - static NullPointerRules NullPointerR; - static ConstantPackedRules ConstantPackedR; - static GeneralPackedRules GeneralPackedR; - static DirectIntRules SByteR; - static DirectIntRules UByteR; - static DirectIntRules ShortR; - static DirectIntRules UShortR; - static DirectIntRules IntR; - static DirectIntRules UIntR; - static DirectIntRules LongR; - static DirectIntRules ULongR; - static DirectFPRules FloatR; - static DirectFPRules DoubleR; - if (isa(V1) || isa(V2) || isa(V1) || isa(V2) || isa(V1) || isa(V2)) - return EmptyR; + return *EmptyR; switch (V1->getType()->getTypeID()) { default: assert(0 && "Unknown value type for constant folding!"); - case Type::BoolTyID: return BoolR; - case Type::PointerTyID: return NullPointerR; - case Type::SByteTyID: return SByteR; - case Type::UByteTyID: return UByteR; - case Type::ShortTyID: return ShortR; - case Type::UShortTyID: return UShortR; - case Type::IntTyID: return IntR; - case Type::UIntTyID: return UIntR; - case Type::LongTyID: return LongR; - case Type::ULongTyID: return ULongR; - case Type::FloatTyID: return FloatR; - case Type::DoubleTyID: return DoubleR; + case Type::BoolTyID: return *BoolR; + case Type::PointerTyID: return *NullPointerR; + case Type::SByteTyID: return *SByteR; + case Type::UByteTyID: return *UByteR; + case Type::ShortTyID: return *ShortR; + case Type::UShortTyID: return *UShortR; + case Type::IntTyID: return *IntR; + case Type::UIntTyID: return *UIntR; + case Type::LongTyID: return *LongR; + case Type::ULongTyID: return *ULongR; + case Type::FloatTyID: return *FloatR; + case Type::DoubleTyID: return *DoubleR; case Type::PackedTyID: if (isa(V1) && isa(V2)) - return ConstantPackedR; - return GeneralPackedR; // Constant folding rules for ConstantAggregateZero. + return *ConstantPackedR; + return *GeneralPackedR; // Constant folding rules for ConstantAggregateZero. } }