[LLVMbugs] [Bug 13756] New: segmentation fault in Loop Strength Reduction

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Sun Sep 2 22:18:10 PDT 2012


http://llvm.org/bugs/show_bug.cgi?id=13756

             Bug #: 13756
           Summary: segmentation fault in Loop Strength Reduction
           Product: libraries
           Version: trunk
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: Scalar Optimizations
        AssignedTo: unassignedbugs at nondot.org
        ReportedBy: junyer at gmail.com
                CC: llvmbugs at cs.uiuc.edu
    Classification: Unclassified


Created attachment 9147
  --> http://llvm.org/bugs/attachment.cgi?id=9147
an LLVM function that implements a DFA that recognises `.+' in UTF-8

In lib/Transforms/Scalar/LoopStrengthReduce.cpp, RewriteForPHI() doesn't handle
SplitCriticalEdge() returning NULL. I'm assuming that it's an edge case (pun
not intended) that you haven't encountered before, so I'm attaching code that
reproduces the bug, but it seems like the fix might be straightforward?


`llvm-as dotplus.ll -o=dotplus.bc' works.

`opt dotplus.bc -S -codegenprepare -mem2reg -loop-deletion' works.

`opt dotplus.bc -S -codegenprepare -mem2reg -loop-reduce' works.

`opt dotplus.bc -S -codegenprepare -mem2reg -loop-deletion -loop-reduce'
crashes!


This patch simply stops LLVM from crashing, but might not be the ideal
solution...


--- llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp.orig
+++ llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
@@ -4447,6 +4447,10 @@ void LSRInstance::RewriteForPHI(PHINode *PN,
            NewBB = SplitCriticalEdge(BB, Parent, P,
                                      /*MergeIdenticalEdges=*/true,
                                      /*DontDeleteUselessPhis=*/true);
+            // It wasn't split, so it wasn't a critical edge after all.
Possibly
+            // due to identical edges all from the same predecessor.
+            if (!NewBB)
+              goto no_split;
          } else {
            SmallVector<BasicBlock*, 2> NewBBs;
            SplitLandingPadPredecessors(Parent, BB, "", "", P, NewBBs);
@@ -4465,6 +4469,7 @@ void LSRInstance::RewriteForPHI(PHINode *PN,
          i = PN->getBasicBlockIndex(BB);
        }
      }
+    no_split:

      std::pair<DenseMap<BasicBlock *, Value *>::iterator, bool> Pair =
        Inserted.insert(std::make_pair(BB, static_cast<Value *>(0)));

-- 
Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.



More information about the llvm-bugs mailing list