diff options
author | Chris Lattner <sabre@nondot.org> | 2006-01-04 02:03:29 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2006-01-04 02:03:29 +0000 |
commit | d15ed597349e611553f0eb72b7187844c7630acc (patch) | |
tree | fd715b4b4fad77057a4f0c3082ce047f428a9e90 | |
parent | 20542957961fc607bacbd9c13cd935eefbdc6f1c (diff) |
don't crash when trying to constant fold packed expressions.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@25072 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/VMCore/ConstantFold.cpp | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/lib/VMCore/ConstantFold.cpp b/lib/VMCore/ConstantFold.cpp index 802c9f4011..4cbe919b83 100644 --- a/lib/VMCore/ConstantFold.cpp +++ b/lib/VMCore/ConstantFold.cpp @@ -328,6 +328,29 @@ struct NullPointerRules : public TemplateRules<ConstantPointerNull, } }; +//===----------------------------------------------------------------------===// +// ConstantPackedRules Class +//===----------------------------------------------------------------------===// + +/// PackedTypeRules provides a concrete base class of ConstRules for +/// ConstantPacked operands. +/// +struct ConstantPackedRules + : public TemplateRules<ConstantPacked, ConstantPackedRules> { +}; + + +//===----------------------------------------------------------------------===// +// GeneralPackedRules Class +//===----------------------------------------------------------------------===// + +/// GeneralPackedRules provides a concrete base class of ConstRules for +/// PackedType operands, where both operands are not ConstantPacked. The usual +/// cause for this is that one operand is a ConstantAggregateZero. +/// +struct GeneralPackedRules : public TemplateRules<Constant, GeneralPackedRules> { +}; + //===----------------------------------------------------------------------===// // DirectRules Class @@ -487,6 +510,8 @@ 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<ConstantSInt, signed char , &Type::SByteTy> SByteR; static DirectIntRules<ConstantUInt, unsigned char , &Type::UByteTy> UByteR; static DirectIntRules<ConstantSInt, signed short, &Type::ShortTy> ShortR; @@ -517,6 +542,10 @@ ConstRules &ConstRules::get(const Constant *V1, const Constant *V2) { case Type::ULongTyID: return ULongR; case Type::FloatTyID: return FloatR; case Type::DoubleTyID: return DoubleR; + case Type::PackedTyID: + if (isa<ConstantPacked>(V1) && isa<ConstantPacked>(V2)) + return ConstantPackedR; + return GeneralPackedR; // Constant folding rules for ConstantAggregateZero. } } |