[llvm-bugs] [Bug 50307] New: clang crashes(-Os) llvm/include/llvm/Analysis/LoopInfo.h:172 ArrayRef<BlockT *> llvm::LoopBase<llvm::BasicBlock, llvm::Loop>::getBlocks() const [BlockT = llvm::BasicBlock, LoopT = llvm::Loop] Assertion `!isInvalid() && "Loop not in a valid state!"' failed
via llvm-bugs
llvm-bugs at lists.llvm.org
Tue May 11 20:25:09 PDT 2021
https://bugs.llvm.org/show_bug.cgi?id=50307
Bug ID: 50307
Summary: clang crashes(-Os)
llvm/include/llvm/Analysis/LoopInfo.h:172
ArrayRef<BlockT *> llvm::LoopBase<llvm::BasicBlock,
llvm::Loop>::getBlocks() const [BlockT =
llvm::BasicBlock, LoopT = llvm::Loop] Assertion
`!isInvalid() && "Loop not in a valid state!"' failed
Product: libraries
Version: trunk
Hardware: All
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.
The following valid C program makes the current trunk of clang crash with -Os.
$cat small.c
#include <stdint.h>
int a, b, c, d;
void func() {
int16_t f = 3;
int32_t *g = a;
uint8_t i = 2;
uint8_t l;
for (;;) {
uint32_t j;
int64_t k;
if (*g)
for (; d <= 2;) {
for (; a;)
for (k = 3; k <= 86; k++) {
c -= j;
j = l;
}
d = 0;
for (; d <= 70; d++)
;
if ((b |= l += f) ? 0 : i)
for (;;)
;
}
}
}
$clang -w -Os small.c
clang-13: /home/tuhaoxin/compilers/llvm
project/llvm/include/llvm/Analysis/LoopInfo.h:172: ArrayRef<BlockT *>
llvm::LoopBase<llvm::BasicBlock, llvm::Loop>::getBlocks() const [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/tuhaoxin/compilers/llvm-project/build/bin/clang-13 -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 -munwind-tables
-target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb
-fcoverage-compilation-dir=/home/tuhaoxin/dut-research/covsmith-test/20210502
-resource-dir /home/tuhaoxin/compilers/llvm-project/build/lib/clang/13.0.0
-c-isystem /usr/local/include/csmith-2.4.0 -cxx-isystem
/usr/local/include/csmith-2.4.0 -internal-isystem
/home/tuhaoxin/compilers/llvm-project/build/lib/clang/13.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 -Os
-w -fdebug-compilation-dir=/home/tuhaoxin/dut-research/covsmith-test/20210502
-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-3596da.o
-x c small.c
1. <eof> parser at end of file
2. Optimizer
#0 0x0000000002a8bbd3 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int)
(/home/tuhaoxin/compilers/llvm-project/build/bin/clang-13+0x2a8bbd3)
#1 0x0000000002a8991e llvm::sys::RunSignalHandlers()
(/home/tuhaoxin/compilers/llvm-project/build/bin/clang-13+0x2a8991e)
#2 0x0000000002a8bf5f SignalHandler(int) Signals.cpp:0:0
#3 0x00007f3253f0b3c0 __restore_rt
(/lib/x86_64-linux-gnu/libpthread.so.0+0x153c0)
#4 0x00007f32539a018b raise
/build/glibc-eX1tMB/glibc-2.31/signal/../sysdeps/unix/sysv/linux/raise.c:51:1
#5 0x00007f325397f859 abort /build/glibc-eX1tMB/glibc-2.31/stdlib/abort.c:81:7
#6 0x00007f325397f729 get_sysdep_segment_value
/build/glibc-eX1tMB/glibc-2.31/intl/loadmsgcat.c:509:8
#7 0x00007f325397f729 _nl_load_domain
/build/glibc-eX1tMB/glibc-2.31/intl/loadmsgcat.c:970:34
#8 0x00007f3253990f36 (/lib/x86_64-linux-gnu/libc.so.6+0x36f36)
#9 0x0000000001cd0bfb llvm::ScalarEvolution::computeLoopDisposition(llvm::SCEV
const*, llvm::Loop const*)
(/home/tuhaoxin/compilers/llvm-project/build/bin/clang-13+0x1cd0bfb)
#10 0x0000000001ccf8c1 llvm::ScalarEvolution::getLoopDisposition(llvm::SCEV
const*, llvm::Loop const*)
(/home/tuhaoxin/compilers/llvm-project/build/bin/clang-13+0x1ccf8c1)
#11 0x0000000001cd090c llvm::ScalarEvolution::computeLoopDisposition(llvm::SCEV
const*, llvm::Loop const*)
(/home/tuhaoxin/compilers/llvm-project/build/bin/clang-13+0x1cd090c)
#12 0x0000000001ccf8c1 llvm::ScalarEvolution::getLoopDisposition(llvm::SCEV
const*, llvm::Loop const*)
(/home/tuhaoxin/compilers/llvm-project/build/bin/clang-13+0x1ccf8c1)
#13 0x0000000001c9b396 llvm::ScalarEvolution::isLoopInvariant(llvm::SCEV
const*, llvm::Loop const*)
(/home/tuhaoxin/compilers/llvm-project/build/bin/clang-13+0x1c9b396)
#14 0x0000000002b54fa6 llvm::rewriteLoopExitValues(llvm::Loop*,
llvm::LoopInfo*, llvm::TargetLibraryInfo*, llvm::ScalarEvolution*,
llvm::TargetTransformInfo const*, llvm::SCEVExpander&, llvm::DominatorTree*,
llvm::ReplaceExitVal, llvm::SmallVector<llvm::WeakTrackingVH, 16u>&)
(/home/tuhaoxin/compilers/llvm-project/build/bin/clang-13+0x2b54fa6)
#15 0x0000000002800554 (anonymous namespace)::IndVarSimplify::run(llvm::Loop*)
IndVarSimplify.cpp:0:0
#16 0x00000000027feaf0 llvm::IndVarSimplifyPass::run(llvm::Loop&,
llvm::AnalysisManager<llvm::Loop, llvm::LoopStandardAnalysisResults&>&,
llvm::LoopStandardAnalysisResults&, llvm::LPMUpdater&)
(/home/tuhaoxin/compilers/llvm-project/build/bin/clang-13+0x27feaf0)
#17 0x0000000003a7bcfd 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/tuhaoxin/compilers/llvm-project/build/bin/clang-13+0x3a7bcfd)
#18 0x0000000003b539ff 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/tuhaoxin/compilers/llvm-project/build/bin/clang-13+0x3b539ff)
#19 0x0000000003b53766 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/tuhaoxin/compilers/llvm-project/build/bin/clang-13+0x3b53766)
#20 0x0000000003b52e58 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/tuhaoxin/compilers/llvm-project/build/bin/clang-13+0x3b52e58)
#21 0x0000000003a70c7d llvm::detail::PassModel<llvm::Loop,
llvm::PassManager<llvm::Loop, llvm::AnalysisManager<llvm::Loop,
llvm::LoopStandardAnalysisResults&>, llvm::LoopStandardAnalysisResults&,
llvm::LPMUpdater&>, 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/tuhaoxin/compilers/llvm-project/build/bin/clang-13+0x3a70c7d)
#22 0x0000000003b54b8b llvm::FunctionToLoopPassAdaptor::run(llvm::Function&,
llvm::AnalysisManager<llvm::Function>&)
(/home/tuhaoxin/compilers/llvm-project/build/bin/clang-13+0x3b54b8b)
#23 0x0000000003a7c95d llvm::detail::PassModel<llvm::Function,
llvm::FunctionToLoopPassAdaptor, llvm::PreservedAnalyses,
llvm::AnalysisManager<llvm::Function> >::run(llvm::Function&,
llvm::AnalysisManager<llvm::Function>&)
(/home/tuhaoxin/compilers/llvm-project/build/bin/clang-13+0x3a7c95d)
#24 0x000000000230e481 llvm::PassManager<llvm::Function,
llvm::AnalysisManager<llvm::Function> >::run(llvm::Function&,
llvm::AnalysisManager<llvm::Function>&)
(/home/tuhaoxin/compilers/llvm-project/build/bin/clang-13+0x230e481)
#25 0x0000000000c2b45d 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/tuhaoxin/compilers/llvm-project/build/bin/clang-13+0xc2b45d)
#26 0x0000000001b29980
llvm::CGSCCToFunctionPassAdaptor::run(llvm::LazyCallGraph::SCC&,
llvm::AnalysisManager<llvm::LazyCallGraph::SCC, llvm::LazyCallGraph&>&,
llvm::LazyCallGraph&, llvm::CGSCCUpdateResult&)
(/home/tuhaoxin/compilers/llvm-project/build/bin/clang-13+0x1b29980)
#27 0x0000000000c2d0bd 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/tuhaoxin/compilers/llvm-project/build/bin/clang-13+0xc2d0bd)
#28 0x0000000001b241b1 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/tuhaoxin/compilers/llvm-project/build/bin/clang-13+0x1b241b1)
#29 0x000000000241442d 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/tuhaoxin/compilers/llvm-project/build/bin/clang-13+0x241442d)
#30 0x0000000001b27f4c
llvm::DevirtSCCRepeatedPass::run(llvm::LazyCallGraph::SCC&,
llvm::AnalysisManager<llvm::LazyCallGraph::SCC, llvm::LazyCallGraph&>&,
llvm::LazyCallGraph&, llvm::CGSCCUpdateResult&)
(/home/tuhaoxin/compilers/llvm-project/build/bin/clang-13+0x1b27f4c)
#31 0x000000000241490d 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/tuhaoxin/compilers/llvm-project/build/bin/clang-13+0x241490d)
#32 0x0000000001b26653
llvm::ModuleToPostOrderCGSCCPassAdaptor::run(llvm::Module&,
llvm::AnalysisManager<llvm::Module>&)
(/home/tuhaoxin/compilers/llvm-project/build/bin/clang-13+0x1b26653)
#33 0x000000000241475d llvm::detail::PassModel<llvm::Module,
llvm::ModuleToPostOrderCGSCCPassAdaptor, llvm::PreservedAnalyses,
llvm::AnalysisManager<llvm::Module> >::run(llvm::Module&,
llvm::AnalysisManager<llvm::Module>&)
(/home/tuhaoxin/compilers/llvm-project/build/bin/clang-13+0x241475d)
#34 0x000000000230d6a4 llvm::PassManager<llvm::Module,
llvm::AnalysisManager<llvm::Module> >::run(llvm::Module&,
llvm::AnalysisManager<llvm::Module>&)
(/home/tuhaoxin/compilers/llvm-project/build/bin/clang-13+0x230d6a4)
#35 0x00000000024120ab llvm::ModuleInlinerWrapperPass::run(llvm::Module&,
llvm::AnalysisManager<llvm::Module>&)
(/home/tuhaoxin/compilers/llvm-project/build/bin/clang-13+0x24120ab)
#36 0x0000000003a8088d llvm::detail::PassModel<llvm::Module,
llvm::ModuleInlinerWrapperPass, llvm::PreservedAnalyses,
llvm::AnalysisManager<llvm::Module> >::run(llvm::Module&,
llvm::AnalysisManager<llvm::Module>&)
(/home/tuhaoxin/compilers/llvm-project/build/bin/clang-13+0x3a8088d)
#37 0x000000000230d6a4 llvm::PassManager<llvm::Module,
llvm::AnalysisManager<llvm::Module> >::run(llvm::Module&,
llvm::AnalysisManager<llvm::Module>&)
(/home/tuhaoxin/compilers/llvm-project/build/bin/clang-13+0x230d6a4)
#38 0x0000000002d1107e (anonymous
namespace)::EmitAssemblyHelper::EmitAssemblyWithNewPassManager(clang::BackendAction,
std::unique_ptr<llvm::raw_pwrite_stream,
std::default_delete<llvm::raw_pwrite_stream> >) BackendUtil.cpp:0:0
#39 0x0000000002d0a7dd 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/tuhaoxin/compilers/llvm-project/build/bin/clang-13+0x2d0a7dd)
#40 0x00000000039c0218
clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&)
(/home/tuhaoxin/compilers/llvm-project/build/bin/clang-13+0x39c0218)
#41 0x00000000043721d3 clang::ParseAST(clang::Sema&, bool, bool)
(/home/tuhaoxin/compilers/llvm-project/build/bin/clang-13+0x43721d3)
#42 0x0000000003340e73 clang::FrontendAction::Execute()
(/home/tuhaoxin/compilers/llvm-project/build/bin/clang-13+0x3340e73)
#43 0x00000000032b1883
clang::CompilerInstance::ExecuteAction(clang::FrontendAction&)
(/home/tuhaoxin/compilers/llvm-project/build/bin/clang-13+0x32b1883)
#44 0x00000000033f0d52
clang::ExecuteCompilerInvocation(clang::CompilerInstance*)
(/home/tuhaoxin/compilers/llvm-project/build/bin/clang-13+0x33f0d52)
#45 0x00000000009db5c8 cc1_main(llvm::ArrayRef<char const*>, char const*,
void*) (/home/tuhaoxin/compilers/llvm-project/build/bin/clang-13+0x9db5c8)
#46 0x00000000009d93cd ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&)
driver.cpp:0:0
#47 0x00000000009d90b4 main
(/home/tuhaoxin/compilers/llvm-project/build/bin/clang-13+0x9d90b4)
#48 0x00007f32539810b3 __libc_start_main
/build/glibc-eX1tMB/glibc-2.31/csu/../csu/libc-start.c:342:3
#49 0x00000000009d606e _start
(/home/tuhaoxin/compilers/llvm-project/build/bin/clang-13+0x9d606e)
clang-13: error: unable to execute command: Aborted (core dumped)
clang-13: error: clang frontend command failed due to signal (use -v to see
invocation)
clang version 13.0.0 (https://github.com/llvm/llvm-project.git
ea64200b6197d8db97a11db15a5906fc1eb5ef4a)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /home/tuhaoxin/compilers/llvm-project/build/bin
clang-13: note: diagnostic msg:
********************
PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT:
Preprocessed source(s) and associated run script(s) are located at:
clang-13: note: diagnostic msg: /tmp/small-4d4bec.c
clang-13: note: diagnostic msg: /tmp/small-4d4bec.sh
clang-13: note: diagnostic msg:
********************
$clang -v
clang version 13.0.0 (https://github.com/llvm/llvm-project.git
ea64200b6197d8db97a11db15a5906fc1eb5ef4a)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /home/tuhaoxin/compilers/llvm-project/build/bin
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.8
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.8.5
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/5
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/5.5.0
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/7
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/7.5.0
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/8
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/9
Selected GCC installation: /usr/lib/gcc/x86_64-linux-gnu/9
Candidate multilib: .;@m64
Candidate multilib: 32;@m32
Candidate multilib: x32;@mx32
Selected multilib: .;@m64
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/20210512/2a110889/attachment-0001.html>
More information about the llvm-bugs
mailing list