From ef671b56276a2d8b6e91b805d7c1dfb72cf2ad42 Mon Sep 17 00:00:00 2001 From: Duncan Sands Date: Sun, 14 Dec 2008 09:43:15 +0000 Subject: [PATCH] Reapply r60997, this time without forgetting that target constants are allowed to have an illegal type. llvm-svn: 61006 --- include/llvm/CodeGen/SelectionDAG.h | 2 +- lib/CodeGen/SelectionDAG/LegalizeDAG.cpp | 17 ++++++++++++----- lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp | 4 ++-- 3 files changed, 15 insertions(+), 8 deletions(-) diff --git a/include/llvm/CodeGen/SelectionDAG.h b/include/llvm/CodeGen/SelectionDAG.h index d18e3c3c359..4cbe3b02e49 100644 --- a/include/llvm/CodeGen/SelectionDAG.h +++ b/include/llvm/CodeGen/SelectionDAG.h @@ -212,7 +212,7 @@ public: /// /// Note that this is an involved process that may invalidate pointers into /// the graph. - void Legalize(); + void Legalize(bool TypesNeedLegalizing); /// RemoveDeadNodes - This method deletes all unreachable nodes in the /// SelectionDAG. diff --git a/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp b/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp index 6f4158b58c1..3a99a256ccc 100644 --- a/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp +++ b/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp @@ -51,6 +51,7 @@ namespace { class VISIBILITY_HIDDEN SelectionDAGLegalize { TargetLowering &TLI; SelectionDAG &DAG; + bool TypesNeedLegalizing; // Libcall insertion helpers. @@ -127,7 +128,7 @@ class VISIBILITY_HIDDEN SelectionDAGLegalize { } public: - explicit SelectionDAGLegalize(SelectionDAG &DAG); + explicit SelectionDAGLegalize(SelectionDAG &DAG, bool TypesNeedLegalizing); /// getTypeAction - Return how we should legalize values of this type, either /// it is already legal or we need to expand it into multiple registers of @@ -348,8 +349,8 @@ SDNode *SelectionDAGLegalize::isShuffleLegal(MVT VT, SDValue Mask) const { return TLI.isShuffleMaskLegal(Mask, VT) ? Mask.getNode() : 0; } -SelectionDAGLegalize::SelectionDAGLegalize(SelectionDAG &dag) - : TLI(dag.getTargetLoweringInfo()), DAG(dag), +SelectionDAGLegalize::SelectionDAGLegalize(SelectionDAG &dag, bool types) + : TLI(dag.getTargetLoweringInfo()), DAG(dag), TypesNeedLegalizing(types), ValueTypeActions(TLI.getValueTypeActions()) { assert(MVT::LAST_VALUETYPE <= 32 && "Too many value types for ValueTypeActions to hold!"); @@ -488,6 +489,12 @@ bool SelectionDAGLegalize::LegalizeAllNodesNotLeadingTo(SDNode *N, SDNode *Dest, /// appropriate for its type. void SelectionDAGLegalize::HandleOp(SDValue Op) { MVT VT = Op.getValueType(); + // If the type legalizer was run then we should never see any illegal result + // types here except for target constants (the type legalizer does not touch + // those). + assert((TypesNeedLegalizing || getTypeAction(VT) == Legal || + Op.getOpcode() == ISD::TargetConstant) && + "Illegal type introduced after type legalization?"); switch (getTypeAction(VT)) { default: assert(0 && "Bad type action!"); case Legal: (void)LegalizeOp(Op); break; @@ -8602,9 +8609,9 @@ SDValue SelectionDAGLegalize::StoreWidenVectorOp(StoreSDNode *ST, // SelectionDAG::Legalize - This is the entry point for the file. // -void SelectionDAG::Legalize() { +void SelectionDAG::Legalize(bool TypesNeedLegalizing) { /// run - This is the main entry point to this class. /// - SelectionDAGLegalize(*this).LegalizeDAG(); + SelectionDAGLegalize(*this, TypesNeedLegalizing).LegalizeDAG(); } diff --git a/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp b/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp index 3d2fb346269..c2b7d3f1db4 100644 --- a/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp +++ b/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp @@ -620,9 +620,9 @@ void SelectionDAGISel::CodeGenAndEmitDAG() { if (TimePassesIsEnabled) { NamedRegionTimer T("DAG Legalization", GroupName); - CurDAG->Legalize(); + CurDAG->Legalize(DisableLegalizeTypes); } else { - CurDAG->Legalize(); + CurDAG->Legalize(DisableLegalizeTypes); } DOUT << "Legalized selection DAG:\n";