llvm / llvm/llvm-project

[RISC-V] Clang crashed at -O1 and above with asm goto

Open
#201,252 3 comments 0 reactions 0 assignees View on GitHub
confirmed crash-on-valid llvm:codegen
Dominant language
LLVM
Stars
40.5k
Forks
18.7k
PR merge metrics
PR metrics pending

Description

Compiler explorer: https://godbolt.org/z/59r5Ganhh

Testcase:

```c
int *a;
void b() {
__asm__ goto("" : "=r"(a) : : : c);
c:
a[1085] = a[1084];
}
```

Backtrace:
```
#4 0x0000000003566630 llvm::DomTreeBuilder::SemiNCAInfo>::getNodeInfo(llvm::BasicBlock*) (/opt/compiler-explorer/clang-trunk/bin/clang+0x3566630)
#5 0x0000000003566e06 unsigned int llvm::DomTreeBuilder::SemiNCAInfo>::runDFS(llvm::BasicBlock*, unsigned int, bool (*)(llvm::BasicBlock*, llvm::BasicBlock*), unsigned int, llvm::DenseMap, llvm::detail::DenseMapPair> const*) (.constprop.0) Dominators.cpp:0:0
#6 0x0000000003567599 llvm::DomTreeBuilder::SemiNCAInfo>::CalculateFromScratch(llvm::DominatorTreeBase&, llvm::DomTreeBuilder::SemiNCAInfo>::BatchUpdateInfo*) (/opt/compiler-explorer/clang-trunk/bin/clang+0x3567599)
#7 0x00000000035677cd llvm::DominatorTreeWrapperPass::runOnFunction(llvm::Function&) (/opt/compiler-explorer/clang-trunk/bin/clang+0x35677cd)
#8 0x00000000035d3be2 llvm::FPPassManager::runOnFunction(llvm::Function&) (/opt/compiler-explorer/clang-trunk/bin/clang+0x35d3be2)
#9 0x00000000035d3fd1 llvm::FPPassManager::runOnModule(llvm::Module&) (/opt/compiler-explorer/clang-trunk/bin/clang+0x35d3fd1)
#10 0x00000000035d567f llvm::legacy::PassManagerImpl::run(llvm::Module&) (/opt/compiler-explorer/clang-trunk/bin/clang+0x35d567f)
#11 0x000000000401ed92 clang::emitBackendOutput(clang::CompilerInstance&, clang::CodeGenOptions&, llvm::StringRef, llvm::Module*, clang::BackendAction, llvm::IntrusiveRefCntPtr, std::unique_ptr>, clang::BackendConsumer*) (/opt/compiler-explorer/clang-trunk/bin/clang+0x401ed92)
#12 0x0000000004663449 clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&) (/opt/compiler-explorer/clang-trunk/bin/clang+0x4663449)
#13 0x00000000062a62ec clang::ParseAST(clang::Sema&, bool, bool) (/opt/compiler-explorer/clang-trunk/bin/clang+0x62a62ec)
#14 0x0000000004663e95 clang::CodeGenAction::ExecuteAction() (/opt/compiler-explorer/clang-trunk/bin/clang+0x4663e95)
#15 0x00000000049a4daa clang::FrontendAction::Execute() (/opt/compiler-explorer/clang-trunk/bin/clang+0x49a4daa)
#16 0x0000000004922065 clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/opt/compiler-explorer/clang-trunk/bin/clang+0x4922065)
#17 0x0000000004a9e12b clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/opt/compiler-explorer/clang-trunk/bin/clang+0x4a9e12b)
#18 0x0000000000e0e958 cc1_main(llvm::ArrayRef, char const*, void*) (/opt/compiler-explorer/clang-trunk/bin/clang+0xe0e958)
#19 0x0000000000e0665b ExecuteCC1Tool(llvm::SmallVectorImpl&, llvm::ToolContext const&, llvm::IntrusiveRefCntPtr) driver.cpp:0:0
#20 0x0000000000e066fd int llvm::function_ref&)>::callback_fn&)>(long, llvm::SmallVectorImpl&) driver.cpp:0:0
#21 0x00000000046d8849 void llvm::function_ref::callback_fn>, std::__cxx11::basic_string, std::allocator>*, bool*) const::'lambda'()>(long) Job.cpp:0:0
#22 0x0000000003bbbf93 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref) (/opt/compiler-explorer/clang-trunk/bin/clang+0x3bbbf93)
#23 0x00000000046d8a69 clang::driver::CC1Command::Execute(llvm::ArrayRef>, std::__cxx11::basic_string, std::allocator>*, bool*) const (.part.0) Job.cpp:0:0
#24 0x0000000004699a52 clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const (/opt/compiler-explorer/clang-trunk/bin/clang+0x4699a52)
#25 0x000000000469a931 clang::driver::Compilation::ExecuteJobs(clang::driver::JobList const&, llvm::SmallVectorImpl>&, bool) const (/opt/compiler-explorer/clang-trunk/bin/clang+0x469a931)
#26 0x00000000046a36cc clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl>&) (/opt/compiler-explorer/clang-trunk/bin/clang+0x46a36cc)
#27 0x0000000000e0b171 clang_main(int, char**, llvm::ToolContext const&) (/opt/compiler-explorer/clang-trunk/bin/clang+0xe0b171)
#28 0x0000000000cb4bca main (/opt/compiler-explorer/clang-trunk/bin/clang+0xcb4bca)
#29 0x0000703290429d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)
#30 0x0000703290429e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)
#31 0x0000000000e060f5 _start (/opt/compiler-explorer/clang-trunk/bin/clang+0xe060f5)
```

Command:
```
clang -O1 --target=riscv64-linux-gnu --gcc-toolchain=/compiler/gcc-trunk-riscv64 --sysroot=/usr/riscv64-linux-gnu -c small.c
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace, preprocessed source, and associated run script.
Stack dump:
0. Program arguments: /compiler/llvm-trunk-aarch64/bin/clang -O1 --target=riscv64-linux-gnu --gcc-toolchain=/compiler/gcc-trunk-riscv64 --sysroot=/usr/riscv64-linux-gnu -c small.c
1. 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 '@b'
Segmentation fault (core dumped)
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.