diff options
author | Chris Lattner <sabre@nondot.org> | 2007-02-20 05:46:39 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2007-02-20 05:46:39 +0000 |
commit | e0e769607c8d6569daea0ff55a99fa2532029342 (patch) | |
tree | 4af74eb72d832ac9b64e3a323672c06a21c0b77c | |
parent | bb9a0411007d9bb7a60313fe427e2ef1fc98c22a (diff) |
simplify some code that was not llvm_shutdown safe
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@34440 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/VMCore/Constants.cpp | 41 |
1 files changed, 5 insertions, 36 deletions
diff --git a/lib/VMCore/Constants.cpp b/lib/VMCore/Constants.cpp index c89609ec9f..58fe8882c8 100644 --- a/lib/VMCore/Constants.cpp +++ b/lib/VMCore/Constants.cpp @@ -89,45 +89,14 @@ bool Constant::canTrap() const { } } - // Static constructor to create a '0' constant of arbitrary type... Constant *Constant::getNullValue(const Type *Ty) { switch (Ty->getTypeID()) { - case Type::IntegerTyID: { - const IntegerType *ITy = dyn_cast<IntegerType>(Ty); - switch (ITy->getBitWidth()) { - case 1: { - static Constant *NullBool = ConstantInt::get(Ty, false); - return NullBool; - } - case 8: { - static Constant *NullInt8 = ConstantInt::get(Ty, 0); - return NullInt8; - } - case 16: { - static Constant *NullInt16 = ConstantInt::get(Ty, 0); - return NullInt16; - } - case 32: { - static Constant *NullInt32 = ConstantInt::get(Ty, 0); - return NullInt32; - } - case 64: { - static Constant *NullInt64 = ConstantInt::get(Ty, 0); - return NullInt64; - } - default: - return ConstantInt::get(Ty, 0); - } - } - case Type::FloatTyID: { - static Constant *NullFloat = ConstantFP::get(Type::FloatTy, 0); - return NullFloat; - } - case Type::DoubleTyID: { - static Constant *NullDouble = ConstantFP::get(Type::DoubleTy, 0); - return NullDouble; - } + case Type::IntegerTyID: + return ConstantInt::get(Ty, 0); + case Type::FloatTyID: + case Type::DoubleTyID: + return ConstantFP::get(Ty, 0.0); case Type::PointerTyID: return ConstantPointerNull::get(cast<PointerType>(Ty)); case Type::StructTyID: |