llvm / llvm-project

The LLVM Project is a collection of modular and reusable compiler and toolchain technologies.
http://llvm.org
Other
28.97k stars 11.94k forks source link

Crash when compiling LLVM IR with tons of musttail calls #35833

Closed llvmbot closed 2 years ago

llvmbot commented 6 years ago
Bugzilla Link 36485
Resolution FIXED
Resolved on Apr 02, 2018 13:13
Version unspecified
OS All
Attachments LLVM IR file
Reporter LLVM Bugzilla Contributor
CC @fhahn,@rnk

Extended Description

0 clang-5.0 0x00000001075c31e7 llvm::sys::PrintStackTrace(llvm::raw_ostream&) + 37 1 clang-5.0 0x00000001075c26ea llvm::sys::RunSignalHandlers() + 83 2 clang-5.0 0x00000001075c360e SignalHandler(int) + 239 3 libsystem_platform.dylib 0x00007fff784cef5a _sigtramp + 26 4 libsystem_platform.dylib 000000000000000000 _sigtramp + 2276659392 5 clang-5.0 0x0000000107553049 getCommonReturnValue(llvm::ReturnInst, llvm::CallInst) + 120 6 clang-5.0 0x000000010755280a eliminateRecursiveTailCall(llvm::CallInst, llvm::ReturnInst, llvm::BasicBlock&, bool&, llvm::SmallVectorImpl<llvm::PHINode>&, llvm::AAResults) + 735 7 clang-5.0 0x00000001075517b6 eliminateTailRecursion(llvm::Function&, llvm::TargetTransformInfo const, llvm::AAResults) + 2287 8 clang-5.0 0x000000010729c2b4 llvm::FPPassManager::runOnFunction(llvm::Function&) + 276 9 clang-5.0 0x0000000106f7cb71 (anonymous namespace)::CGPassManager::runOnModule(llvm::Module&) + 661 10 clang-5.0 0x000000010729c7a5 llvm::legacy::PassManagerImpl::run(llvm::Module&) + 579 11 clang-5.0 0x00000001076e9df8 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 >) + 9714 12 clang-5.0 0x000000010781fe97 clang::CodeGenAction::ExecuteAction() + 973 13 clang-5.0 0x00000001079986db clang::FrontendAction::Execute() + 73 14 clang-5.0 0x000000010796980b clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) + 625 15 clang-5.0 0x00000001079c5a66 clang::ExecuteCompilerInvocation(clang::CompilerInstance) + 2438 16 clang-5.0 0x00000001066f0411 cc1_main(llvm::ArrayRef<char const>, char const, void) + 1169 17 clang-5.0 0x00000001066eee70 main + 8127 18 libdyld.dylib 0x00007fff7824e145 start + 1 19 libdyld.dylib 0x0000000000000033 start + 2279284463 Stack dump:

  1. Program arguments: /usr/local/Cellar/llvm/5.0.1/bin/clang-5.0 -cc1 -triple x86_64-apple-macosx10.13.0 -Wdeprecated-objc-isa-usage -Werror=deprecated-objc-isa-usage -emit-obj -disable-free -disable-llvm-verifier -discard-value-names -main-file-name otherwise-skip.ll -mrelocation-model pic -pic-level 2 -mthread-model posix -mdisable-fp-elim -masm-verbose -munwind-tables -target-cpu penryn -target-linker-version 305 -dwarf-column-info -debugger-tuning=lldb -resource-dir /usr/local/Cellar/llvm/5.0.1/lib/clang/5.0.1 -Os -fdebug-compilation-dir /Users/findutnyy/Code/indutny/llparse -ferror-limit 19 -fmessage-length 178 -stack-protector 1 -fblocks -fobjc-runtime=macosx-10.13.0 -fencode-extended-block-signature -fmax-type-align=16 -fdiagnostics-show-option -fcolor-diagnostics -vectorize-loops -vectorize-slp -o /var/folders/7l/34nn743x7hv3pwhp4pjplxxc3kfgkf/T/otherwise-skip-5b8771.o -x ir test/tmp/otherwise-skip.ll
  2. Per-module optimization passes
  3. Running pass 'CallGraph Pass Manager' on module 'test/tmp/otherwise-skip.ll'.
  4. Running pass 'Tail Call Elimination' on function '@llparse__n_start' clang-5.0: error: unable to execute command: Segmentation fault: 11 clang-5.0: error: clang frontend command failed due to signal (use -v to see invocation) clang version 5.0.1 (tags/RELEASE_501/final) Target: x86_64-apple-darwin17.0.0 Thread model: posix InstalledDir: /usr/local/opt/llvm/bin
llvmbot commented 2 years ago

mentioned in issue llvm/llvm-bugzilla-archive#36604

rnk commented 6 years ago

Fixed in r326404.

llvmbot commented 6 years ago

Here is the proposed fix: https://reviews.llvm.org/D43695

llvmbot commented 6 years ago

Minimal LLVM IR file Minimal test case

llvmbot commented 6 years ago

Looks like SSCP is a culprit again:

BISECT: running pass (8) Interprocedural Sparse Conditional Constant Propagation on module (./test/tmp/otherwise-skip.ll)

...

musttail call result must be returned ret i8 bitcast (i8 (i8, i8, i32) @​llparse__n_start to i8) musttail call result must be returned ret i8 bitcast (i8 (i8, i8, i32) @​llparse__n_start to i8)

llvmbot commented 6 years ago

Here goes Debug build assertion:

Assertion failed: (i_nocapture < OperandTraits::operands(this) && "getOperand() out of range!"), function getOperand, file /Users/findutnyy/Code/llvm-mirror/llvm/include/llvm/IR/Instructions.h, line 3141. 0 clang-7.0 0x000000010eaea43c llvm::sys::PrintStackTrace(llvm::raw_ostream&) + 60 1 clang-7.0 0x000000010eaeaa39 PrintStackTraceSignalHandler(void) + 25 2 clang-7.0 0x000000010eae63c9 llvm::sys::RunSignalHandlers() + 425 3 clang-7.0 0x000000010eaeae32 SignalHandler(int) + 354 4 libsystem_platform.dylib 0x00007fff784cef5a _sigtramp + 26 5 libsystem_platform.dylib 0x00007ff154c45318 _sigtramp + 3698811864 6 libsystem_c.dylib 0x00007fff782fa32a abort + 127 7 libsystem_c.dylib 0x00007fff782c2380 basename_r + 0 8 clang-7.0 0x000000010d3998e6 llvm::ReturnInst::getOperand(unsigned int) const + 118 9 clang-7.0 0x000000010e934d97 getCommonReturnValue(llvm::ReturnInst, llvm::CallInst) + 183 10 clang-7.0 0x000000010e933fba eliminateRecursiveTailCall(llvm::CallInst, llvm::ReturnInst, llvm::BasicBlock&, bool&, llvm::SmallVectorImpl<llvm::PHINode>&, llvm::AAResults, llvm::OptimizationRemarkEmitter) + 474 11 clang-7.0 0x000000010e9314a9 processReturningBlock(llvm::ReturnInst, llvm::BasicBlock&, bool&, llvm::SmallVectorImpl<llvm::PHINode>&, bool, llvm::TargetTransformInfo const, llvm::AAResults, llvm::OptimizationRemarkEmitter) + 137 12 clang-7.0 0x000000010e93054a eliminateTailRecursion(llvm::Function&, llvm::TargetTransformInfo const, llvm::AAResults, llvm::OptimizationRemarkEmitter) + 1226 13 clang-7.0 0x000000010e930961 (anonymous namespace)::TailCallElim::runOnFunction(llvm::Function&) + 161 14 clang-7.0 0x000000010de559cf llvm::FPPassManager::runOnFunction(llvm::Function&) + 399 15 clang-7.0 0x000000010d27bf1c (anonymous namespace)::CGPassManager::RunPassOnSCC(llvm::Pass, llvm::CallGraphSCC&, llvm::CallGraph&, bool&, bool&) + 796 16 clang-7.0 0x000000010d27a6d9 (anonymous namespace)::CGPassManager::RunAllPassesOnSCC(llvm::CallGraphSCC&, llvm::CallGraph&, bool&) + 1561 17 clang-7.0 0x000000010d279ac3 (anonymous namespace)::CGPassManager::runOnModule(llvm::Module&) + 419 18 clang-7.0 0x000000010de56ca4 (anonymous namespace)::MPPassManager::runOnModule(llvm::Module&) + 2196 19 clang-7.0 0x000000010de56196 llvm::legacy::PassManagerImpl::run(llvm::Module&) + 342 20 clang-7.0 0x000000010de579d1 llvm::legacy::PassManager::run(llvm::Module&) + 33 21 clang-7.0 0x000000010ef446b3 (anonymous namespace)::EmitAssemblyHelper::EmitAssembly(clang::BackendAction, std::__1::unique_ptr<llvm::raw_pwrite_stream, std::__1::default_delete >) + 4771 22 clang-7.0 0x000000010ef3e67d 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 >) + 6077 23 clang-7.0 0x000000010f332638 clang::CodeGenAction::ExecuteAction() + 5000 24 clang-7.0 0x000000010faaaed0 clang::FrontendAction::Execute() + 112 25 clang-7.0 0x000000010f9bb2cd clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) + 2285 26 clang-7.0 0x000000010fb76879 clang::ExecuteCompilerInvocation(clang::CompilerInstance) + 5849 27 clang-7.0 0x000000010b84b820 cc1_main(llvm::ArrayRef<char const>, char const, void) + 4944 28 clang-7.0 0x000000010b83a2be ExecuteCC1Tool(llvm::ArrayRef<char const*>, llvm::StringRef) + 622 29 clang-7.0 0x000000010b83794a main + 4282 30 libdyld.dylib 0x00007fff7824e145 start + 1 Stack dump:

  1. Program arguments: /Users/findutnyy/Code/llvm-mirror/build/bin/clang-7.0 -cc1 -triple i386-apple-macosx10.13.0 -emit-obj -disable-free -main-file-name otherwise-skip.ll -mrelocation-model pic -pic-level 2 -mthread-model posix -mdisable-fp-elim -masm-verbose -munwind-tables -target-cpu penryn -dwarf-column-info -debug-info-kind=standalone -dwarf-version=4 -debugger-tuning=lldb -target-linker-version 305 -resource-dir /Users/findutnyy/Code/llvm-mirror/build/lib/clang/7.0.0 -Os -fdebug-compilation-dir /Users/findutnyy/Code/indutny/llparse -ferror-limit 19 -fmessage-length 0 -fvisibility hidden -stack-protector 1 -fblocks -fencode-extended-block-signature -fobjc-runtime=macosx-fragile-10.13.0 -fobjc-subscripting-legacy-runtime -fmax-type-align=16 -fdiagnostics-show-option -vectorize-loops -vectorize-slp -o /var/folders/7l/34nn743x7hv3pwhp4pjplxxc3kfgkf/T/otherwise-skip-5b6595.o -x ir /Users/findutnyy/Code/indutny/llparse/test/tmp/otherwise-skip.ll
  2. Per-module optimization passes
  3. Running pass 'CallGraph Pass Manager' on module '/Users/findutnyy/Code/indutny/llparse/test/tmp/otherwise-skip.ll'.
  4. Running pass 'Tail Call Elimination' on function '@llparse__n_start' clang-7.0: error: unable to execute command: Abort trap: 6 clang-7.0: error: clang frontend command failed due to signal (use -v to see invocation) clang version 7.0.0 (git@github.com:llvm-mirror/clang.git 0972dc790621cb6c6718ef9a5090a993cc0724c2) (git@github.com:llvm-mirror/llvm.git d5784797c6647bd72ab37232ab432785a04a71df) Target: i386-apple-darwin17.0.0 Thread model: posix InstalledDir: /Users/findutnyy/Code/llvm-mirror/build/bin clang-7.0: note: diagnostic msg: PLEASE submit a bug report to https://bugs.llvm.org/ and include the crash backtrace, preprocessed source, and associated run script. clang-7.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-7.0: note: diagnostic msg: /var/folders/7l/34nn743x7hv3pwhp4pjplxxc3kfgkf/T/fixture-e9643f.c clang-7.0: note: diagnostic msg: /var/folders/7l/34nn743x7hv3pwhp4pjplxxc3kfgkf/T/extra-fad3b8.c clang-7.0: note: diagnostic msg: /var/folders/7l/34nn743x7hv3pwhp4pjplxxc3kfgkf/T/fixture-e9643f.sh clang-7.0: note: diagnostic msg: Crash backtrace is located in clang-7.0: note: diagnostic msg: /Users/findutnyy/Library/Logs/DiagnosticReports/clang-7.0.crash clang-7.0: note: diagnostic msg: (choose the .crash file that corresponds to your crash) clang-7.0: note: diagnostic msg:


llvmbot commented 6 years ago

Going to take a look at it myself. Any hints are welcome!