[llvm-bugs] [Bug 52018] New: crash on llvm/include/llvm/Analysis/LoopInfoImpl.h:36: void llvm::LoopBase<N, M>::getExitingBlocks(llvm::SmallVectorImpl<BlockT*>&) const [with BlockT = llvm::BasicBlock; LoopT = llvm::Loop]: Assertion `!isInvalid() && "Loop not in a valid state!"' failed

via llvm-bugs llvm-bugs at lists.llvm.org
Wed Sep 29 22:01:16 PDT 2021


https://bugs.llvm.org/show_bug.cgi?id=52018

            Bug ID: 52018
           Summary: crash on llvm/include/llvm/Analysis/LoopInfoImpl.h:36:
                    void llvm::LoopBase<N,
                    M>::getExitingBlocks(llvm::SmallVectorImpl<BlockT*>&)
                    const [with BlockT = llvm::BasicBlock; LoopT =
                    llvm::Loop]: Assertion `!isInvalid() && "Loop not in a
                    valid state!"' failed
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: Scalar Optimizations
          Assignee: unassignedbugs at nondot.org
          Reporter: haoxintu at gmail.com
                CC: llvm-bugs at lists.llvm.org

Hi all.

This appears to be a recent regression issue.

$cat small.c
#include <stdint.h>
int a, b;
int c() {
  uint32_t d;
  int16_t e = 0;
  uint32_t *f = &d;
  for (;;)
    if (*f -= e) {
      uint64_t g;
      for (e = 3; e <= 7; e++) {
        int64_t i;
        if (d ^= a)
          return 0;
        for (b = 7; b <= 8; b++)
          ;
      }
    }
}

$clang -O3 small.c
clang-14:
/home/haoxin/haoxin-data/compilers/llvm-project/llvm/include/llvm/Analysis/LoopInfoImpl.h:36:
void llvm::LoopBase<N, M>::getExitingBlocks(llvm::SmallVectorImpl<BlockT*>&)
const [with BlockT = llvm::BasicBlock; LoopT = llvm::Loop]: Assertion
`!isInvalid() && "Loop not in a valid state!"' failed.
PLEASE submit a bug report to https://bugs.llvm.org/ and include the crash
backtrace, preprocessed source, and associated run script.
Stack dump:
0.      Program arguments:
/home/haoxin/haoxin-data/compilers/llvm-project/build/bin/clang-14 -cc1 -triple
x86_64-unknown-linux-gnu -emit-obj --mrelax-relocations -disable-free
-main-file-name small.c -mrelocation-model static -mframe-pointer=none
-fmath-errno -fno-rounding-math -mconstructor-aliases -funwind-tables=2
-target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb
-fcoverage-compilation-dir=/home/haoxin/haoxin-data/dut-research/covsmith-test/20210819/23
-resource-dir
/home/haoxin/haoxin-data/compilers/llvm-project/build/lib/clang/14.0.0
-internal-isystem
/home/haoxin/haoxin-data/compilers/llvm-project/build/lib/clang/14.0.0/include
-internal-isystem /usr/local/include -internal-isystem
/usr/lib/gcc/x86_64-linux-gnu/9/../../../../x86_64-linux-gnu/include
-internal-externc-isystem /usr/include/x86_64-linux-gnu
-internal-externc-isystem /include -internal-externc-isystem /usr/include -O3
-fdebug-compilation-dir=/home/haoxin/haoxin-data/dut-research/covsmith-test/20210819/23
-ferror-limit 19 -fgnuc-version=4.2.1 -fcolor-diagnostics -vectorize-loops
-vectorize-slp -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /tmp/small-d6027f.o
-x c small.c
1.      <eof> parser at end of file
2.      Optimizer
 #0 0x000055c4dc4c24b4 PrintStackTraceSignalHandler(void*) Signals.cpp:0:0
 #1 0x000055c4dc4bfbce SignalHandler(int) Signals.cpp:0:0
 #2 0x00007f31386323c0 __restore_rt
(/lib/x86_64-linux-gnu/libpthread.so.0+0x153c0)
 #3 0x00007f31380d118b raise
/build/glibc-eX1tMB/glibc-2.31/signal/../sysdeps/unix/sysv/linux/raise.c:51:1
 #4 0x00007f31380b0859 abort /build/glibc-eX1tMB/glibc-2.31/stdlib/abort.c:81:7
 #5 0x00007f31380b0729 get_sysdep_segment_value
/build/glibc-eX1tMB/glibc-2.31/intl/loadmsgcat.c:509:8
 #6 0x00007f31380b0729 _nl_load_domain
/build/glibc-eX1tMB/glibc-2.31/intl/loadmsgcat.c:970:34
 #7 0x00007f31380c1f36 (/lib/x86_64-linux-gnu/libc.so.6+0x36f36)
 #8 0x000055c4db3517bd
(/home/haoxin/haoxin-data/compilers/llvm-project/build/bin/clang-14+0x2a397bd)
 #9 0x000055c4db415f54
llvm::ScalarEvolution::computeBackedgeTakenCount(llvm::Loop const*, bool)
(/home/haoxin/haoxin-data/compilers/llvm-project/build/bin/clang-14+0x2afdf54)
#10 0x000055c4db416ce2 llvm::ScalarEvolution::getBackedgeTakenInfo(llvm::Loop
const*)
(/home/haoxin/haoxin-data/compilers/llvm-project/build/bin/clang-14+0x2afece2)
#11 0x000055c4db417d80
llvm::ScalarEvolution::getConstantMaxBackedgeTakenCount(llvm::Loop const*)
(/home/haoxin/haoxin-data/compilers/llvm-project/build/bin/clang-14+0x2affd80)
#12 0x000055c4db42716c llvm::ScalarEvolution::getRangeRef(llvm::SCEV const*,
llvm::ScalarEvolution::RangeSignHint)
(/home/haoxin/haoxin-data/compilers/llvm-project/build/bin/clang-14+0x2b0f16c)
#13 0x000055c4db42693f llvm::ScalarEvolution::getRangeRef(llvm::SCEV const*,
llvm::ScalarEvolution::RangeSignHint)
(/home/haoxin/haoxin-data/compilers/llvm-project/build/bin/clang-14+0x2b0e93f)
#14 0x000055c4db42693f llvm::ScalarEvolution::getRangeRef(llvm::SCEV const*,
llvm::ScalarEvolution::RangeSignHint)
(/home/haoxin/haoxin-data/compilers/llvm-project/build/bin/clang-14+0x2b0e93f)
#15 0x000055c4db42603c llvm::ScalarEvolution::getRangeRef(llvm::SCEV const*,
llvm::ScalarEvolution::RangeSignHint)
(/home/haoxin/haoxin-data/compilers/llvm-project/build/bin/clang-14+0x2b0e03c)
#16 0x000055c4db43253f llvm::ScalarEvolution::getMinusSCEV(llvm::SCEV const*,
llvm::SCEV const*, llvm::SCEV::NoWrapFlags, unsigned int)
(/home/haoxin/haoxin-data/compilers/llvm-project/build/bin/clang-14+0x2b1a53f)
#17 0x000055c4db41bbf3 llvm::ScalarEvolution::createSCEV(llvm::Value*)
(.part.0) ScalarEvolution.cpp:0:0
#18 0x000055c4db41d18e llvm::ScalarEvolution::getSCEV(llvm::Value*) (.part.0)
ScalarEvolution.cpp:0:0
#19 0x000055c4dc66dc64 (anonymous
namespace)::SimplifyIndvar::simplifyUsers(llvm::PHINode*, llvm::IVVisitor*)
SimplifyIndVar.cpp:0:0
#20 0x000055c4dc66f772 llvm::simplifyUsersOfIV(llvm::PHINode*,
llvm::ScalarEvolution*, llvm::DominatorTree*, llvm::LoopInfo*,
llvm::TargetTransformInfo const*, llvm::SmallVectorImpl<llvm::WeakTrackingVH>&,
llvm::SCEVExpander&, llvm::IVVisitor*)
(/home/haoxin/haoxin-data/compilers/llvm-project/build/bin/clang-14+0x3d57772)
#21 0x000055c4dc1b4c09 (anonymous namespace)::IndVarSimplify::run(llvm::Loop*)
IndVarSimplify.cpp:0:0
#22 0x000055c4dc1b7574 llvm::IndVarSimplifyPass::run(llvm::Loop&,
llvm::AnalysisManager<llvm::Loop, llvm::LoopStandardAnalysisResults&>&,
llvm::LoopStandardAnalysisResults&, llvm::LPMUpdater&)
(/home/haoxin/haoxin-data/compilers/llvm-project/build/bin/clang-14+0x389f574)
#23 0x000055c4dd725826 llvm::detail::PassModel<llvm::Loop,
llvm::IndVarSimplifyPass, llvm::PreservedAnalyses,
llvm::AnalysisManager<llvm::Loop, llvm::LoopStandardAnalysisResults&>,
llvm::LoopStandardAnalysisResults&, llvm::LPMUpdater&>::run(llvm::Loop&,
llvm::AnalysisManager<llvm::Loop, llvm::LoopStandardAnalysisResults&>&,
llvm::LoopStandardAnalysisResults&, llvm::LPMUpdater&)
(/home/haoxin/haoxin-data/compilers/llvm-project/build/bin/clang-14+0x4e0d826)
#24 0x000055c4df5b1ce8 llvm::Optional<llvm::PreservedAnalyses>
llvm::PassManager<llvm::Loop, llvm::AnalysisManager<llvm::Loop,
llvm::LoopStandardAnalysisResults&>, llvm::LoopStandardAnalysisResults&,
llvm::LPMUpdater&>::runSinglePass<llvm::Loop,
std::unique_ptr<llvm::detail::PassConcept<llvm::Loop,
llvm::AnalysisManager<llvm::Loop, llvm::LoopStandardAnalysisResults&>,
llvm::LoopStandardAnalysisResults&, llvm::LPMUpdater&>,
std::default_delete<llvm::detail::PassConcept<llvm::Loop,
llvm::AnalysisManager<llvm::Loop, llvm::LoopStandardAnalysisResults&>,
llvm::LoopStandardAnalysisResults&, llvm::LPMUpdater&> > > >(llvm::Loop&,
std::unique_ptr<llvm::detail::PassConcept<llvm::Loop,
llvm::AnalysisManager<llvm::Loop, llvm::LoopStandardAnalysisResults&>,
llvm::LoopStandardAnalysisResults&, llvm::LPMUpdater&>,
std::default_delete<llvm::detail::PassConcept<llvm::Loop,
llvm::AnalysisManager<llvm::Loop, llvm::LoopStandardAnalysisResults&>,
llvm::LoopStandardAnalysisResults&, llvm::LPMUpdater&> > >&,
llvm::AnalysisManager<llvm::Loop, llvm::LoopStandardAnalysisResults&>&,
llvm::LoopStandardAnalysisResults&, llvm::LPMUpdater&,
llvm::PassInstrumentation&)
(/home/haoxin/haoxin-data/compilers/llvm-project/build/bin/clang-14+0x6c99ce8)
#25 0x000055c4df5b2046 llvm::PassManager<llvm::Loop,
llvm::AnalysisManager<llvm::Loop, llvm::LoopStandardAnalysisResults&>,
llvm::LoopStandardAnalysisResults&,
llvm::LPMUpdater&>::runWithoutLoopNestPasses(llvm::Loop&,
llvm::AnalysisManager<llvm::Loop, llvm::LoopStandardAnalysisResults&>&,
llvm::LoopStandardAnalysisResults&, llvm::LPMUpdater&)
(/home/haoxin/haoxin-data/compilers/llvm-project/build/bin/clang-14+0x6c9a046)
#26 0x000055c4df5b34dd llvm::PassManager<llvm::Loop,
llvm::AnalysisManager<llvm::Loop, llvm::LoopStandardAnalysisResults&>,
llvm::LoopStandardAnalysisResults&, llvm::LPMUpdater&>::run(llvm::Loop&,
llvm::AnalysisManager<llvm::Loop, llvm::LoopStandardAnalysisResults&>&,
llvm::LoopStandardAnalysisResults&, llvm::LPMUpdater&)
(/home/haoxin/haoxin-data/compilers/llvm-project/build/bin/clang-14+0x6c9b4dd)
#27 0x000055c4df5b56c8 llvm::FunctionToLoopPassAdaptor::run(llvm::Function&,
llvm::AnalysisManager<llvm::Function>&)
(/home/haoxin/haoxin-data/compilers/llvm-project/build/bin/clang-14+0x6c9d6c8)
#28 0x000055c4dd721876 llvm::detail::PassModel<llvm::Function,
llvm::FunctionToLoopPassAdaptor, llvm::PreservedAnalyses,
llvm::AnalysisManager<llvm::Function> >::run(llvm::Function&,
llvm::AnalysisManager<llvm::Function>&)
(/home/haoxin/haoxin-data/compilers/llvm-project/build/bin/clang-14+0x4e09876)
#29 0x000055c4dbb9ca56 llvm::PassManager<llvm::Function,
llvm::AnalysisManager<llvm::Function> >::run(llvm::Function&,
llvm::AnalysisManager<llvm::Function>&)
(/home/haoxin/haoxin-data/compilers/llvm-project/build/bin/clang-14+0x3284a56)
#30 0x000055c4d9f67c76 llvm::detail::PassModel<llvm::Function,
llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function> >,
llvm::PreservedAnalyses, llvm::AnalysisManager<llvm::Function>
>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&)
(/home/haoxin/haoxin-data/compilers/llvm-project/build/bin/clang-14+0x164fc76)
#31 0x000055c4db2684cf
llvm::CGSCCToFunctionPassAdaptor::run(llvm::LazyCallGraph::SCC&,
llvm::AnalysisManager<llvm::LazyCallGraph::SCC, llvm::LazyCallGraph&>&,
llvm::LazyCallGraph&, llvm::CGSCCUpdateResult&)
(/home/haoxin/haoxin-data/compilers/llvm-project/build/bin/clang-14+0x29504cf)
#32 0x000055c4d9f689f6 llvm::detail::PassModel<llvm::LazyCallGraph::SCC,
llvm::CGSCCToFunctionPassAdaptor, llvm::PreservedAnalyses,
llvm::AnalysisManager<llvm::LazyCallGraph::SCC, llvm::LazyCallGraph&>,
llvm::LazyCallGraph&, llvm::CGSCCUpdateResult&>::run(llvm::LazyCallGraph::SCC&,
llvm::AnalysisManager<llvm::LazyCallGraph::SCC, llvm::LazyCallGraph&>&,
llvm::LazyCallGraph&, llvm::CGSCCUpdateResult&)
(/home/haoxin/haoxin-data/compilers/llvm-project/build/bin/clang-14+0x16509f6)
#33 0x000055c4db25f9db llvm::PassManager<llvm::LazyCallGraph::SCC,
llvm::AnalysisManager<llvm::LazyCallGraph::SCC, llvm::LazyCallGraph&>,
llvm::LazyCallGraph&, llvm::CGSCCUpdateResult&>::run(llvm::LazyCallGraph::SCC&,
llvm::AnalysisManager<llvm::LazyCallGraph::SCC, llvm::LazyCallGraph&>&,
llvm::LazyCallGraph&, llvm::CGSCCUpdateResult&)
(/home/haoxin/haoxin-data/compilers/llvm-project/build/bin/clang-14+0x29479db)
#34 0x000055c4dbcc5c16 llvm::detail::PassModel<llvm::LazyCallGraph::SCC,
llvm::PassManager<llvm::LazyCallGraph::SCC,
llvm::AnalysisManager<llvm::LazyCallGraph::SCC, llvm::LazyCallGraph&>,
llvm::LazyCallGraph&, llvm::CGSCCUpdateResult&>, llvm::PreservedAnalyses,
llvm::AnalysisManager<llvm::LazyCallGraph::SCC, llvm::LazyCallGraph&>,
llvm::LazyCallGraph&, llvm::CGSCCUpdateResult&>::run(llvm::LazyCallGraph::SCC&,
llvm::AnalysisManager<llvm::LazyCallGraph::SCC, llvm::LazyCallGraph&>&,
llvm::LazyCallGraph&, llvm::CGSCCUpdateResult&)
(/home/haoxin/haoxin-data/compilers/llvm-project/build/bin/clang-14+0x33adc16)
#35 0x000055c4db264074
llvm::DevirtSCCRepeatedPass::run(llvm::LazyCallGraph::SCC&,
llvm::AnalysisManager<llvm::LazyCallGraph::SCC, llvm::LazyCallGraph&>&,
llvm::LazyCallGraph&, llvm::CGSCCUpdateResult&)
(/home/haoxin/haoxin-data/compilers/llvm-project/build/bin/clang-14+0x294c074)
#36 0x000055c4dbcc5bc6 llvm::detail::PassModel<llvm::LazyCallGraph::SCC,
llvm::DevirtSCCRepeatedPass, llvm::PreservedAnalyses,
llvm::AnalysisManager<llvm::LazyCallGraph::SCC, llvm::LazyCallGraph&>,
llvm::LazyCallGraph&, llvm::CGSCCUpdateResult&>::run(llvm::LazyCallGraph::SCC&,
llvm::AnalysisManager<llvm::LazyCallGraph::SCC, llvm::LazyCallGraph&>&,
llvm::LazyCallGraph&, llvm::CGSCCUpdateResult&)
(/home/haoxin/haoxin-data/compilers/llvm-project/build/bin/clang-14+0x33adbc6)
#37 0x000055c4db261d43
llvm::ModuleToPostOrderCGSCCPassAdaptor::run(llvm::Module&,
llvm::AnalysisManager<llvm::Module>&)
(/home/haoxin/haoxin-data/compilers/llvm-project/build/bin/clang-14+0x2949d43)
#38 0x000055c4dbcc5c66 llvm::detail::PassModel<llvm::Module,
llvm::ModuleToPostOrderCGSCCPassAdaptor, llvm::PreservedAnalyses,
llvm::AnalysisManager<llvm::Module> >::run(llvm::Module&,
llvm::AnalysisManager<llvm::Module>&)
(/home/haoxin/haoxin-data/compilers/llvm-project/build/bin/clang-14+0x33adc66)
#39 0x000055c4dbb98f8f llvm::PassManager<llvm::Module,
llvm::AnalysisManager<llvm::Module> >::run(llvm::Module&,
llvm::AnalysisManager<llvm::Module>&)
(/home/haoxin/haoxin-data/compilers/llvm-project/build/bin/clang-14+0x3280f8f)
#40 0x000055c4dbcc8d01 llvm::ModuleInlinerWrapperPass::run(llvm::Module&,
llvm::AnalysisManager<llvm::Module>&)
(/home/haoxin/haoxin-data/compilers/llvm-project/build/bin/clang-14+0x33b0d01)
#41 0x000055c4dd724c26 llvm::detail::PassModel<llvm::Module,
llvm::ModuleInlinerWrapperPass, llvm::PreservedAnalyses,
llvm::AnalysisManager<llvm::Module> >::run(llvm::Module&,
llvm::AnalysisManager<llvm::Module>&)
(/home/haoxin/haoxin-data/compilers/llvm-project/build/bin/clang-14+0x4e0cc26)
#42 0x000055c4dbb98f8f llvm::PassManager<llvm::Module,
llvm::AnalysisManager<llvm::Module> >::run(llvm::Module&,
llvm::AnalysisManager<llvm::Module>&)
(/home/haoxin/haoxin-data/compilers/llvm-project/build/bin/clang-14+0x3280f8f)
#43 0x000055c4dc80f39e (anonymous
namespace)::EmitAssemblyHelper::EmitAssemblyWithNewPassManager(clang::BackendAction,
std::unique_ptr<llvm::raw_pwrite_stream,
std::default_delete<llvm::raw_pwrite_stream> >) BackendUtil.cpp:0:0
#44 0x000055c4dc8145e5 clang::EmitBackendOutput(clang::DiagnosticsEngine&,
clang::HeaderSearchOptions const&, clang::CodeGenOptions const&,
clang::TargetOptions const&, clang::LangOptions const&, llvm::StringRef,
llvm::Module*, clang::BackendAction, std::unique_ptr<llvm::raw_pwrite_stream,
std::default_delete<llvm::raw_pwrite_stream> >)
(/home/haoxin/haoxin-data/compilers/llvm-project/build/bin/clang-14+0x3efc5e5)
#45 0x000055c4dd6bc6bf
clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&)
(/home/haoxin/haoxin-data/compilers/llvm-project/build/bin/clang-14+0x4da46bf)
#46 0x000055c4de403b79 clang::ParseAST(clang::Sema&, bool, bool)
(/home/haoxin/haoxin-data/compilers/llvm-project/build/bin/clang-14+0x5aebb79)
#47 0x000055c4dd6bb1f8 clang::CodeGenAction::ExecuteAction()
(/home/haoxin/haoxin-data/compilers/llvm-project/build/bin/clang-14+0x4da31f8)
#48 0x000055c4dcf38a09 clang::FrontendAction::Execute()
(/home/haoxin/haoxin-data/compilers/llvm-project/build/bin/clang-14+0x4620a09)
#49 0x000055c4dcec989e
clang::CompilerInstance::ExecuteAction(clang::FrontendAction&)
(/home/haoxin/haoxin-data/compilers/llvm-project/build/bin/clang-14+0x45b189e)
#50 0x000055c4dd0184c0
clang::ExecuteCompilerInvocation(clang::CompilerInstance*)
(/home/haoxin/haoxin-data/compilers/llvm-project/build/bin/clang-14+0x47004c0)
#51 0x000055c4d9c8232d cc1_main(llvm::ArrayRef<char const*>, char const*,
void*)
(/home/haoxin/haoxin-data/compilers/llvm-project/build/bin/clang-14+0x136a32d)
#52 0x000055c4d9c7e588 ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&)
driver.cpp:0:0
#53 0x000055c4d9bb2c29 main
(/home/haoxin/haoxin-data/compilers/llvm-project/build/bin/clang-14+0x129ac29)
#54 0x00007f31380b20b3 __libc_start_main
/build/glibc-eX1tMB/glibc-2.31/csu/../csu/libc-start.c:342:3
#55 0x000055c4d9c7e0fe _start
(/home/haoxin/haoxin-data/compilers/llvm-project/build/bin/clang-14+0x13660fe)
clang-14: error: unable to execute command: Aborted (core dumped)
clang-14: error: clang frontend command failed due to signal (use -v to see
invocation)
clang version 14.0.0 (https://github.com/llvm/llvm-project
1380eae590202639d00d459bcacee9817162de60)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /home/haoxin/haoxin-data/compilers/llvm-project/build/bin
clang-14: note: diagnostic msg:
********************

PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT:
Preprocessed source(s) and associated run script(s) are located at:
clang-14: note: diagnostic msg: /tmp/small-6ee7f2.c
clang-14: note: diagnostic msg: /tmp/small-6ee7f2.sh
clang-14: note: diagnostic msg:

********************

Reproduced in Godbolt: https://godbolt.org/z/9eG1b1a7x

Thanks,
Haoxin

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20210930/5271466a/attachment-0001.html>


More information about the llvm-bugs mailing list