llvm / llvm/llvm-project

[opt] -passes='reg2mem' causes Broken Module (CatchSwitchInst not the first non-PHI instruction in the block.)

Open
#192,020 5 comments 0 reactions 0 assignees View on GitHub
confirmed crash-on-valid generated by fuzzer llvm:optimizations
Dominant language
LLVM
Stars
40.5k
Forks
18.7k
PR merge metrics
PR metrics pending

Description

Reproducer: https://godbolt.org/z/vYGzErqTe

```
CatchSwitchInst not the first non-PHI instruction in the block.
%0 = catchswitch within none [label %catch] unwind label %catch.dispatch2
LLVM ERROR: Broken function found after pass "RegToMemPass", compilation aborted!
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace and instructions to reproduce the bug.
Stack dump:
0. Program arguments: /opt/compiler-explorer/clang-assertions-trunk/bin/opt -o /app/output.s -S -verify-each -passes=reg2mem
1. Running pass "function(reg2mem)" on module ""
2. Running pass "reg2mem" on function "fn3"
#0 0x0000000005c4f168 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x5c4f168)
#1 0x0000000005c4bf94 llvm::sys::RunSignalHandlers() (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x5c4bf94)
#2 0x0000000005c4c10a SignalHandler(int, siginfo_t*, void*) Signals.cpp:0:0
#3 0x000074a8e7042520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
#4 0x000074a8e70969fc pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x969fc)
#5 0x000074a8e7042476 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x42476)
#6 0x000074a8e70287f3 abort (/lib/x86_64-linux-gnu/libc.so.6+0x287f3)
#7 0x0000000000828885 llvm::json::operator==(llvm::json::Value const&, llvm::json::Value const&) (.cold) JSON.cpp:0:0
#8 0x00000000032951ec llvm::VerifyInstrumentation::registerCallbacks(llvm::PassInstrumentationCallbacks&, llvm::AnalysisManager*)::'lambda'(llvm::StringRef, llvm::Any, llvm::PreservedAnalyses const&)::operator()(llvm::StringRef, llvm::Any, llvm::PreservedAnalyses const&) const (.isra.0) StandardInstrumentations.cpp:0:0
#9 0x00000000032954bd void llvm::detail::UniqueFunctionBase::CallImpl*)::'lambda'(llvm::StringRef, llvm::Any, llvm::PreservedAnalyses const&)>(void*, llvm::StringRef, llvm::Any&, llvm::PreservedAnalyses const&) StandardInstrumentations.cpp:0:0
#10 0x00000000059b07bf llvm::PassManager>::run(llvm::Function&, llvm::AnalysisManager&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x59b07bf)
#11 0x0000000000f26b6e llvm::detail::PassModel>, llvm::AnalysisManager>::run(llvm::Function&, llvm::AnalysisManager&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0xf26b6e)
#12 0x00000000059af896 llvm::ModuleToFunctionPassAdaptor::run(llvm::Module&, llvm::AnalysisManager&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x59af896)
#13 0x0000000000964f4e llvm::detail::PassModel>::run(llvm::Module&, llvm::AnalysisManager&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x964f4e)
#14 0x00000000059b2266 llvm::PassManager>::run(llvm::Module&, llvm::AnalysisManager&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x59b2266)
#15 0x000000000096f03a llvm::runPassPipeline(llvm::StringRef, llvm::Module&, llvm::TargetMachine*, llvm::TargetLibraryInfoImpl*, llvm::ToolOutputFile*, llvm::ToolOutputFile*, llvm::ToolOutputFile*, llvm::StringRef, llvm::ArrayRef, llvm::ArrayRef>, llvm::opt_tool::OutputKind, llvm::opt_tool::VerifierKind, bool, bool, bool, bool, bool, bool, bool, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x96f03a)
#16 0x00000000009630df optMain (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x9630df)
#17 0x000074a8e7029d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)
#18 0x000074a8e7029e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)
#19 0x00000000009585c5 _start (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x9585c5)
Program terminated with signal: SIGSEGV
Compiler returned: 139
```

Generated by fuzzer.

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.