[llvm-bugs] [Bug 48627] New: crash in tail call elimination of C++2a coroutines on MIPS

via llvm-bugs llvm-bugs at lists.llvm.org
Tue Dec 29 17:46:00 PST 2020


https://bugs.llvm.org/show_bug.cgi?id=48627

            Bug ID: 48627
           Summary: crash in tail call elimination of C++2a coroutines on
                    MIPS
           Product: clang
           Version: 11.0
          Hardware: Macintosh
                OS: MacOS X
            Status: NEW
          Severity: normal
          Priority: P
         Component: LLVM Codegen
          Assignee: unassignedclangbugs at nondot.org
          Reporter: saurik at saurik.com
                CC: llvm-bugs at lists.llvm.org, neeilans at live.com,
                    richard-llvm at metafoo.co.uk

Created attachment 24321
  --> https://bugs.llvm.org/attachment.cgi?id=24321&action=edit
the flattened code generated in the crash report

Here is a somewhat-whittled test case of a compiler crash trying to use
coroutines on MIPS.



/usr/local/opt/llvm/bin/clang++ --sysroot debian-stretch-ish -target
mips-linux-gnu -c -o test.o -std=c++2a -Os -fcoroutines-ts -nostdinc++ -isystem
env/libcxx/include -isystem env/libcxxabi/include test.cpp

libcxx: 2076f539f410805ef88692b9c0ce0a0b882a7680
libcxxabi: a88633b46c401e6be38b93cf08660f137f86664d

$ /usr/local/opt/llvm/bin/clang++ --version
clang version 11.0.0
Target: x86_64-apple-darwin18.7.0
Thread model: posix
InstalledDir: /usr/local/opt/llvm/bin



#include <experimental/coroutine>

struct Task {
    struct promise_type {
        std::experimental::coroutine_handle<> code_;

        auto initial_suspend() noexcept {
            return std::experimental::suspend_always(); }
        auto final_suspend() noexcept {
            return std::experimental::suspend_always(); }

        auto get_return_object() noexcept {
            return
Task(std::experimental::coroutine_handle<promise_type>::from_promise(*this));
        }

        void unhandled_exception() noexcept {}
        void return_void() noexcept {}
        void operator *() {}
    };

    std::experimental::coroutine_handle<promise_type> code_;

    Task(std::experimental::coroutine_handle<promise_type> code) noexcept :
        code_(std::move(code)) {}

    bool await_ready() noexcept {
        return !code_ || code_.done(); }

    template <typename Promise_>
    auto await_suspend(std::experimental::coroutine_handle<Promise_> code)
noexcept {
        code_.promise().code_ = std::move(code);
        return code_;
    }

    auto await_resume() const {
        return *this->code_.promise();
    }
};

Task f();
Task g() { co_await f(); }



fatal error: error in backend: failed to perform tail call elimination on a
call site marked musttail
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: /usr/local/opt/llvm/bin/clang++ --sysroot
/Users/saurik/orchid/cli-shared/out-wrt/sysroot -target mips-linux-gnu -c -o
test.o -std=c++2a -Os -fcoroutines-ts -nostdinc++ -isystem env/libcxx/include
-isystem env/libcxxabi/include test.cpp
1.      <eof> parser at end of file
2.      Code generation
3.      Running pass 'Function Pass Manager' on module 'test.cpp'.
4.      Running pass 'MIPS DAG->DAG Pattern Instruction Selection' on function
'@_Z1gv.resume'
0  libLLVM.dylib      0x00000001041da6c4
llvm::sys::PrintStackTrace(llvm::raw_ostream&) + 40
1  libLLVM.dylib      0x00000001041da141 llvm::sys::CleanupOnSignal(unsigned
long) + 184
2  libLLVM.dylib      0x0000000104146b61 (anonymous
namespace)::CrashRecoveryContextImpl::HandleCrash(int, unsigned long) + 97
3  libLLVM.dylib      0x0000000104146afe
llvm::CrashRecoveryContext::HandleExit(int) + 14
4  libLLVM.dylib      0x00000001041d7927 llvm::sys::Process::Exit(int) + 35
5  clang++            0x000000010195a73d LLVMErrorHandler(void*,
std::__1::basic_string<char, std::__1::char_traits<char>,
std::__1::allocator<char> > const&, bool) + 180
6  libLLVM.dylib      0x000000010414f369 llvm::report_fatal_error(llvm::Twine
const&, bool) + 254
7  libLLVM.dylib      0x000000010414f26b llvm::report_fatal_error(llvm::Twine
const&, bool) + 0
8  libLLVM.dylib      0x000000010582cad6
llvm::MipsTargetLowering::LowerCall(llvm::TargetLowering::CallLoweringInfo&,
llvm::SmallVectorImpl<llvm::SDValue>&) const + 5702
9  libLLVM.dylib      0x000000010463fce0
llvm::TargetLowering::LowerCallTo(llvm::TargetLowering::CallLoweringInfo&)
const + 3798
10 libLLVM.dylib      0x00000001046558de
llvm::SelectionDAGBuilder::lowerInvokable(llvm::TargetLowering::CallLoweringInfo&,
llvm::BasicBlock const*) + 386
11 libLLVM.dylib      0x00000001046452c7
llvm::SelectionDAGBuilder::LowerCallTo(llvm::CallBase const&, llvm::SDValue,
bool, llvm::BasicBlock const*) + 1483
12 libLLVM.dylib      0x00000001046374e4
llvm::SelectionDAGBuilder::visitCall(llvm::CallInst const&) + 1170
13 libLLVM.dylib      0x000000010462ff87
llvm::SelectionDAGBuilder::visit(llvm::Instruction const&) + 113
14 libLLVM.dylib      0x00000001046964b5
llvm::SelectionDAGISel::SelectBasicBlock(llvm::ilist_iterator<llvm::ilist_detail::node_options<llvm::Instruction,
false, false, void>, false, true>,
llvm::ilist_iterator<llvm::ilist_detail::node_options<llvm::Instruction, false,
false, void>, false, true>, bool&) + 155
15 libLLVM.dylib      0x00000001046961d4
llvm::SelectionDAGISel::SelectAllBasicBlocks(llvm::Function const&) + 3686
16 libLLVM.dylib      0x00000001046949d4
llvm::SelectionDAGISel::runOnMachineFunction(llvm::MachineFunction&) + 1618
17 libLLVM.dylib      0x0000000105819d8c
llvm::MipsDAGToDAGISel::runOnMachineFunction(llvm::MachineFunction&) + 32
18 libLLVM.dylib      0x00000001043e0cdb
llvm::MachineFunctionPass::runOnFunction(llvm::Function&) + 239
19 libLLVM.dylib      0x00000001042a09a5
llvm::FPPassManager::runOnFunction(llvm::Function&) + 517
20 libLLVM.dylib      0x00000001042a4204
llvm::FPPassManager::runOnModule(llvm::Module&) + 52
21 libLLVM.dylib      0x00000001042a0e14
llvm::legacy::PassManagerImpl::run(llvm::Module&) + 668
22 libclang-cpp.dylib 0x00000001023d0e33
clang::EmitBackendOutput(clang::DiagnosticsEngine&, clang::HeaderSearchOptions
const&, clang::CodeGenOptions const&, clang::TargetOptions const&,
clang::LangOptions const&, llvm::DataLayout const&, llvm::Module*,
clang::BackendAction, std::__1::unique_ptr<llvm::raw_pwrite_stream,
std::__1::default_delete<llvm::raw_pwrite_stream> >) + 10681
23 libclang-cpp.dylib 0x00000001025f8239
clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&) + 1041
24 libclang-cpp.dylib 0x0000000101a59e68 clang::ParseAST(clang::Sema&, bool,
bool) + 507
25 libclang-cpp.dylib 0x0000000102af759b clang::FrontendAction::Execute() + 77
26 libclang-cpp.dylib 0x0000000102abf611
clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) + 1287
27 libclang-cpp.dylib 0x0000000102b44afb
clang::ExecuteCompilerInvocation(clang::CompilerInstance*) + 1059
28 clang++            0x000000010195a0b8 cc1_main(llvm::ArrayRef<char const*>,
char const*, void*) + 1880
29 clang++            0x00000001019589c6
ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&) + 270
30 libclang-cpp.dylib 0x00000001028bd1a1 void llvm::function_ref<void
()>::callback_fn<clang::driver::CC1Command::Execute(llvm::ArrayRef<llvm::Optional<llvm::StringRef>
>, std::__1::basic_string<char, std::__1::char_traits<char>,
std::__1::allocator<char> >*, bool*) const::$_1>(long) + 23
31 libLLVM.dylib      0x0000000104146adc
llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) + 218
32 libclang-cpp.dylib 0x00000001028bc85f
clang::driver::CC1Command::Execute(llvm::ArrayRef<llvm::Optional<llvm::StringRef>
>, std::__1::basic_string<char, std::__1::char_traits<char>,
std::__1::allocator<char> >*, bool*) const + 233
33 libclang-cpp.dylib 0x000000010289d636
clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&,
clang::driver::Command const*&) const + 526
34 libclang-cpp.dylib 0x000000010289d825
clang::driver::Compilation::ExecuteJobs(clang::driver::JobList const&,
llvm::SmallVectorImpl<std::__1::pair<int, clang::driver::Command const*> >&)
const + 95
35 libclang-cpp.dylib 0x00000001028ac46a
clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&,
llvm::SmallVectorImpl<std::__1::pair<int, clang::driver::Command const*> >&) +
210
36 clang++            0x0000000101958202 main + 7204
37 libdyld.dylib      0x00007fff5de933d5 start + 1
clang-11: error: clang frontend command failed with exit code 70 (use -v to see
invocation)
clang version 11.0.0
Target: mips-unknown-linux-gnu
Thread model: posix
InstalledDir: /usr/local/opt/llvm/bin
clang-11: note: diagnostic msg:
********************

PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT:
Preprocessed source(s) and associated run script(s) are located at:
clang-11: note: diagnostic msg:
/var/folders/h8/lhvqzq_d0rd1hqhvtvzrhqj00000gn/T/test-5e3bd1.cpp
clang-11: note: diagnostic msg:
/var/folders/h8/lhvqzq_d0rd1hqhvtvzrhqj00000gn/T/test-5e3bd1.sh
clang-11: note: diagnostic msg: Crash backtrace is located in
clang-11: note: diagnostic msg:
/Users/saurik/Library/Logs/DiagnosticReports/clang-11_<YYYY-MM-DD-HHMMSS>_<hostname>.crash
clang-11: note: diagnostic msg: (choose the .crash file that corresponds to
your crash)
clang-11: note: diagnostic msg:

********************

-- 
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/20201230/5aae6eaf/attachment-0001.html>


More information about the llvm-bugs mailing list