<html>
<head>
<base href="https://bugs.llvm.org/">
</head>
<body><table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Bug ID</th>
<td><a class="bz_bug_link
bz_status_NEW "
title="NEW - clang crashes at -O2"
href="https://bugs.llvm.org/show_bug.cgi?id=49466">49466</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>clang crashes at -O2
</td>
</tr>
<tr>
<th>Product</th>
<td>libraries
</td>
</tr>
<tr>
<th>Version</th>
<td>trunk
</td>
</tr>
<tr>
<th>Hardware</th>
<td>PC
</td>
</tr>
<tr>
<th>OS</th>
<td>Linux
</td>
</tr>
<tr>
<th>Status</th>
<td>NEW
</td>
</tr>
<tr>
<th>Severity</th>
<td>normal
</td>
</tr>
<tr>
<th>Priority</th>
<td>P
</td>
</tr>
<tr>
<th>Component</th>
<td>Scalar Optimizations
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>haoxintu@gmail.com
</td>
</tr>
<tr>
<th>CC</th>
<td>llvm-bugs@lists.llvm.org
</td>
</tr></table>
<p>
<div>
<pre>Hi.
This code makes clang-trunk crashed at -O2. Other released versions or optimal
options handle this case well.
$cat small.c
#include <stdint.h>
uint64_t b, g, f, e, d, c;
int m() {
int i;
uint64_t p ;
uint32_t j ;
uint32_t *k = f;
uint8_t l;
for (;;) {
uint8_t a;
for (; i <= 2; i = j) {
if (j) {
int32_t n;
for (; p; p++)
if (e)
for (; n; n++)
;
} else {
int8_t o = l >= (0 >= 0);
return o;
}
if (d / 0 >= (j = c))
l -= (b /= *k) <= (g %= a);
for (; e; e++)
;
}
for (l = 7; l; l = d)
;
}
return 0;
}
$clang -w -O2 small.c
PLEASE submit a bug report to <a href="https://bugs.llvm.org/">https://bugs.llvm.org/</a> 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-20210304/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/random-compiler-testing/random-test/ccg-test/useful-cases/creduce
-resource-dir
/media/haoxin/SeagateData/haoxin-data/dut-research/compilers/llvm-project/build-20210304/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-20210304/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/dut-research/random-compiler-testing/random-test/ccg-test/useful-cases/creduce
-ferror-limit 19 -fgnuc-version=4.2.1 -fcolor-diagnostics -vectorize-loops
-vectorize-slp -faddrsig -o /tmp/small-7db9c9.o -x c small.c
1. <eof> parser at end of file
2. Code generation
3. Running pass 'Function Pass Manager' on module 'small.c'.
4. Running pass 'CodeGen Prepare' on function '@m'
#0 0x00005609c2f5075c llvm::sys::PrintStackTrace(llvm::raw_ostream&, int)
(/media/haoxin/SeagateData/haoxin-data/dut-research/compilers/llvm-project/build-20210304/bin/clang-13+0x340875c)
#1 0x00005609c2f4e394 llvm::sys::RunSignalHandlers()
(/media/haoxin/SeagateData/haoxin-data/dut-research/compilers/llvm-project/build-20210304/bin/clang-13+0x3406394)
#2 0x00005609c2f4e503 SignalHandler(int) Signals.cpp:0:0
#3 0x00007faad7971980 __restore_rt
(/lib/x86_64-linux-gnu/libpthread.so.0+0x12980)
#4 0x00005609c1fefd2a llvm::LoopBase<llvm::BasicBlock,
llvm::Loop>::getLoopLatch() const
(/media/haoxin/SeagateData/haoxin-data/dut-research/compilers/llvm-project/build-20210304/bin/clang-13+0x24a7d2a)
#5 0x00005609c21b2694 (anonymous
namespace)::CodeGenPrepare::replaceMathCmpWithIntrinsic(llvm::BinaryOperator*,
llvm::Value*, llvm::Value*, llvm::CmpInst*, unsigned int)
CodeGenPrepare.cpp:0:0
#6 0x00005609c21c250e (anonymous
namespace)::CodeGenPrepare::optimizeCmp(llvm::CmpInst*, bool&)
CodeGenPrepare.cpp:0:0
#7 0x00005609c21d22e8 (anonymous
namespace)::CodeGenPrepare::optimizeInst(llvm::Instruction*, bool&)
CodeGenPrepare.cpp:0:0
#8 0x00005609c21d745d (anonymous
namespace)::CodeGenPrepare::runOnFunction(llvm::Function&) (.part.1793)
CodeGenPrepare.cpp:0:0
#9 0x00005609c2717224 llvm::FPPassManager::runOnFunction(llvm::Function&)
(/media/haoxin/SeagateData/haoxin-data/dut-research/compilers/llvm-project/build-20210304/bin/clang-13+0x2bcf224)
#10 0x00005609c2717d69 llvm::FPPassManager::runOnModule(llvm::Module&)
(/media/haoxin/SeagateData/haoxin-data/dut-research/compilers/llvm-project/build-20210304/bin/clang-13+0x2bcfd69)
#11 0x00005609c2716b41 llvm::legacy::PassManagerImpl::run(llvm::Module&)
(/media/haoxin/SeagateData/haoxin-data/dut-research/compilers/llvm-project/build-20210304/bin/clang-13+0x2bceb41)
#12 0x00005609c320df3b (anonymous
namespace)::EmitAssemblyHelper::EmitAssemblyWithNewPassManager(clang::BackendAction,
std::unique_ptr<llvm::raw_pwrite_stream,
std::default_delete<llvm::raw_pwrite_stream> >) BackendUtil.cpp:0:0
#13 0x00005609c3211135 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-20210304/bin/clang-13+0x36c9135)
#14 0x00005609c3e79b16
clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&)
(/media/haoxin/SeagateData/haoxin-data/dut-research/compilers/llvm-project/build-20210304/bin/clang-13+0x4331b16)
#15 0x00005609c49d8aa9 clang::ParseAST(clang::Sema&, bool, bool)
(/media/haoxin/SeagateData/haoxin-data/dut-research/compilers/llvm-project/build-20210304/bin/clang-13+0x4e90aa9)
#16 0x00005609c3e788d8 clang::CodeGenAction::ExecuteAction()
(/media/haoxin/SeagateData/haoxin-data/dut-research/compilers/llvm-project/build-20210304/bin/clang-13+0x43308d8)
#17 0x00005609c3812229 clang::FrontendAction::Execute()
(/media/haoxin/SeagateData/haoxin-data/dut-research/compilers/llvm-project/build-20210304/bin/clang-13+0x3cca229)
#18 0x00005609c37b0141
clang::CompilerInstance::ExecuteAction(clang::FrontendAction&)
(/media/haoxin/SeagateData/haoxin-data/dut-research/compilers/llvm-project/build-20210304/bin/clang-13+0x3c68141)
#19 0x00005609c38da840
clang::ExecuteCompilerInvocation(clang::CompilerInstance*)
(/media/haoxin/SeagateData/haoxin-data/dut-research/compilers/llvm-project/build-20210304/bin/clang-13+0x3d92840)
#20 0x00005609c0b802b4 cc1_main(llvm::ArrayRef<char const*>, char const*,
void*)
(/media/haoxin/SeagateData/haoxin-data/dut-research/compilers/llvm-project/build-20210304/bin/clang-13+0x10382b4)
#21 0x00005609c0b7c817 ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&)
driver.cpp:0:0
#22 0x00005609c0aab517 main
(/media/haoxin/SeagateData/haoxin-data/dut-research/compilers/llvm-project/build-20210304/bin/clang-13+0xf63517)
#23 0x00007faad657cbf7 __libc_start_main
/build/glibc-S9d2JN/glibc-2.27/csu/../csu/libc-start.c:344:0
#24 0x00005609c0b7c29a _start
(/media/haoxin/SeagateData/haoxin-data/dut-research/compilers/llvm-project/build-20210304/bin/clang-13+0x103429a)
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 (<a href="https://github.com/llvm/llvm-project">https://github.com/llvm/llvm-project</a>
a968e7b82eac364d411c81aae58722a0b3a4b29c)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir:
/home/haoxin/haoxin-data/dut-research/compilers/llvm-project/build-20210304/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-a7539a.c
clang-13: note: diagnostic msg: /tmp/small-a7539a.sh
clang-13: note: diagnostic msg:
********************
Thanks,
Haoxin</pre>
</div>
</p>
<hr>
<span>You are receiving this mail because:</span>
<ul>
<li>You are on the CC list for the bug.</li>
</ul>
</body>
</html>