LegalizeDAG is not supposed to introduce illegal
authorDuncan Sands <baldrick@free.fr>
Sat, 13 Dec 2008 22:33:38 +0000 (22:33 +0000)
committerDuncan Sands <baldrick@free.fr>
Sat, 13 Dec 2008 22:33:38 +0000 (22:33 +0000)
types into the DAG if they were not already there.
Check this with an assertion.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@60997 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/CodeGen/SelectionDAG.h
lib/CodeGen/SelectionDAG/LegalizeDAG.cpp
lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp

index d18e3c3c35938e78306912bb4aa00c073546489b..4cbe3b02e493783240e205f75669cabd67a6fdc9 100644 (file)
@@ -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.
index 6f4158b58c18507b58a55939f6743c6d6d7bca93..dd9d667895b16c8301f4dfdeb11ea48f152c9e36 100644 (file)
@@ -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,8 @@ bool SelectionDAGLegalize::LegalizeAllNodesNotLeadingTo(SDNode *N, SDNode *Dest,
 /// appropriate for its type.
 void SelectionDAGLegalize::HandleOp(SDValue Op) {
   MVT VT = Op.getValueType();
+  assert((TypesNeedLegalizing || getTypeAction(VT) == Legal) &&
+         "Illegal type introduced after type legalization?");
   switch (getTypeAction(VT)) {
   default: assert(0 && "Bad type action!");
   case Legal:   (void)LegalizeOp(Op); break;
@@ -8602,9 +8605,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();
 }
 
index 3d2fb3462691f3df3114e53d0471235f56d3226b..c2b7d3f1db40aaa49fa0908ecfc52fff56557342 100644 (file)
@@ -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";