<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 -O1 causes "PHI node has multiple entries for the same basic block with different incoming values!""
href="https://bugs.llvm.org/show_bug.cgi?id=49218">49218</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>clang -O1 causes "PHI node has multiple entries for the same basic block with different incoming values!"
</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 all.
This program make clang crash with -O1, and this problem only happens in the
current trunk version of clang.
$cat small.c
#include <stdint.h>
int a, b;
int c() {
int64_t d = b;
if (d) {
uint16_t e;
for (; b;)
f:
for (; d;)
g:
if (e)
for (;;)
;
for (;;) {
int64_t k;
uint8_t i;
if (k) {
m:
k %= i;
goto g;
}
}
}
{
int16_t j;
for (;; d++) {
int32_t l;
if (j)
goto f;
if (a) {
for (; d;)
goto m;
if (0 / 0)
return a;
for (;;)
;
}
}
}
}
$clang -w -c -O1 small.c
PHI node has multiple entries for the same basic block with different incoming
values!
%k.2.ph = phi i64 [ poison, %for.cond9.preheader ], [ poison, %cleanup29 ], [
undef, %cleanup29 ], [ %k.0, %for.cond ]
label %cleanup29
i64 undef
i64 poison
in function c
fatal error: error in backend: Broken function found, compilation aborted!
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: clang -c -w -O1 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 'Module Verifier' on function '@c'
#0 0x000055a24fc7567c llvm::sys::PrintStackTrace(llvm::raw_ostream&, int)
(/media/haoxin/SeagateData/haoxin-data/dut-research/compilers/llvm-project/build-20210216/bin/clang-13+0x33de67c)
#1 0x000055a24fc732b4 llvm::sys::RunSignalHandlers()
(/media/haoxin/SeagateData/haoxin-data/dut-research/compilers/llvm-project/build-20210216/bin/clang-13+0x33dc2b4)
#2 0x000055a24fc7354b llvm::sys::CleanupOnSignal(unsigned long)
(/media/haoxin/SeagateData/haoxin-data/dut-research/compilers/llvm-project/build-20210216/bin/clang-13+0x33dc54b)
#3 0x000055a24fbd26bf llvm::CrashRecoveryContext::HandleExit(int)
(/media/haoxin/SeagateData/haoxin-data/dut-research/compilers/llvm-project/build-20210216/bin/clang-13+0x333b6bf)
#4 0x000055a24fc6b97e llvm::sys::Process::Exit(int, bool)
(/media/haoxin/SeagateData/haoxin-data/dut-research/compilers/llvm-project/build-20210216/bin/clang-13+0x33d497e)
#5 0x000055a24d8ddf05 LLVMErrorHandler(void*, std::__cxx11::basic_string<char,
std::char_traits<char>, std::allocator<char> > const&, bool) cc1_main.cpp:0:0
#6 0x000055a24fbda439 llvm::report_fatal_error(llvm::Twine const&, bool)
(/media/haoxin/SeagateData/haoxin-data/dut-research/compilers/llvm-project/build-20210216/bin/clang-13+0x3343439)
#7 0x000055a24fbda578
(/media/haoxin/SeagateData/haoxin-data/dut-research/compilers/llvm-project/build-20210216/bin/clang-13+0x3343578)
#8 0x000055a24f4c6083 (anonymous
namespace)::VerifierLegacyPass::runOnFunction(llvm::Function&) Verifier.cpp:0:0
#9 0x000055a24f441e14 llvm::FPPassManager::runOnFunction(llvm::Function&)
(/media/haoxin/SeagateData/haoxin-data/dut-research/compilers/llvm-project/build-20210216/bin/clang-13+0x2baae14)
#10 0x000055a24f442959 llvm::FPPassManager::runOnModule(llvm::Module&)
(/media/haoxin/SeagateData/haoxin-data/dut-research/compilers/llvm-project/build-20210216/bin/clang-13+0x2bab959)
#11 0x000055a24f441731 llvm::legacy::PassManagerImpl::run(llvm::Module&)
(/media/haoxin/SeagateData/haoxin-data/dut-research/compilers/llvm-project/build-20210216/bin/clang-13+0x2baa731)
#12 0x000055a24ff30de0 (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 0x000055a24ff33f65 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-20210216/bin/clang-13+0x369cf65)
#14 0x000055a250b90f6b
clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&)
(/media/haoxin/SeagateData/haoxin-data/dut-research/compilers/llvm-project/build-20210216/bin/clang-13+0x42f9f6b)
#15 0x000055a2516e4059 clang::ParseAST(clang::Sema&, bool, bool)
(/media/haoxin/SeagateData/haoxin-data/dut-research/compilers/llvm-project/build-20210216/bin/clang-13+0x4e4d059)
#16 0x000055a250b8fce8 clang::CodeGenAction::ExecuteAction()
(/media/haoxin/SeagateData/haoxin-data/dut-research/compilers/llvm-project/build-20210216/bin/clang-13+0x42f8ce8)
#17 0x000055a25052df19 clang::FrontendAction::Execute()
(/media/haoxin/SeagateData/haoxin-data/dut-research/compilers/llvm-project/build-20210216/bin/clang-13+0x3c96f19)
#18 0x000055a2504c4dc9
clang::CompilerInstance::ExecuteAction(clang::FrontendAction&)
(/media/haoxin/SeagateData/haoxin-data/dut-research/compilers/llvm-project/build-20210216/bin/clang-13+0x3c2ddc9)
#19 0x000055a2505f4fa0
clang::ExecuteCompilerInvocation(clang::CompilerInstance*)
(/media/haoxin/SeagateData/haoxin-data/dut-research/compilers/llvm-project/build-20210216/bin/clang-13+0x3d5dfa0)
#20 0x000055a24d8df054 cc1_main(llvm::ArrayRef<char const*>, char const*,
void*)
(/media/haoxin/SeagateData/haoxin-data/dut-research/compilers/llvm-project/build-20210216/bin/clang-13+0x1048054)
#21 0x000055a24d8db557 ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&)
driver.cpp:0:0
#22 0x000055a250384745 void llvm::function_ref<void
()>::callback_fn<clang::driver::CC1Command::Execute(llvm::ArrayRef<llvm::Optional<llvm::StringRef>
<span class="quote">>, std::__cxx11::basic_string<char, std::char_traits<char>,</span >
std::allocator<char> >*, bool*) const::'lambda'()>(long) Job.cpp:0:0
#23 0x000055a24fbd2592
llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>)
(/media/haoxin/SeagateData/haoxin-data/dut-research/compilers/llvm-project/build-20210216/bin/clang-13+0x333b592)
#24 0x000055a250385a8c
clang::driver::CC1Command::Execute(llvm::ArrayRef<llvm::Optional<llvm::StringRef>
<span class="quote">>, std::__cxx11::basic_string<char, std::char_traits<char>,</span >
std::allocator<char> >*, bool*) const (.part.185) Job.cpp:0:0
#25 0x000055a25035cfa9
clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&,
clang::driver::Command const*&) const
(/media/haoxin/SeagateData/haoxin-data/dut-research/compilers/llvm-project/build-20210216/bin/clang-13+0x3ac5fa9)
#26 0x000055a25035e157
clang::driver::Compilation::ExecuteJobs(clang::driver::JobList const&,
llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*> >&) const
(/media/haoxin/SeagateData/haoxin-data/dut-research/compilers/llvm-project/build-20210216/bin/clang-13+0x3ac7157)
#27 0x000055a2503704a9
clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&,
llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*> >&)
(/media/haoxin/SeagateData/haoxin-data/dut-research/compilers/llvm-project/build-20210216/bin/clang-13+0x3ad94a9)
#28 0x000055a24d80b955 main
(/media/haoxin/SeagateData/haoxin-data/dut-research/compilers/llvm-project/build-20210216/bin/clang-13+0xf74955)
#29 0x00007fbbac038bf7 __libc_start_main
/build/glibc-S9d2JN/glibc-2.27/csu/../csu/libc-start.c:344:0
#30 0x000055a24d8dafda _start
(/media/haoxin/SeagateData/haoxin-data/dut-research/compilers/llvm-project/build-20210216/bin/clang-13+0x1043fda)
clang-13: error: clang frontend command failed with exit code 70 (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>
22f00f61dd5483a9fdaed3b7592d392c23b3646a)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir:
/home/haoxin/haoxin-data/dut-research/compilers/llvm-project/build-20210216/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-42adaf.c
clang-13: note: diagnostic msg: /tmp/small-42adaf.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>