[llvm] r359582 - [X86] If PreprocessISelDAG reorders a load before a call, make sure we remove dead nodes from the graph

Craig Topper via llvm-commits llvm-commits at lists.llvm.org
Tue Apr 30 10:56:47 PDT 2019


Author: ctopper
Date: Tue Apr 30 10:56:47 2019
New Revision: 359582

URL: http://llvm.org/viewvc/llvm-project?rev=359582&view=rev
Log:
[X86] If PreprocessISelDAG reorders a load before a call, make sure we remove dead nodes from the graph

The reordering can leave at least a dead TokenFactor in the graph. This cause the linearize scheduler to fail with something like the assert seen in PR22614. This is only one of many ways we can break the linearize scheduler today so I can't say for sure that any of the other failures in that bug were caused by this issue.

This takes the heavy hammer approach of just running RemoveDeadNodes unconditionally at the end of the PreprocessISelDAG. If this turns out to be a compile time hit, we can try to refine it.

Differential Revision: https://reviews.llvm.org/D61164

Modified:
    llvm/trunk/lib/Target/X86/X86ISelDAGToDAG.cpp
    llvm/trunk/test/CodeGen/X86/fold-call-3.ll

Modified: llvm/trunk/lib/Target/X86/X86ISelDAGToDAG.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86ISelDAGToDAG.cpp?rev=359582&r1=359581&r2=359582&view=diff
==============================================================================
--- llvm/trunk/lib/Target/X86/X86ISelDAGToDAG.cpp (original)
+++ llvm/trunk/lib/Target/X86/X86ISelDAGToDAG.cpp Tue Apr 30 10:56:47 2019
@@ -907,6 +907,11 @@ void X86DAGToDAGISel::PreprocessISelDAG(
     ++I;
     CurDAG->DeleteNode(N);
   }
+
+  // The load+call transform above can leave some dead nodes in the graph. Make
+  // sure we remove them. Its possible some of the other transforms do to so
+  // just remove dead nodes unconditionally.
+  CurDAG->RemoveDeadNodes();
 }
 
 // Look for a redundant movzx/movsx that can occur after an 8-bit divrem.

Modified: llvm/trunk/test/CodeGen/X86/fold-call-3.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/fold-call-3.ll?rev=359582&r1=359581&r2=359582&view=diff
==============================================================================
--- llvm/trunk/test/CodeGen/X86/fold-call-3.ll (original)
+++ llvm/trunk/test/CodeGen/X86/fold-call-3.ll Tue Apr 30 10:56:47 2019
@@ -1,5 +1,7 @@
 ; RUN: llc < %s -mtriple=x86_64-apple-darwin | grep call | grep 560
 ; rdar://6522427
+; This command line used to crash due to dangling nodes left after PreprocessISelDAG
+; RUN: llc < %s -mtriple=x86_64-apple-darwin -pre-RA-sched=linearize
 
 	%"struct.clang::Action" = type { %"struct.clang::ActionBase" }
 	%"struct.clang::ActionBase" = type { i32 (...)** }




More information about the llvm-commits mailing list