[llvm-commits] CVS: llvm/lib/VMCore/ConstantFolding.cpp
Chris Lattner
lattner at cs.uiuc.edu
Tue Jan 3 18:03:41 PST 2006
Changes in directory llvm/lib/VMCore:
ConstantFolding.cpp updated: 1.76 -> 1.77
---
Log message:
don't crash when trying to constant fold packed expressions.
---
Diffs of the changes: (+29 -0)
ConstantFolding.cpp | 29 +++++++++++++++++++++++++++++
1 files changed, 29 insertions(+)
Index: llvm/lib/VMCore/ConstantFolding.cpp
diff -u llvm/lib/VMCore/ConstantFolding.cpp:1.76 llvm/lib/VMCore/ConstantFolding.cpp:1.77
--- llvm/lib/VMCore/ConstantFolding.cpp:1.76 Mon May 2 22:13:01 2005
+++ llvm/lib/VMCore/ConstantFolding.cpp Tue Jan 3 20:03:29 2006
@@ -328,6 +328,29 @@
}
};
+//===----------------------------------------------------------------------===//
+// 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 @@
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 @@
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.
}
}
More information about the llvm-commits
mailing list