[llvm-bugs] [Bug 46784] New: Regression in coroutines between clang 10 and clang 11 with compiler crash in -O2 -g ("broken function")
via llvm-bugs
llvm-bugs at lists.llvm.org
Mon Jul 20 12:10:04 PDT 2020
https://bugs.llvm.org/show_bug.cgi?id=46784
Bug ID: 46784
Summary: Regression in coroutines between clang 10 and clang 11
with compiler crash in -O2 -g ("broken function")
Product: clang
Version: 11.0
Hardware: PC
OS: Windows NT
Status: NEW
Severity: enhancement
Priority: P
Component: C++2a
Assignee: unassignedclangbugs at nondot.org
Reporter: bartde at microsoft.com
CC: blitzrakete at gmail.com, erik.pilkington at gmail.com,
gornishanov at gmail.com, hans at chromium.org,
JunMa at linux.alibaba.com, llvm-bugs at lists.llvm.org,
modocache at gmail.com, richard-llvm at metafoo.co.uk
Blocks: 46725
This is blocking us to move to clang 11 and get fixes for various
coroutine-related bugs.
Error:
mismatched subprogram between llvm.dbg.value variable and !dbg attachment
call void @llvm.dbg.value(metadata %"class.std::__1::vector"* undef, metadata
!5008, metadata !DIExpression()), !dbg !5213
label %133
void (%"_ZZ17clang11_bug_reprovENK3$_0clEv.Frame"*)*
@"_ZZ17clang11_bug_reprovENK3$_0clEv.resume"
!5008 = !DILocalVariable(name: "awaitables", arg: 1, scope: !5004, file: !69,
line: 58, type: !4638)
!5004 = distinct !DISubprogram(name: "my_operator<my_void_task>", linkageName:
"_Z11my_operatorI12my_void_taskEDaONSt3__16vectorIT_NS1_9allocatorIS3_EEEE",
scope: !69, file: !69, line: 58, type: !5005, scopeLine: 59, flags:
DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition |
DISPFlagOptimized, unit: !0, templateParams: !5009, retainedNodes: !5007)
!5213 = !DILocation(line: 0, scope: !1513, inlinedAt: !5212)
!1513 = distinct !DISubprogram(name: "my_operator<my_void_task>", linkageName:
"_Z11my_operatorI12my_void_taskEDaONSt3__16vectorIT_NS1_9allocatorIS3_EEEE",
scope: !69, file: !69, line: 58, type: !1514, scopeLine: 59, flags:
DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition |
DISPFlagOptimized, unit: !0, templateParams: !1518, retainedNodes: !1516)
fatal error: error in backend: Broken function
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: /opt/compiler-explorer/clang-trunk/bin/clang++ -g -o
./output.s -mllvm --x86-asm-syntax=intel -S
--gcc-toolchain=/opt/compiler-explorer/gcc-9.2.0 -fcolor-diagnostics
-fno-crash-diagnostics -std=c++2a -O2 -g -fcoroutines-ts -stdlib=libc++
<source>
1. <eof> parser at end of file
2. Per-module optimization passes
3. Running pass 'CallGraph Pass Manager' on module '<source>'.
4. While splitting coroutine @"_ZZ17clang11_bug_reprovENK3$_0clEv"
#0 0x000055633a45075a llvm::sys::PrintStackTrace(llvm::raw_ostream&)
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x2cad75a)
#1 0x000055633a44e504 llvm::sys::RunSignalHandlers()
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x2cab504)
#2 0x000055633a44e775 llvm::sys::CleanupOnSignal(unsigned long)
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x2cab775)
#3 0x000055633a3c3882 llvm::CrashRecoveryContext::HandleExit(int)
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x2c20882)
#4 0x000055633a4473d7 llvm::sys::Process::Exit(int)
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x2ca43d7)
#5 0x00005563386289b1 LLVMErrorHandler(void*, std::__cxx11::basic_string<char,
std::char_traits<char>, std::allocator<char> > const&, bool)
(/opt/compiler-explorer/clang-trunk/bin/clang+++0xe859b1)
#6 0x000055633a3ca029 llvm::report_fatal_error(llvm::Twine const&, bool)
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x2c27029)
#7 0x000055633a3ca168
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x2c27168)
#8 0x000055633b5a875e postSplitCleanup(llvm::Function&)
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x3e0575e)
#9 0x000055633b5a93f1 splitSwitchCoroutine(llvm::Function&,
llvm::coro::Shape&, llvm::SmallVectorImpl<llvm::Function*>&)
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x3e063f1)
#10 0x000055633b5aaf70 splitCoroutine(llvm::Function&,
llvm::SmallVectorImpl<llvm::Function*>&) (.constprop.449)
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x3e07f70)
#11 0x000055633b5ac614 (anonymous
namespace)::CoroSplitLegacy::runOnSCC(llvm::CallGraphSCC&) (.part.448)
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x3e09614)
#12 0x0000556339683bbf (anonymous
namespace)::CGPassManager::runOnModule(llvm::Module&)
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x1ee0bbf)
#13 0x0000556339d832c1 llvm::legacy::PassManagerImpl::run(llvm::Module&)
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x25e02c1)
#14 0x000055633a6d181d (anonymous
namespace)::EmitAssemblyHelper::EmitAssembly(clang::BackendAction,
std::unique_ptr<llvm::raw_pwrite_stream,
std::default_delete<llvm::raw_pwrite_stream> >)
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x2f2e81d)
#15 0x000055633a6d344b 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> >)
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x2f3044b)
#16 0x000055633b2161f4
clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&)
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x3a731f4)
#17 0x000055633bf872b9 clang::ParseAST(clang::Sema&, bool, bool)
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x47e42b9)
#18 0x000055633ac3cb89 clang::FrontendAction::Execute()
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x3499b89)
#19 0x000055633abf694b
clang::CompilerInstance::ExecuteAction(clang::FrontendAction&)
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x345394b)
#20 0x000055633ad02f7b
clang::ExecuteCompilerInvocation(clang::CompilerInstance*)
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x355ff7b)
#21 0x0000556338629f3c cc1_main(llvm::ArrayRef<char const*>, char const*,
void*) (/opt/compiler-explorer/clang-trunk/bin/clang+++0xe86f3c)
#22 0x0000556338626a3d ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&)
(/opt/compiler-explorer/clang-trunk/bin/clang+++0xe83a3d)
#23 0x000055633aacf3f5 void llvm::function_ref<void
()>::callback_fn<clang::driver::CC1Command::Execute(llvm::ArrayRef<llvm::Optional<llvm::StringRef>
>, std::__cxx11::basic_string<char, std::char_traits<char>,
std::allocator<char> >*, bool*) const::'lambda'()>(long)
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x332c3f5)
#24 0x000055633a3c3713
llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>)
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x2c20713)
#25 0x000055633aacfed0
clang::driver::CC1Command::Execute(llvm::ArrayRef<llvm::Optional<llvm::StringRef>
>, std::__cxx11::basic_string<char, std::char_traits<char>,
std::allocator<char> >*, bool*) const (.part.148)
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x332ced0)
#26 0x000055633aaaa0a5
clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&,
clang::driver::Command const*&) const
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x33070a5)
#27 0x000055633aaaaaef
clang::driver::Compilation::ExecuteJobs(clang::driver::JobList const&,
llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*> >&) const
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x3307aef)
#28 0x000055633aab3685
clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&,
llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*> >&)
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x3310685)
#29 0x0000556338566921 main
(/opt/compiler-explorer/clang-trunk/bin/clang+++0xdc3921)
#30 0x00007ff5f84fdb97 __libc_start_main
(/lib/x86_64-linux-gnu/libc.so.6+0x21b97)
#31 0x00005563386265ba _start
(/opt/compiler-explorer/clang-trunk/bin/clang+++0xe835ba)
clang-12: error: clang frontend command failed with exit code 70 (use -v to see
invocation)
ASM generation compiler returned: 70
mismatched subprogram between llvm.dbg.value variable and !dbg attachment
call void @llvm.dbg.value(metadata %"class.std::__1::vector"* undef, metadata
!5008, metadata !DIExpression()), !dbg !5213
label %133
void (%"_ZZ17clang11_bug_reprovENK3$_0clEv.Frame"*)*
@"_ZZ17clang11_bug_reprovENK3$_0clEv.resume"
!5008 = !DILocalVariable(name: "awaitables", arg: 1, scope: !5004, file: !69,
line: 58, type: !4638)
!5004 = distinct !DISubprogram(name: "my_operator<my_void_task>", linkageName:
"_Z11my_operatorI12my_void_taskEDaONSt3__16vectorIT_NS1_9allocatorIS3_EEEE",
scope: !69, file: !69, line: 58, type: !5005, scopeLine: 59, flags:
DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition |
DISPFlagOptimized, unit: !0, templateParams: !5009, retainedNodes: !5007)
!5213 = !DILocation(line: 0, scope: !1513, inlinedAt: !5212)
!1513 = distinct !DISubprogram(name: "my_operator<my_void_task>", linkageName:
"_Z11my_operatorI12my_void_taskEDaONSt3__16vectorIT_NS1_9allocatorIS3_EEEE",
scope: !69, file: !69, line: 58, type: !1514, scopeLine: 59, flags:
DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition |
DISPFlagOptimized, unit: !0, templateParams: !1518, retainedNodes: !1516)
fatal error: error in backend: Broken function
clang-12: error: clang frontend command failed with exit code 70 (use -v to see
invocation)
Execution build compiler returned: 70
Compiler flags:
-std=c++2a -O2 -g -fcoroutines-ts -stdlib=libc++
Minimal repro (https://godbolt.org/z/91Ers9):
#define REPRO_NEED_VECTOR_ELEM 1
#define REPRO_NEED_MOVE 1
#include <experimental/coroutine>
struct my_void_task final
{
struct promise_type final
{
my_void_task get_return_object() noexcept { return my_void_task{this};
}
void return_void() const noexcept {}
void unhandled_exception() const {}
std::experimental::suspend_always initial_suspend() const noexcept {
return {}; }
std::experimental::suspend_always final_suspend() const noexcept {
return {}; }
};
using coroutine_handle_promise_t =
std::experimental::coroutine_handle<promise_type>;
my_void_task() = delete;
my_void_task(const my_void_task&) = delete;
my_void_task& operator=(const my_void_task&) = delete;
my_void_task(my_void_task && task) noexcept
: m_coro{task.m_coro}
{
task.m_coro = nullptr;
}
my_void_task& operator=(my_void_task&& task) noexcept
{
return *this; // NB: Removed all code
}
private:
explicit my_void_task(promise_type * p)
: m_coro{coroutine_handle_promise_t::from_promise(*p)}
{
}
coroutine_handle_promise_t m_coro;
};
#include <vector>
template <typename Awaitable>
auto my_operator(std::vector<Awaitable>&& awaitables)
{
struct awaitable final
{
awaitable(std::vector<Awaitable> awaitables)
: m_awaitables{std::move(awaitables)}
{
}
struct awaiter final
{
bool await_ready() { return false; }
void await_suspend(std::experimental::coroutine_handle<>) {}
int await_resume() { return 42; }
};
awaiter operator co_await() { return {}; }
private:
std::vector<Awaitable> m_awaitables;
};
return awaitable{std::move(awaitables)};
}
my_void_task hhh()
{
co_return;
}
void clang11_bug_repro()
{
auto f = []() -> my_void_task {
std::vector<my_void_task> v{};
#if REPRO_NEED_VECTOR_ELEM
v.push_back(hhh());
#endif
#if REPRO_NEED_MOVE
auto w = my_operator(std::move(v));
auto x = co_await std::move(w);
#else
auto x = co_await when_any(std::move(v));
#endif
};
auto g = f();
}
Referenced Bugs:
https://bugs.llvm.org/show_bug.cgi?id=46725
[Bug 46725] [meta] 11.0.0 Release Blockers
--
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/20200720/90f9b4c0/attachment.html>
More information about the llvm-bugs
mailing list