[LLVMbugs] [Bug 7562] New: -mem2reg -indvars segfaults

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Sat Jul 3 08:15:03 PDT 2010


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

           Summary: -mem2reg -indvars segfaults
           Product: libraries
           Version: trunk
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: Loop Optimizer
        AssignedTo: unassignedbugs at nondot.org
        ReportedBy: grosser at fim.uni-passau.de
                CC: llvmbugs at cs.uiuc.edu


Created an attachment (id=5160)
 --> (http://llvm.org/bugs/attachment.cgi?id=5160)
Segfault with opt -mem2reg -indvars

Hi,

running "opt -mem2reg -indvars" on the attached test case leads to a SIGSEGV
because of stack space exhaustion.

Neither opt -mem2reg, opt -indvars nor opt -mem2reg -loopsimplify -indvars
crashes.

During the crash Indvars is introducing more and more canonical induction
variables, but does not recognize that it has already inserted one. I believe
this is because the
LI->getCanonicalInductionVariable() function expects a loop header with just
two predecessors. However in this case there are three.

Two possible solutions I thought about are:

* Change LI->getCanonicalInductionVariable() to not depend on loop simplified
form
* Require all users of SCEVExpander to ask for LoopSimplified loops.

Part of the backtrace until it repeats:
--------------------------------------------------------------
#21891 0x00007ffff5f2c12f in llvm::SCEVExpander::expand (this=0x7fffffffe070,
S=0x672140) at
/home/grosser/Projekte/llvm/git/lib/Analysis/ScalarEvolutionExpander.cpp:1297
#21892 0x00007ffff5f2c1ee in llvm::SCEVExpander::expandCodeFor
(this=0x7fffffffe070, SH=0x672140, Ty=0x0) at
/home/grosser/Projekte/llvm/git/lib/Analysis/ScalarEvolutionExpander.cpp:1255
#21893 0x00007ffff5f2d787 in llvm::SCEVExpander::expandCodeFor
(this=0x7fffffffe070, SH=0x672140, Ty=0x0, I=0x672c00) at
/home/grosser/Projekte/llvm/git/lib/Analysis/ScalarEvolutionExpander.cpp:1250
#21894 0x00007ffff5f2d86b in
llvm::SCEVExpander::getOrInsertCanonicalInductionVariable (this=0x7fffffffe070,
L=0x66f760, Ty=0x65e9c8) at
/home/grosser/Projekte/llvm/git/lib/Analysis/ScalarEvolutionExpander.cpp:1344
#21895 0x00007ffff5f2f87f in llvm::SCEVExpander::visitAddRecExpr
(this=0x7fffffffe070, S=0x672140) at
/home/grosser/Projekte/llvm/git/lib/Analysis/ScalarEvolutionExpander.cpp:1138
#21896 0x00007ffff5f34423 in llvm::SCEVVisitor<llvm::SCEVExpander,
llvm::Value*>::visit (this=0x7fffffffe070, S=0x672140) at
/home/grosser/Projekte/llvm/git/include/llvm/Analysis/ScalarEvolutionExpressions.h:588
#21897 0x00007ffff5f2c12f in llvm::SCEVExpander::expand (this=0x7fffffffe070,
S=0x672140) at
/home/grosser/Projekte/llvm/git/lib/Analysis/ScalarEvolutionExpander.cpp:1297
#21898 0x00007ffff5f2f547 in llvm::SCEVExpander::visitAddRecExpr
(this=0x7fffffffe070, S=0x671a50) at
/home/grosser/Projekte/llvm/git/lib/Analysis/ScalarEvolutionExpander.cpp:1100
#21899 0x00007ffff5f34423 in llvm::SCEVVisitor<llvm::SCEVExpander,
llvm::Value*>::visit (this=0x7fffffffe070, S=0x671a50) at
/home/grosser/Projekte/llvm/git/include/llvm/Analysis/ScalarEvolutionExpressions.h:588
#21900 0x00007ffff5f2c12f in llvm::SCEVExpander::expand (this=0x7fffffffe070,
S=0x671a50) at
/home/grosser/Projekte/llvm/git/lib/Analysis/ScalarEvolutionExpander.cpp:1297
#21901 0x00007ffff5f2c1ee in llvm::SCEVExpander::expandCodeFor
(this=0x7fffffffe070, SH=0x671a50, Ty=0x65e9c8) at
/home/grosser/Projekte/llvm/git/lib/Analysis/ScalarEvolutionExpander.cpp:1255
#21902 0x00007ffff5f2edc4 in llvm::SCEVExpander::visitSMaxExpr
(this=0x7fffffffe070, S=0x671c80) at
/home/grosser/Projekte/llvm/git/lib/Analysis/ScalarEvolutionExpander.cpp:1206
#21903 0x00007ffff5f34436 in llvm::SCEVVisitor<llvm::SCEVExpander,
llvm::Value*>::visit (this=0x7fffffffe070, S=0x671c80) at
/home/grosser/Projekte/llvm/git/include/llvm/Analysis/ScalarEvolutionExpressions.h:590
#21904 0x00007ffff5f2c12f in llvm::SCEVExpander::expand (this=0x7fffffffe070,
S=0x671c80) at
/home/grosser/Projekte/llvm/git/lib/Analysis/ScalarEvolutionExpander.cpp:1297
#21905 0x00007ffff5f2c1ee in llvm::SCEVExpander::expandCodeFor
(this=0x7fffffffe070, SH=0x671c80, Ty=0x65e9c8) at
/home/grosser/Projekte/llvm/git/lib/Analysis/ScalarEvolutionExpander.cpp:1255
#21906 0x00007ffff5f2d604 in llvm::SCEVExpander::visitAddExpr
(this=0x7fffffffe070, S=0x6720d0) at
/home/grosser/Projekte/llvm/git/lib/Analysis/ScalarEvolutionExpander.cpp:721
#21907 0x00007ffff5f343e4 in llvm::SCEVVisitor<llvm::SCEVExpander,
llvm::Value*>::visit (this=0x7fffffffe070, S=0x6720d0) at
/home/grosser/Projekte/llvm/git/include/llvm/Analysis/ScalarEvolutionExpressions.h:582
#21908 0x00007ffff5f2c12f in llvm::SCEVExpander::expand (this=0x7fffffffe070,
S=0x6720d0) at
/home/grosser/Projekte/llvm/git/lib/Analysis/ScalarEvolutionExpander.cpp:1297
#21909 0x00007ffff5f2c1ee in llvm::SCEVExpander::expandCodeFor
(this=0x7fffffffe070, SH=0x6720d0, Ty=0x65e9c8) at
/home/grosser/Projekte/llvm/git/lib/Analysis/ScalarEvolutionExpander.cpp:1255
#21910 0x00007ffff5f2d787 in llvm::SCEVExpander::expandCodeFor
(this=0x7fffffffe070, SH=0x6720d0, Ty=0x65e9c8, I=0x666560) at
/home/grosser/Projekte/llvm/git/lib/Analysis/ScalarEvolutionExpander.cpp:1250
#21911 0x00007ffff708b8e9 in RewriteLoopExitValues (this=0x665530, L=0x66f3a0,
Rewriter=...) at
/home/grosser/Projekte/llvm/git/lib/Transforms/Scalar/IndVarSimplify.cpp:301
#21912 0x00007ffff708c234 in runOnLoop (this=0x665530, L=0x66f3a0, LPM=...) at
/home/grosser/Projekte/llvm/git/lib/Transforms/Scalar/IndVarSimplify.cpp:504
#21913 0x00007ffff5eb06dd in llvm::LPPassManager::runOnFunction (this=0x66c670,
F=...) at /home/grosser/Projekte/llvm/git/lib/Analysis/LoopPass.cpp:269
#21914 0x00007ffff572f109 in llvm::FPPassManager::runOnFunction (this=0x6649b0,
F=...) at /home/grosser/Projekte/llvm/git/lib/VMCore/PassManager.cpp:1433
#21915 0x00007ffff572f361 in llvm::FPPassManager::runOnModule (this=0x6649b0,
M=...) at /home/grosser/Projekte/llvm/git/lib/VMCore/PassManager.cpp:1453
#21916 0x00007ffff572ed41 in llvm::MPPassManager::runOnModule (this=0x663bf0,
M=...) at /home/grosser/Projekte/llvm/git/lib/VMCore/PassManager.cpp:1507
#21917 0x00007ffff5731c67 in llvm::PassManagerImpl::run (this=0x6636a0, M=...)
at /home/grosser/Projekte/llvm/git/lib/VMCore/PassManager.cpp:1588
#21918 0x00007ffff5731cc9 in llvm::PassManager::run (this=0x7fffffffe850,
M=...) at /home/grosser/Projekte/llvm/git/lib/VMCore/PassManager.cpp:1631
#21919 0x0000000000437e9d in main (argc=4, argv=0x7fffffffea38) at
/home/grosser/Projekte/llvm/git/tools/opt/opt.cpp:550
----------------------------------------------------------------------------

-- 
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