[llvm] 4e87823 - [LoopLoadElim] Fix crash by always checking simplify form

Max Kazantsev via llvm-commits llvm-commits at lists.llvm.org
Thu Apr 9 19:32:16 PDT 2020


Author: Max Kazantsev
Date: 2020-04-10T09:23:28+07:00
New Revision: 4e8782302691518b084ab3d57ebbbd140fbe9a14

URL: https://github.com/llvm/llvm-project/commit/4e8782302691518b084ab3d57ebbbd140fbe9a14
DIFF: https://github.com/llvm/llvm-project/commit/4e8782302691518b084ab3d57ebbbd140fbe9a14.diff

LOG: [LoopLoadElim] Fix crash by always checking simplify form

Loop simplify form should always be checked because logic of
propagateStoredValueToLoadUsers relies on it (in particular, it
requires preheader).

Reviewed By: Fedor Sergeev, Florian Hahn
Differential Revision: https://reviews.llvm.org/D77775

Added: 
    

Modified: 
    llvm/lib/Transforms/Scalar/LoopLoadElimination.cpp
    llvm/test/Transforms/LoopLoadElim/new-pm-preheader-problem.ll

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Transforms/Scalar/LoopLoadElimination.cpp b/llvm/lib/Transforms/Scalar/LoopLoadElimination.cpp
index b074a11be5b5..78460bfc5c00 100644
--- a/llvm/lib/Transforms/Scalar/LoopLoadElimination.cpp
+++ b/llvm/lib/Transforms/Scalar/LoopLoadElimination.cpp
@@ -535,6 +535,11 @@ class LoadEliminationForLoop {
       return false;
     }
 
+    if (!L->isLoopSimplifyForm()) {
+      LLVM_DEBUG(dbgs() << "Loop is not is loop-simplify form");
+      return false;
+    }
+
     if (!Checks.empty() || !LAI.getPSE().getUnionPredicate().isAlwaysTrue()) {
       if (LAI.hasConvergentOp()) {
         LLVM_DEBUG(dbgs() << "Versioning is needed but not allowed with "
@@ -554,11 +559,6 @@ class LoadEliminationForLoop {
         return false;
       }
 
-      if (!L->isLoopSimplifyForm()) {
-        LLVM_DEBUG(dbgs() << "Loop is not is loop-simplify form");
-        return false;
-      }
-
       // Point of no-return, start the transformation.  First, version the loop
       // if necessary.
 

diff  --git a/llvm/test/Transforms/LoopLoadElim/new-pm-preheader-problem.ll b/llvm/test/Transforms/LoopLoadElim/new-pm-preheader-problem.ll
index a63dc29faca7..b436310b76c4 100644
--- a/llvm/test/Transforms/LoopLoadElim/new-pm-preheader-problem.ll
+++ b/llvm/test/Transforms/LoopLoadElim/new-pm-preheader-problem.ll
@@ -1,7 +1,5 @@
-; XFAIL: *
 ; RUN: opt -passes=loop-load-elim -S < %s | FileCheck %s
-; This test demonstrates an assertion failure due to missing preheader in new PM.
-; REQUIRES: asserts
+; Make sure it doesn't crash in new pass manager due to missing preheader.
 target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"
 
 define void @test(i32* noalias nocapture %A, i32* noalias nocapture readonly %B, i64 %N, i1 %C) {


        


More information about the llvm-commits mailing list