Quuxplusone / LLVMBugzillaTest

0 stars 0 forks source link

[coroutines] assertion (Block[UseIndex].Consumes[DefIndex] && "use must consume def") with __attribute__((always_inline)) #34243

Open Quuxplusone opened 7 years ago

Quuxplusone commented 7 years ago
Bugzilla Link PR35270
Status NEW
Importance P enhancement
Reported by Eric Niebler (eniebler@boost.org)
Reported on 2017-11-09 20:21:43 -0800
Last modified on 2018-03-01 15:01:39 -0800
Version trunk
Hardware PC All
CC andrew@ziglang.org, dgregor@apple.com, gornishanov@gmail.com, llvm-bugs@lists.llvm.org, modocache@gmail.com
Fixed by commit(s)
Attachments test.cpp (3949 bytes, text/plain)
file_35270.txt (48199 bytes, text/plain)
Blocks
Blocked by
See also
Created attachment 19399
repro

Compile attached file as:
clang++ -std=gnu++2a -fcoroutines-ts -c test.cpp

Removing the one instance of __attribute__((__always_inline__)) eliminates the
error.

Assertion failed: (Block[UseIndex].Consumes[DefIndex] && "use must consume
def"), function hasPathCrossingSuspendPoint, file
/Users/eniebler/llvm/lib/Transforms/Coroutines/CoroFrame.cpp, line 106.
0  clang-6.0                0x0000000103b01e0c
llvm::sys::PrintStackTrace(llvm::raw_ostream&) + 60
1  clang-6.0                0x0000000103b02409
PrintStackTraceSignalHandler(void*) + 25
2  clang-6.0                0x0000000103afdc69 llvm::sys::RunSignalHandlers() +
425
3  clang-6.0                0x0000000103b027c2 SignalHandler(int) + 354
4  libsystem_platform.dylib 0x00007fffae360b3a _sigtramp + 26
5  clang-6.0                0x0000000100c32c05
llvm::isa_impl<llvm::Instruction, llvm::Value, void>::doit(llvm::Value const&)
+ 21
6  libsystem_c.dylib        0x00007fffae1e5420 abort + 129
7  libsystem_c.dylib        0x00007fffae1ac893 basename_r + 0
8  clang-6.0                0x0000000105078dae (anonymous
namespace)::SuspendCrossingInfo::hasPathCrossingSuspendPoint(llvm::BasicBlock*,
llvm::BasicBlock*) const + 366
9  clang-6.0                0x0000000105078c22 (anonymous
namespace)::SuspendCrossingInfo::isDefinitionAcrossSuspend(llvm::BasicBlock*,
llvm::User*) const + 130
10 clang-6.0                0x0000000105074868 (anonymous
namespace)::SuspendCrossingInfo::isDefinitionAcrossSuspend(llvm::Instruction&,
llvm::User*) const + 56
11 clang-6.0                0x000000010507410d
llvm::coro::buildCoroutineFrame(llvm::Function&, llvm::coro::Shape&) + 2221
12 clang-6.0                0x000000010507b0a3 splitCoroutine(llvm::Function&,
llvm::CallGraph&, llvm::CallGraphSCC&) + 147
13 clang-6.0                0x000000010507a881 (anonymous
namespace)::CoroSplit::runOnSCC(llvm::CallGraphSCC&) + 1937
14 clang-6.0                0x00000001023953df (anonymous
namespace)::CGPassManager::RunPassOnSCC(llvm::Pass*, llvm::CallGraphSCC&,
llvm::CallGraph&, bool&, bool&) + 255
15 clang-6.0                0x0000000102393db9 (anonymous
namespace)::CGPassManager::RunAllPassesOnSCC(llvm::CallGraphSCC&,
llvm::CallGraph&, bool&) + 1561
16 clang-6.0                0x00000001023931a3 (anonymous
namespace)::CGPassManager::runOnModule(llvm::Module&) + 419
17 clang-6.0                0x0000000102f34ee4 (anonymous
namespace)::MPPassManager::runOnModule(llvm::Module&) + 2196
18 clang-6.0                0x0000000102f343d6
llvm::legacy::PassManagerImpl::run(llvm::Module&) + 342
19 clang-6.0                0x0000000102f35c11
llvm::legacy::PassManager::run(llvm::Module&) + 33
20 clang-6.0                0x0000000103f27c03 (anonymous
namespace)::EmitAssemblyHelper::EmitAssembly(clang::BackendAction,
std::__1::unique_ptr<llvm::raw_pwrite_stream,
std::__1::default_delete<llvm::raw_pwrite_stream> >) + 4771
21 clang-6.0                0x0000000103f220b2
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> >) + 4450
22 clang-6.0                0x00000001042fc1ba
clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&) + 5562
23 clang-6.0                0x000000010617eb26 clang::ParseAST(clang::Sema&,
bool, bool) + 1238
24 clang-6.0                0x0000000104a3f295
clang::ASTFrontendAction::ExecuteAction() + 485
25 clang-6.0                0x00000001042f9fba
clang::CodeGenAction::ExecuteAction() + 5546
26 clang-6.0                0x0000000104a3e1f0 clang::FrontendAction::Execute()
+ 112
27 clang-6.0                0x00000001049537ad
clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) + 2285
28 clang-6.0                0x0000000104af26a3
clang::ExecuteCompilerInvocation(clang::CompilerInstance*) + 5843
29 clang-6.0                0x0000000100a51284 cc1_main(llvm::ArrayRef<char
const*>, char const*, void*) + 4900
30 clang-6.0                0x0000000100a4020e
ExecuteCC1Tool(llvm::ArrayRef<char const*>, llvm::StringRef) + 622
31 clang-6.0                0x0000000100a3d8aa main + 4282
32 libdyld.dylib            0x00007fffae151235 start + 1
33 libdyld.dylib            0x0000000000000038 start + 1374350852
Stack dump:
0.  Program arguments: /Users/eniebler/llvm-install/bin/clang-6.0 -cc1 -triple
x86_64-apple-macosx10.12.0 -Wdeprecated-objc-isa-usage -Werror=deprecated-objc-
isa-usage -emit-obj -mrelax-all -disable-free -main-file-name test.cpp -
mrelocation-model pic -pic-level 2 -mthread-model posix -mdisable-fp-elim -masm-
verbose -munwind-tables -faligned-alloc-unavailable -target-cpu penryn -dwarf-
column-info -debugger-tuning=lldb -target-linker-version 302.3 -coverage-notes-
file /Users/eniebler/test.gcno -resource-dir /Users/eniebler/llvm-
install/lib/clang/6.0.0 -stdlib=libc++ -std=gnu++2a -fdeprecated-macro -fdebug-
compilation-dir /Users/eniebler -ferror-limit 19 -fmessage-length 183 -stack-
protector 1 -fblocks -fencode-extended-block-signature -fcoroutines-ts -fobjc-
runtime=macosx-10.12.0 -fcxx-exceptions -fexceptions -fmax-type-align=16 -
fdiagnostics-show-option -fcolor-diagnostics -o test.o -x c++ test.cpp
1.  <eof> parser at end of file
2.  Per-module optimization passes
3.  Running pass 'CallGraph Pass Manager' on module 'test.cpp'.
clang-6.0: error: unable to execute command: Abort trap: 6
clang-6.0: error: clang frontend command failed due to signal (use -v to see
invocation)
clang version 6.0.0 (http://llvm.org/git/clang.git
a5d15d15a4534ca7e221af8f7bc421300ae0e4a2) (http://llvm.org/git/llvm.git
d90f53e14ab206e2903596f3cf679b70a2a5babc)
Target: x86_64-apple-darwin16.7.0
Thread model: posix
InstalledDir: /Users/eniebler/./llvm-install/bin
clang-6.0: note: diagnostic msg: PLEASE submit a bug report to
http://llvm.org/bugs/ and include the crash backtrace, preprocessed source, and
associated run script.
clang-6.0: note: diagnostic msg:
********************

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

********************
Quuxplusone commented 7 years ago

Attached test.cpp (3949 bytes, text/plain): repro

Quuxplusone commented 7 years ago

Eric, can you confirm that it reproes on trunk?

Quuxplusone commented 7 years ago

I just pulled and rebuilt. It still repros on trunk, I'm afraid. :-(

Quuxplusone commented 6 years ago

Attached file_35270.txt (48199 bytes, text/plain): another_repro_no_inline.ll

Quuxplusone commented 6 years ago

Is this for sure a Clang bug as opposed to an LLVM bug?

Quuxplusone commented 6 years ago

I've put some work into investigating this and https://bugs.llvm.org/show_bug.cgi?id=35048. I believe the two are exposing a related issue in LLVM, which I think is centered in the interaction between the inlining and coroutine splitting passes. I'm not yet certain.

I've found several LLVM IR files that trigger the assertion reported here. For example, this IR, https://gist.github.com/modocache/fe49375b039c888d2869c642907213d0, when run with 'opt -inline -coro-early -coro-split -coro-elide', hits the assertion reported here. Using bugpoint I reduced this to https://gist.github.com/modocache/1a3b9fc5b327a7a67e4443e180bad3d4, which still triggers the assert (but I'm not sure if it's still valid coroutines IR).

Considering the assertion is hit using just IR, I think this is a bug in LLVM, not Clang.