[PATCH] D29180: Fix implementation of DAGTypeLegalizer::PerformExpensiveChecks

Serge Pavlov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sun Jan 29 23:54:22 PST 2017


sepavloff updated this revision to Diff 86246.
sepavloff added a comment.

Added one more case where legalization failed

With current implementation of the legalizer a node may present in both
`SoftenedFloats` and `ReplacedValues`. Now this change fixes 9 test fails
observed in builds with expensive checks enabled.


https://reviews.llvm.org/D29180

Files:
  lib/CodeGen/SelectionDAG/LegalizeTypes.cpp
  test/CodeGen/ARM/fp16.ll
  test/CodeGen/X86/soft-fp.ll


Index: test/CodeGen/X86/soft-fp.ll
===================================================================
--- test/CodeGen/X86/soft-fp.ll
+++ test/CodeGen/X86/soft-fp.ll
@@ -2,7 +2,7 @@
 ; RUN:     | FileCheck %s --check-prefix=SOFT1 --check-prefix=CHECK
 ; RUN: llc < %s -march=x86-64 -mattr=+mmx,+sse2,+soft-float \
 ; RUN:     | FileCheck %s --check-prefix=SOFT2 --check-prefix=CHECK
-; RUN: llc < %s -march=x86-64 -mattr=+mmx,+sse \
+; RUN: llc < %s -march=x86-64 -mattr=+mmx,+sse -enable-legalize-types-checking \
 ; RUN:     | FileCheck %s --check-prefix=SSE1 --check-prefix=CHECK
 ; RUN: llc < %s -march=x86-64 -mattr=+mmx,+sse2 \
 ; RUN:     | FileCheck %s --check-prefix=SSE2 --check-prefix=CHECK
Index: test/CodeGen/ARM/fp16.ll
===================================================================
--- test/CodeGen/ARM/fp16.ll
+++ test/CodeGen/ARM/fp16.ll
@@ -2,7 +2,7 @@
 ; RUN: llc -mtriple=armv7a--none-gnueabi < %s | FileCheck --check-prefix=CHECK --check-prefix=CHECK-HARDFLOAT-GNU %s
 ; RUN: llc -mtriple=armv7a--none-musleabi < %s | FileCheck --check-prefix=CHECK --check-prefix=CHECK-HARDFLOAT-GNU %s
 ; RUN: llc -mtriple=armv8-eabihf < %s | FileCheck --check-prefix=CHECK --check-prefix=CHECK-ARMV8 %s
-; RUN: llc -mtriple=thumbv7m-eabi < %s | FileCheck --check-prefix=CHECK --check-prefix=CHECK-SOFTFLOAT-EABI %s
+; RUN: llc -mtriple=thumbv7m-eabi -enable-legalize-types-checking < %s | FileCheck --check-prefix=CHECK --check-prefix=CHECK-SOFTFLOAT-EABI %s
 ; RUN: llc -mtriple=thumbv7m-gnueabi < %s | FileCheck --check-prefix=CHECK --check-prefix=CHECK-SOFTFLOAT-GNU %s
 ; RUN: llc -mtriple=thumbv7m-musleabi < %s | FileCheck --check-prefix=CHECK --check-prefix=CHECK-SOFTFLOAT-GNU %s
 
Index: lib/CodeGen/SelectionDAG/LegalizeTypes.cpp
===================================================================
--- lib/CodeGen/SelectionDAG/LegalizeTypes.cpp
+++ lib/CodeGen/SelectionDAG/LegalizeTypes.cpp
@@ -33,7 +33,9 @@
   // of PromotedIntegers, ExpandedIntegers, ..., ReplacedValues.
 
   // If a node is processed, then each value with an illegal type must be mapped
-  // by exactly one of PromotedIntegers, ExpandedIntegers, ..., ReplacedValues.
+  // by exactly one of PromotedIntegers, ExpandedIntegers, ..., ReplacedValues
+  // with the exception that a value may be in SoftenedFloats and in
+  // ReplacedValues simultaneously.
   // Values with a legal type may be mapped by ReplacedValues, but not by any of
   // the other maps.
 
@@ -124,7 +126,9 @@
         // Since we allow ReplacedValues to map deleted nodes, it may map nodes
         // marked NewNode too, since a deleted node may have been reallocated as
         // another node that has not been seen by the LegalizeTypes machinery.
-        if ((Node.getNodeId() == NewNode && Mapped > 1) ||
+        // Treatment of SoftenedFloats may also create nodes that are abandoned
+        // latter.
+        if ((Node.getNodeId() == NewNode && Mapped > 1 && Mapped != 4) ||
             (Node.getNodeId() != NewNode && Mapped != 0)) {
           dbgs() << "Unprocessed value in a map!";
           Failed = true;
@@ -138,7 +142,7 @@
         if (Mapped == 0) {
           dbgs() << "Processed value not in any map!";
           Failed = true;
-        } else if (Mapped & (Mapped - 1)) {
+        } else if ((Mapped != (1 | 4)) && (Mapped & (Mapped - 1))) {
           dbgs() << "Value in multiple maps!";
           Failed = true;
         }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D29180.86246.patch
Type: text/x-patch
Size: 3425 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170130/080449d1/attachment.bin>


More information about the llvm-commits mailing list