[llvm-bugs] [Bug 49784] New: clang crashes at -O1, -O2, and -Os
via llvm-bugs
llvm-bugs at lists.llvm.org
Wed Mar 31 07:12:13 PDT 2021
https://bugs.llvm.org/show_bug.cgi?id=49784
Bug ID: 49784
Summary: clang crashes at -O1, -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 all.
This small.c makes clang crash at -O1, -O2, and -Os on the current trunk of
clang, and the released versions perform well on this case.
$cat small.c
#include <stdint.h>
int a;
void b() {
uint32_t c = 4;
int16_t d;
uint32_t *e = &c;
if ((*e != 0) - (0 >= 0))
;
else {
int16_t *f = &d;
uint32_t **g = &e;
if (*e &= a && *f) {
uint32_t *j;
uint32_t *i = *j;
if (0)
l:
e = i;
if (**g) {
int16_t *m = f;
uint8_t k = *m ?: (*i = k);
goto l;
}
}
}
goto l;
}
$clang -O1 -w small.c
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-20210330/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/dut-research/covsmith-test/report-0331
-resource-dir
/media/haoxin/SeagateData/haoxin-data/dut-research/compilers/llvm-project/build-20210330/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
/usr/lib/gcc/x86_64-linux-gnu/8/../../../../x86_64-linux-gnu/include
-internal-isystem
/media/haoxin/SeagateData/haoxin-data/dut-research/compilers/llvm-project/build-20210330/lib/clang/13.0.0/include
-internal-externc-isystem /usr/include/x86_64-linux-gnu
-internal-externc-isystem /include -internal-externc-isystem /usr/include -O1
-w
-fdebug-compilation-dir=/home/haoxin/haoxin-data/dut-research/covsmith-test/report-0331
-ferror-limit 19 -fgnuc-version=4.2.1 -fcolor-diagnostics -faddrsig
-D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /tmp/small-78c566.o -x c small.c
1. <eof> parser at end of file
2. Optimizer
#0 0x0000560f2b56efcc llvm::sys::PrintStackTrace(llvm::raw_ostream&, int)
(/media/haoxin/SeagateData/haoxin-data/dut-research/compilers/llvm-project/build-20210330/bin/clang-13+0x3481fcc)
#1 0x0000560f2b56cc04 llvm::sys::RunSignalHandlers()
(/media/haoxin/SeagateData/haoxin-data/dut-research/compilers/llvm-project/build-20210330/bin/clang-13+0x347fc04)
#2 0x0000560f2b56cd73 SignalHandler(int) Signals.cpp:0:0
#3 0x00007f3b0011b980 __restore_rt
(/lib/x86_64-linux-gnu/libpthread.so.0+0x12980)
#4 0x0000560f2ac36000 llvm::BasicBlock::getModule() const
(/media/haoxin/SeagateData/haoxin-data/dut-research/compilers/llvm-project/build-20210330/bin/clang-13+0x2b49000)
#5 0x0000560f2a6192cf llvm::MemoryLocation::get(llvm::LoadInst const*)
(/media/haoxin/SeagateData/haoxin-data/dut-research/compilers/llvm-project/build-20210330/bin/clang-13+0x252c2cf)
#6 0x0000560f2a4bebe8 llvm::AliasSetTracker::add(llvm::LoadInst*)
(/media/haoxin/SeagateData/haoxin-data/dut-research/compilers/llvm-project/build-20210330/bin/clang-13+0x23d1be8)
#7 0x0000560f2b2ce15c collectPromotionCandidates(llvm::MemorySSA*,
llvm::AAResults*, llvm::Loop*,
llvm::SmallVectorImpl<llvm::Instruction*>&)::'lambda0'(llvm::Instruction*)::operator()(llvm::Instruction*)
const LICM.cpp:0:0
#8 0x0000560f2b2dde54 (anonymous
namespace)::LoopInvariantCodeMotion::runOnLoop(llvm::Loop*, llvm::AAResults*,
llvm::LoopInfo*, llvm::DominatorTree*, llvm::BlockFrequencyInfo*,
llvm::TargetLibraryInfo*, llvm::TargetTransformInfo*, llvm::ScalarEvolution*,
llvm::MemorySSA*, llvm::OptimizationRemarkEmitter*) (.part.903) LICM.cpp:0:0
#9 0x0000560f2b2de5c9 llvm::LICMPass::run(llvm::Loop&,
llvm::AnalysisManager<llvm::Loop, llvm::LoopStandardAnalysisResults&>&,
llvm::LoopStandardAnalysisResults&, llvm::LPMUpdater&)
(/media/haoxin/SeagateData/haoxin-data/dut-research/compilers/llvm-project/build-20210330/bin/clang-13+0x31f15c9)
#10 0x0000560f2c519681 llvm::detail::PassModel<llvm::Loop, llvm::LICMPass,
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&)
(/media/haoxin/SeagateData/haoxin-data/dut-research/compilers/llvm-project/build-20210330/bin/clang-13+0x442c681)
#11 0x0000560f2c682dc6 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&) (.constprop.159) LoopPassManager.cpp:0:0
#12 0x0000560f2c684240 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&)
(/media/haoxin/SeagateData/haoxin-data/dut-research/compilers/llvm-project/build-20210330/bin/clang-13+0x4597240)
#13 0x0000560f2c684434 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&)
(/media/haoxin/SeagateData/haoxin-data/dut-research/compilers/llvm-project/build-20210330/bin/clang-13+0x4597434)
#14 0x0000560f2c68640d llvm::FunctionToLoopPassAdaptor::run(llvm::Function&,
llvm::AnalysisManager<llvm::Function>&)
(/media/haoxin/SeagateData/haoxin-data/dut-research/compilers/llvm-project/build-20210330/bin/clang-13+0x459940d)
#15 0x0000560f2c518f31 llvm::detail::PassModel<llvm::Function,
llvm::FunctionToLoopPassAdaptor, llvm::PreservedAnalyses,
llvm::AnalysisManager<llvm::Function> >::run(llvm::Function&,
llvm::AnalysisManager<llvm::Function>&)
(/media/haoxin/SeagateData/haoxin-data/dut-research/compilers/llvm-project/build-20210330/bin/clang-13+0x442bf31)
#16 0x0000560f2ad6fe35 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-20210330/bin/clang-13+0x2c82e35)
#17 0x0000560f293e4b41 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-20210330/bin/clang-13+0x12f7b41)
#18 0x0000560f2a513c68
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-20210330/bin/clang-13+0x2426c68)
#19 0x0000560f293e54e1 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-20210330/bin/clang-13+0x12f84e1)
#20 0x0000560f2a50c267 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-20210330/bin/clang-13+0x241f267)
#21 0x0000560f2ae71751 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-20210330/bin/clang-13+0x2d84751)
#22 0x0000560f2a50fd06
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-20210330/bin/clang-13+0x2422d06)
#23 0x0000560f2ae71711 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-20210330/bin/clang-13+0x2d84711)
#24 0x0000560f2a50dc57
llvm::ModuleToPostOrderCGSCCPassAdaptor::run(llvm::Module&,
llvm::AnalysisManager<llvm::Module>&)
(/media/haoxin/SeagateData/haoxin-data/dut-research/compilers/llvm-project/build-20210330/bin/clang-13+0x2420c57)
#25 0x0000560f2ae71791 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-20210330/bin/clang-13+0x2d84791)
#26 0x0000560f2ad6e245 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-20210330/bin/clang-13+0x2c81245)
#27 0x0000560f2ae744df llvm::ModuleInlinerWrapperPass::run(llvm::Module&,
llvm::AnalysisManager<llvm::Module>&)
(/media/haoxin/SeagateData/haoxin-data/dut-research/compilers/llvm-project/build-20210330/bin/clang-13+0x2d874df)
#28 0x0000560f2c51a441 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-20210330/bin/clang-13+0x442d441)
#29 0x0000560f2ad6e245 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-20210330/bin/clang-13+0x2c81245)
#30 0x0000560f2b83243b (anonymous
namespace)::EmitAssemblyHelper::EmitAssemblyWithNewPassManager(clang::BackendAction,
std::unique_ptr<llvm::raw_pwrite_stream,
std::default_delete<llvm::raw_pwrite_stream> >) BackendUtil.cpp:0:0
#31 0x0000560f2b836b95 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-20210330/bin/clang-13+0x3749b95)
#32 0x0000560f2c4b83c6
clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&)
(/media/haoxin/SeagateData/haoxin-data/dut-research/compilers/llvm-project/build-20210330/bin/clang-13+0x43cb3c6)
#33 0x0000560f2d01ba29 clang::ParseAST(clang::Sema&, bool, bool)
(/media/haoxin/SeagateData/haoxin-data/dut-research/compilers/llvm-project/build-20210330/bin/clang-13+0x4f2ea29)
#34 0x0000560f2c4b7188 clang::CodeGenAction::ExecuteAction()
(/media/haoxin/SeagateData/haoxin-data/dut-research/compilers/llvm-project/build-20210330/bin/clang-13+0x43ca188)
#35 0x0000560f2be416f9 clang::FrontendAction::Execute()
(/media/haoxin/SeagateData/haoxin-data/dut-research/compilers/llvm-project/build-20210330/bin/clang-13+0x3d546f9)
#36 0x0000560f2bddf8b1
clang::CompilerInstance::ExecuteAction(clang::FrontendAction&)
(/media/haoxin/SeagateData/haoxin-data/dut-research/compilers/llvm-project/build-20210330/bin/clang-13+0x3cf28b1)
#37 0x0000560f2bf09d60
clang::ExecuteCompilerInvocation(clang::CompilerInstance*)
(/media/haoxin/SeagateData/haoxin-data/dut-research/compilers/llvm-project/build-20210330/bin/clang-13+0x3e1cd60)
#38 0x0000560f2914ef14 cc1_main(llvm::ArrayRef<char const*>, char const*,
void*)
(/media/haoxin/SeagateData/haoxin-data/dut-research/compilers/llvm-project/build-20210330/bin/clang-13+0x1061f14)
#39 0x0000560f2914b477 ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&)
driver.cpp:0:0
#40 0x0000560f29079067 main
(/media/haoxin/SeagateData/haoxin-data/dut-research/compilers/llvm-project/build-20210330/bin/clang-13+0xf8c067)
#41 0x00007f3afed26bf7 __libc_start_main
/build/glibc-S9d2JN/glibc-2.27/csu/../csu/libc-start.c:344:0
#42 0x0000560f2914aefa _start
(/media/haoxin/SeagateData/haoxin-data/dut-research/compilers/llvm-project/build-20210330/bin/clang-13+0x105defa)
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
850fcedb272ff07ac46b9880e628caec2de3eb2c)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir:
/home/haoxin/haoxin-data/dut-research/compilers/llvm-project/build-20210330/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-4b8465.c
clang-13: note: diagnostic msg: /tmp/small-4b8465.sh
clang-13: note: diagnostic msg:
********************
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/20210331/6b66e288/attachment-0001.html>
More information about the llvm-bugs
mailing list