[llvm-bugs] [Bug 49537] New: Clang trunk crashes at -O2 and -Os
via llvm-bugs
llvm-bugs at lists.llvm.org
Thu Mar 11 06:29:05 PST 2021
https://bugs.llvm.org/show_bug.cgi?id=49537
Bug ID: 49537
Summary: Clang trunk crashes at -O2 and -Os
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.
This valid C code makes clang-trunk crashed at -O2 and -Os. Other released
versions or optimal options handle this case well.
$cat small.c
#include <stdint.h>
int i, a, b, l, j, k;
int16_t c;
void d() {
int8_t e = 9;
uint32_t *m = l;
e -= g(b += l <= i <= m, (c *= 4) != 0, k *= l | e % k || 6 % b);
-*m &(c -= b) ? l ^= k : (j += e) || (k = 0);
}
void n(int64_t o) {
int p;
int64_t *q;
int64_t *r = &q;
int64_t *s = &q;
for (; *s <= 2; *s += 1) {
d();
for (p = 6; p;)
;
}
int16_t f = &p;
for (; *s <= 60;) {
int64_t t;
for (; q;) {
f;
f = t;
}
for (;;) {
if (b || (*q = a))
*r = &o;
o ? c = 0 : 0;
}
}
}
$clang -O2 -w small.c (or -Os)
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:
/media/haoxin/SeagateData/haoxin-data/dut-research/compilers/llvm-project/build-20210310/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/haoxin/haoxin-data/test -resource-dir
/media/haoxin/SeagateData/haoxin-data/dut-research/compilers/llvm-project/build-20210310/lib/clang/13.0.0
-c-isystem /usr/local/include/csmith-2.3.0 -cxx-isystem
/usr/local/include/csmith-2.3.0 -internal-isystem /usr/local/include
-internal-isystem
/media/haoxin/SeagateData/haoxin-data/dut-research/compilers/llvm-project/build-20210310/lib/clang/13.0.0/include
-internal-externc-isystem /usr/include/x86_64-linux-gnu
-internal-externc-isystem /include -internal-externc-isystem /usr/include -O2
-w -fdebug-compilation-dir=/home/haoxin/haoxin-data/test -ferror-limit 19
-fgnuc-version=4.2.1 -fcolor-diagnostics -vectorize-loops -vectorize-slp
-faddrsig -o /tmp/small-8dd8f3.o -x c small.c
1. <eof> parser at end of file
2. Optimizer
#0 0x0000557e0b7e13fc llvm::sys::PrintStackTrace(llvm::raw_ostream&, int)
(/media/haoxin/SeagateData/haoxin-data/dut-research/compilers/llvm-project/build-20210310/bin/clang-13+0x34273fc)
#1 0x0000557e0b7df034 llvm::sys::RunSignalHandlers()
(/media/haoxin/SeagateData/haoxin-data/dut-research/compilers/llvm-project/build-20210310/bin/clang-13+0x3425034)
#2 0x0000557e0b7df1a3 SignalHandler(int) Signals.cpp:0:0
#3 0x00007fee9155f980 __restore_rt
(/lib/x86_64-linux-gnu/libpthread.so.0+0x12980)
#4 0x0000557e0aeb2a31 llvm::BasicBlock::getTerminator() const
(/media/haoxin/SeagateData/haoxin-data/dut-research/compilers/llvm-project/build-20210310/bin/clang-13+0x2af8a31)
#5 0x0000557e0a872a3d llvm::LoopBase<llvm::BasicBlock,
llvm::Loop>::getExitBlocks(llvm::SmallVectorImpl<llvm::BasicBlock*>&) const
(/media/haoxin/SeagateData/haoxin-data/dut-research/compilers/llvm-project/build-20210310/bin/clang-13+0x24b8a3d)
#6 0x0000557e0a7699c3
llvm::isPotentiallyReachableFromMany(llvm::SmallVectorImpl<llvm::BasicBlock*>&,
llvm::BasicBlock*, llvm::SmallPtrSetImpl<llvm::BasicBlock*> const*,
llvm::DominatorTree const*, llvm::LoopInfo const*)
(/media/haoxin/SeagateData/haoxin-data/dut-research/compilers/llvm-project/build-20210310/bin/clang-13+0x23af9c3)
#7 0x0000557e0a76a447 llvm::isPotentiallyReachable(llvm::Instruction const*,
llvm::Instruction const*, llvm::SmallPtrSetImpl<llvm::BasicBlock*> const*,
llvm::DominatorTree const*, llvm::LoopInfo const*)
(/media/haoxin/SeagateData/haoxin-data/dut-research/compilers/llvm-project/build-20210310/bin/clang-13+0x23b0447)
#8 0x0000557e0a750fac
llvm::BasicAAResult::isValueEqualInPotentialCycles(llvm::Value const*,
llvm::Value const*)
(/media/haoxin/SeagateData/haoxin-data/dut-research/compilers/llvm-project/build-20210310/bin/clang-13+0x2396fac)
#9 0x0000557e0a75879d llvm::BasicAAResult::aliasCheck(llvm::Value const*,
llvm::LocationSize, llvm::AAMDNodes const&, llvm::Value const*,
llvm::LocationSize, llvm::AAMDNodes const&, llvm::AAQueryInfo&)
(/media/haoxin/SeagateData/haoxin-data/dut-research/compilers/llvm-project/build-20210310/bin/clang-13+0x239e79d)
#10 0x0000557e0a7590bb llvm::BasicAAResult::alias(llvm::MemoryLocation const&,
llvm::MemoryLocation const&, llvm::AAQueryInfo&)
(/media/haoxin/SeagateData/haoxin-data/dut-research/compilers/llvm-project/build-20210310/bin/clang-13+0x239f0bb)
#11 0x0000557e0a72dbfb llvm::AAResults::alias(llvm::MemoryLocation const&,
llvm::MemoryLocation const&, llvm::AAQueryInfo&)
(/media/haoxin/SeagateData/haoxin-data/dut-research/compilers/llvm-project/build-20210310/bin/clang-13+0x2373bfb)
#12 0x0000557e0a759fd2 llvm::BasicAAResult::aliasPHI(llvm::PHINode const*,
llvm::LocationSize, llvm::AAMDNodes const&, llvm::Value const*,
llvm::LocationSize, llvm::AAMDNodes const&, llvm::AAQueryInfo&)
(/media/haoxin/SeagateData/haoxin-data/dut-research/compilers/llvm-project/build-20210310/bin/clang-13+0x239ffd2)
#13 0x0000557e0a7584b1 llvm::BasicAAResult::aliasCheckRecursive(llvm::Value
const*, llvm::LocationSize, llvm::AAMDNodes const&, llvm::Value const*,
llvm::LocationSize, llvm::AAMDNodes const&, llvm::AAQueryInfo&, llvm::Value
const*, llvm::Value const*)
(/media/haoxin/SeagateData/haoxin-data/dut-research/compilers/llvm-project/build-20210310/bin/clang-13+0x239e4b1)
#14 0x0000557e0a758b14 llvm::BasicAAResult::aliasCheck(llvm::Value const*,
llvm::LocationSize, llvm::AAMDNodes const&, llvm::Value const*,
llvm::LocationSize, llvm::AAMDNodes const&, llvm::AAQueryInfo&)
(/media/haoxin/SeagateData/haoxin-data/dut-research/compilers/llvm-project/build-20210310/bin/clang-13+0x239eb14)
#15 0x0000557e0a7590bb llvm::BasicAAResult::alias(llvm::MemoryLocation const&,
llvm::MemoryLocation const&, llvm::AAQueryInfo&)
(/media/haoxin/SeagateData/haoxin-data/dut-research/compilers/llvm-project/build-20210310/bin/clang-13+0x239f0bb)
#16 0x0000557e0a72dbfb llvm::AAResults::alias(llvm::MemoryLocation const&,
llvm::MemoryLocation const&, llvm::AAQueryInfo&)
(/media/haoxin/SeagateData/haoxin-data/dut-research/compilers/llvm-project/build-20210310/bin/clang-13+0x2373bfb)
#17 0x0000557e0a72fae2 llvm::AAResults::getModRefInfo(llvm::StoreInst const*,
llvm::MemoryLocation const&, llvm::AAQueryInfo&)
(/media/haoxin/SeagateData/haoxin-data/dut-research/compilers/llvm-project/build-20210310/bin/clang-13+0x2375ae2)
#18 0x0000557e0a72fc8e llvm::AAResults::getModRefInfo(llvm::StoreInst const*,
llvm::MemoryLocation const&)
(/media/haoxin/SeagateData/haoxin-data/dut-research/compilers/llvm-project/build-20210310/bin/clang-13+0x2375c8e)
#19 0x0000557e0a850ffa llvm::FindAvailablePtrLoadStore(llvm::Value*,
llvm::Type*, bool, llvm::BasicBlock*,
llvm::ilist_iterator<llvm::ilist_detail::node_options<llvm::Instruction, true,
false, void>, false, false>&, unsigned int, llvm::AAResults*, bool*, unsigned
int*)
(/media/haoxin/SeagateData/haoxin-data/dut-research/compilers/llvm-project/build-20210310/bin/clang-13+0x2496ffa)
#20 0x0000557e0b53a0b6
llvm::JumpThreadingPass::simplifyPartiallyRedundantLoad(llvm::LoadInst*)
(.part.786) JumpThreading.cpp:0:0
#21 0x0000557e0b5406f7 llvm::JumpThreadingPass::processBlock(llvm::BasicBlock*)
(/media/haoxin/SeagateData/haoxin-data/dut-research/compilers/llvm-project/build-20210310/bin/clang-13+0x31866f7)
#22 0x0000557e0b54131e llvm::JumpThreadingPass::runImpl(llvm::Function&,
llvm::TargetLibraryInfo*, llvm::LazyValueInfo*, llvm::AAResults*,
llvm::DomTreeUpdater*, bool, std::unique_ptr<llvm::BlockFrequencyInfo,
std::default_delete<llvm::BlockFrequencyInfo> >,
std::unique_ptr<llvm::BranchProbabilityInfo,
std::default_delete<llvm::BranchProbabilityInfo> >)
(/media/haoxin/SeagateData/haoxin-data/dut-research/compilers/llvm-project/build-20210310/bin/clang-13+0x318731e)
#23 0x0000557e0b5427b4 llvm::JumpThreadingPass::run(llvm::Function&,
llvm::AnalysisManager<llvm::Function>&)
(/media/haoxin/SeagateData/haoxin-data/dut-research/compilers/llvm-project/build-20210310/bin/clang-13+0x31887b4)
#24 0x0000557e0c779dc1 llvm::detail::PassModel<llvm::Function,
llvm::JumpThreadingPass, llvm::PreservedAnalyses,
llvm::AnalysisManager<llvm::Function> >::run(llvm::Function&,
llvm::AnalysisManager<llvm::Function>&)
(/media/haoxin/SeagateData/haoxin-data/dut-research/compilers/llvm-project/build-20210310/bin/clang-13+0x43bfdc1)
#25 0x0000557e0afe9c05 llvm::PassManager<llvm::Function,
llvm::AnalysisManager<llvm::Function> >::run(llvm::Function&,
llvm::AnalysisManager<llvm::Function>&)
(/media/haoxin/SeagateData/haoxin-data/dut-research/compilers/llvm-project/build-20210310/bin/clang-13+0x2c2fc05)
#26 0x0000557e096902b1 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>&)
(/media/haoxin/SeagateData/haoxin-data/dut-research/compilers/llvm-project/build-20210310/bin/clang-13+0x12d62b1)
#27 0x0000557e0a79a9b8
llvm::CGSCCToFunctionPassAdaptor::run(llvm::LazyCallGraph::SCC&,
llvm::AnalysisManager<llvm::LazyCallGraph::SCC, llvm::LazyCallGraph&>&,
llvm::LazyCallGraph&, llvm::CGSCCUpdateResult&)
(/media/haoxin/SeagateData/haoxin-data/dut-research/compilers/llvm-project/build-20210310/bin/clang-13+0x23e09b8)
#28 0x0000557e09690c01 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&)
(/media/haoxin/SeagateData/haoxin-data/dut-research/compilers/llvm-project/build-20210310/bin/clang-13+0x12d6c01)
#29 0x0000557e0a792fda 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&)
(/media/haoxin/SeagateData/haoxin-data/dut-research/compilers/llvm-project/build-20210310/bin/clang-13+0x23d8fda)
#30 0x0000557e0b0e9a31 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&)
(/media/haoxin/SeagateData/haoxin-data/dut-research/compilers/llvm-project/build-20210310/bin/clang-13+0x2d2fa31)
#31 0x0000557e0a796a56
llvm::DevirtSCCRepeatedPass::run(llvm::LazyCallGraph::SCC&,
llvm::AnalysisManager<llvm::LazyCallGraph::SCC, llvm::LazyCallGraph&>&,
llvm::LazyCallGraph&, llvm::CGSCCUpdateResult&)
(/media/haoxin/SeagateData/haoxin-data/dut-research/compilers/llvm-project/build-20210310/bin/clang-13+0x23dca56)
#32 0x0000557e0b0e99f1 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&)
(/media/haoxin/SeagateData/haoxin-data/dut-research/compilers/llvm-project/build-20210310/bin/clang-13+0x2d2f9f1)
#33 0x0000557e0a7949a7
llvm::ModuleToPostOrderCGSCCPassAdaptor::run(llvm::Module&,
llvm::AnalysisManager<llvm::Module>&)
(/media/haoxin/SeagateData/haoxin-data/dut-research/compilers/llvm-project/build-20210310/bin/clang-13+0x23da9a7)
#34 0x0000557e0b0e9a71 llvm::detail::PassModel<llvm::Module,
llvm::ModuleToPostOrderCGSCCPassAdaptor, llvm::PreservedAnalyses,
llvm::AnalysisManager<llvm::Module> >::run(llvm::Module&,
llvm::AnalysisManager<llvm::Module>&)
(/media/haoxin/SeagateData/haoxin-data/dut-research/compilers/llvm-project/build-20210310/bin/clang-13+0x2d2fa71)
#35 0x0000557e0afe8015 llvm::PassManager<llvm::Module,
llvm::AnalysisManager<llvm::Module> >::run(llvm::Module&,
llvm::AnalysisManager<llvm::Module>&)
(/media/haoxin/SeagateData/haoxin-data/dut-research/compilers/llvm-project/build-20210310/bin/clang-13+0x2c2e015)
#36 0x0000557e0b0ec79f llvm::ModuleInlinerWrapperPass::run(llvm::Module&,
llvm::AnalysisManager<llvm::Module>&)
(/media/haoxin/SeagateData/haoxin-data/dut-research/compilers/llvm-project/build-20210310/bin/clang-13+0x2d3279f)
#37 0x0000557e0c77b611 llvm::detail::PassModel<llvm::Module,
llvm::ModuleInlinerWrapperPass, llvm::PreservedAnalyses,
llvm::AnalysisManager<llvm::Module> >::run(llvm::Module&,
llvm::AnalysisManager<llvm::Module>&)
(/media/haoxin/SeagateData/haoxin-data/dut-research/compilers/llvm-project/build-20210310/bin/clang-13+0x43c1611)
#38 0x0000557e0afe8015 llvm::PassManager<llvm::Module,
llvm::AnalysisManager<llvm::Module> >::run(llvm::Module&,
llvm::AnalysisManager<llvm::Module>&)
(/media/haoxin/SeagateData/haoxin-data/dut-research/compilers/llvm-project/build-20210310/bin/clang-13+0x2c2e015)
#39 0x0000557e0baa224b (anonymous
namespace)::EmitAssemblyHelper::EmitAssemblyWithNewPassManager(clang::BackendAction,
std::unique_ptr<llvm::raw_pwrite_stream,
std::default_delete<llvm::raw_pwrite_stream> >) BackendUtil.cpp:0:0
#40 0x0000557e0baa6675 clang::EmitBackendOutput(clang::DiagnosticsEngine&,
clang::HeaderSearchOptions const&, clang::CodeGenOptions const&,
clang::TargetOptions const&, clang::LangOptions const&, llvm::DataLayout
const&, llvm::Module*, clang::BackendAction,
std::unique_ptr<llvm::raw_pwrite_stream,
std::default_delete<llvm::raw_pwrite_stream> >)
(/media/haoxin/SeagateData/haoxin-data/dut-research/compilers/llvm-project/build-20210310/bin/clang-13+0x36ec675)
#41 0x0000557e0c71a736
clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&)
(/media/haoxin/SeagateData/haoxin-data/dut-research/compilers/llvm-project/build-20210310/bin/clang-13+0x4360736)
#42 0x0000557e0d27a229 clang::ParseAST(clang::Sema&, bool, bool)
(/media/haoxin/SeagateData/haoxin-data/dut-research/compilers/llvm-project/build-20210310/bin/clang-13+0x4ec0229)
#43 0x0000557e0c7194f8 clang::CodeGenAction::ExecuteAction()
(/media/haoxin/SeagateData/haoxin-data/dut-research/compilers/llvm-project/build-20210310/bin/clang-13+0x435f4f8)
#44 0x0000557e0c0ad8b9 clang::FrontendAction::Execute()
(/media/haoxin/SeagateData/haoxin-data/dut-research/compilers/llvm-project/build-20210310/bin/clang-13+0x3cf38b9)
#45 0x0000557e0c04b7a1
clang::CompilerInstance::ExecuteAction(clang::FrontendAction&)
(/media/haoxin/SeagateData/haoxin-data/dut-research/compilers/llvm-project/build-20210310/bin/clang-13+0x3c917a1)
#46 0x0000557e0c175b20
clang::ExecuteCompilerInvocation(clang::CompilerInstance*)
(/media/haoxin/SeagateData/haoxin-data/dut-research/compilers/llvm-project/build-20210310/bin/clang-13+0x3dbbb20)
#47 0x0000557e093fd684 cc1_main(llvm::ArrayRef<char const*>, char const*,
void*)
(/media/haoxin/SeagateData/haoxin-data/dut-research/compilers/llvm-project/build-20210310/bin/clang-13+0x1043684)
#48 0x0000557e093f9be7 ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&)
driver.cpp:0:0
#49 0x0000557e093282b7 main
(/media/haoxin/SeagateData/haoxin-data/dut-research/compilers/llvm-project/build-20210310/bin/clang-13+0xf6e2b7)
#50 0x00007fee9016abf7 __libc_start_main
/build/glibc-S9d2JN/glibc-2.27/csu/../csu/libc-start.c:344:0
#51 0x0000557e093f966a _start
(/media/haoxin/SeagateData/haoxin-data/dut-research/compilers/llvm-project/build-20210310/bin/clang-13+0x103f66a)
clang-13: error: unable to execute command: Segmentation fault (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
590ac0a26af4c9f63d5564be8c13b12d409a7fd9)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir:
/home/haoxin/haoxin-data/dut-research/compilers/llvm-project/build-20210310/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-a4f316.c
clang-13: note: diagnostic msg: /tmp/small-a4f316.sh
clang-13: note: diagnostic msg:
********************
$clang -v
clang version 13.0.0 (https://github.com/llvm/llvm-project
590ac0a26af4c9f63d5564be8c13b12d409a7fd9)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir:
/home/haoxin/haoxin-data/dut-research/compilers/llvm-project/build-20210310/bin
Found candidate GCC installation: /usr/lib/gcc/i686-linux-gnu/8
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
Selected GCC installation: /usr/lib/gcc/x86_64-linux-gnu/8
Candidate multilib: .;@m64
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/20210311/71ec8b1a/attachment-0001.html>
More information about the llvm-bugs
mailing list