[llvm-bugs] [Bug 46011] New: Toy Fibonacci program in IR causes segfault during optimization passes

via llvm-bugs llvm-bugs at lists.llvm.org
Wed May 20 13:47:47 PDT 2020


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

            Bug ID: 46011
           Summary: Toy Fibonacci program in IR causes segfault during
                    optimization passes
           Product: libraries
           Version: 10.0
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: Loop Optimizer
          Assignee: unassignedbugs at nondot.org
          Reporter: ambrus at gmail.com
                CC: llvm-bugs at lists.llvm.org

The following program crashes clang in the llvm optimization passes on OSX,
Windows/MSYS64, and Linux Mint.

It's entirely possible the program has a bug, but it should probably return a
more graceful error, rather than crashing the compiler.

; crash.ll
define i64 @fib(i64 %n) {
entry:
  %is0 = icmp eq i64 %n, 0
  br i1 %is0, label %return_0, label %loop
return_0:
  ret i64 0
loop:
  %i = phi i64 [2, %entry], [%ii, %loop]
  %ii = add i64 %i, 1

  %a = phi i64 [1, %entry], [%b, %loop]
  %b = phi i64 [1, %entry], [%c, %loop]
  %c = add i64 %a, %b

  %continue = icmp ule i64 %ii, %n
  br i1 %continue, label %loop, label %done
done:
  ret i64 %b
}


Stack trace from Windows/MSYS64 (the other platforms appear to have the same
crash, but with less complete stack traces).

$ clang -S crash.ll -o crashopt.ll -emit-llvm -O1
warning: overriding the module target triple with x86_64-w64-windows-gnu
[-Woverride-module]
Stack dump:
0.      Program arguments: C:\msys64\mingw64\bin\clang.exe -cc1 -triple
x86_64-w64-windows-gnu -emit-llvm -disable-free -disable-llvm-verifier
-discard-value-names -main-file-name crash.ll -mrelocation-model pic -pic-level
2 -mthread-model posix -fmath-errno -masm-verbose -mconstructor-aliases
-munwind-tables -target-cpu x86-64 -dwarf-column-info -debugger-tuning=gdb
-momit-leaf-frame-pointer -coverage-notes-file
C:\Users\ambrus\llvmcrash\crashopt.gcno -resource-dir
C:\msys64\mingw64\lib\clang\9.0.0 -O1 -fdebug-compilation-dir
C:\Users\ambrus\llvmcrash -ferror-limit 19 -fmessage-length 0
-fno-use-cxa-atexit -fobjc-runtime=gcc -fseh-exceptions
-fdiagnostics-show-option -faddrsig -o crashopt.ll -x ir crash.ll
1.      Per-module optimization passes
2.      Running pass 'CallGraph Pass Manager' on module 'crash.ll'.
3.      Running pass 'Combine redundant instructions' on function '@fib'
 #0 0x000000006cf43bf0 llvm::InstCombiner::visitPHINode(llvm::PHINode&)
(C:\msys64\mingw64\bin\libLLVM.dll+0xb83bf0)
 #1 0x000000006ceb9002 llvm::InstCombiner::run()
(C:\msys64\mingw64\bin\libLLVM.dll+0xaf9002)
 #2 0x000000006ceba951 llvm::InstCombiner::run()
(C:\msys64\mingw64\bin\libLLVM.dll+0xafa951)
 #3 0x000000006cebaca4
llvm::InstructionCombiningPass::runOnFunction(llvm::Function&)
(C:\msys64\mingw64\bin\libLLVM.dll+0xafaca4)
 #4 0x000000006c59fef8 llvm::FPPassManager::runOnFunction(llvm::Function&)
(C:\msys64\mingw64\bin\libLLVM.dll+0x1dfef8)
 #5 0x000000006d344d71 llvm::initializeDummyCGSCCPassPass(llvm::PassRegistry&)
(C:\msys64\mingw64\bin\libLLVM.dll+0xf84d71)
 #6 0x000000006c59f2cb llvm::legacy::PassManagerImpl::run(llvm::Module&)
(C:\msys64\mingw64\bin\libLLVM.dll+0x1df2cb)
 #7 0x0000000067ff2633 clang::EmitBackendOutput(clang::DiagnosticsEngine&,
clang::HeaderSearchOptions const&, clang::CodeGenOptions const&,
clang::TargetOptions const&, clang::LangOptions const&, llvm::DataLayout
const&, llvm::Module*, clang::BackendAction,
std::unique_ptr<llvm::raw_pwrite_stream,
std::default_delete<llvm::raw_pwrite_stream> >)
(C:\msys64\mingw64\bin\libclang-cpp.dll+0xbf2633)
 #8 0x000000006829fa60 clang::CodeGenAction::ExecuteAction()
(C:\msys64\mingw64\bin\libclang-cpp.dll+0xe9fa60)
 #9 0x000000006895ccd9 clang::FrontendAction::Execute()
(C:\msys64\mingw64\bin\libclang-cpp.dll+0x155ccd9)
#10 0x000000006891cb81
clang::CompilerInstance::ExecuteAction(clang::FrontendAction&)
(C:\msys64\mingw64\bin\libclang-cpp.dll+0x151cb81)
#11 0x00000000689bf689
clang::ExecuteCompilerInvocation(clang::CompilerInstance*)
(C:\msys64\mingw64\bin\libclang-cpp.dll+0x15bf689)
#12 0x000000000040217b (C:\msys64\mingw64\bin\clang.exe+0x217b)
#13 0x0000000000413b07 (C:\msys64\mingw64\bin\clang.exe+0x13b07)
#14 0x00000000004013b4 (C:\msys64\mingw64\bin\clang.exe+0x13b4)
#15 0x000000000040150b (C:\msys64\mingw64\bin\clang.exe+0x150b)
#16 0x00007ffc34f37bd4 (C:\WINDOWS\System32\KERNEL32.DLL+0x17bd4)
#17 0x00007ffc350ace51 (C:\WINDOWS\SYSTEM32\ntdll.dll+0x6ce51)
clang: error: clang frontend command failed due to signal (use -v to see
invocation)
clang version 9.0.0 (https://github.com/msys2/MINGW-packages.git
ded8515833d0acc22453a8b5d2adb73cbf355fe1)
Target: x86_64-w64-windows-gnu
Thread model: posix
InstalledDir: C:\msys64\mingw64\bin
clang: 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: note: diagnostic msg: Error generating preprocessed source(s) - no
preprocessable inputs.

-- 
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/20200520/3a57a56a/attachment-0001.html>


More information about the llvm-bugs mailing list