Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Segmentation fault in codegenprepare pass #92270

Closed
zhangxiaosa opened this issue May 15, 2024 · 4 comments
Closed

Segmentation fault in codegenprepare pass #92270

zhangxiaosa opened this issue May 15, 2024 · 4 comments
Labels
invalid Resolved as invalid, i.e. not a bug

Comments

@zhangxiaosa
Copy link

I found a segmentation fault in codegenprepare pass, and this is how to reproduce:
Bug-triggering program:

$ cat input.ll
define i32 @a() { ret i32 0 }

LLVM version:

$ git rev-parse --short HEAD
7c8176ebd39c
$ ./opt --version
LLVM (http://llvm.org/):
  LLVM version 19.0.0git
  Optimized build.
  Default target: x86_64-unknown-linux-gnu
  Host CPU: icelake-server

Command to reproduce:

$ ./opt -passes=codegenprepare input.ll
WARNING: You're attempting to print out a bitcode file.
This is inadvisable as it may cause display problems. If
you REALLY want to taste LLVM bitcode first-hand, you
can force output with the `-f' option.

PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
Stack dump:
0.	Program arguments: ./opt -passes=codegenprepare input.ll
 #0 0x0000557b3f481740 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (./opt+0x44fd740)
 #1 0x0000557b3f47ed0e SignalHandler(int) Signals.cpp:0:0
 #2 0x00007f99e987b520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
 #3 0x0000557b3d78b6ad llvm::CodeGenPreparePass::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (./opt+0x28076ad)
 #4 0x0000557b3ca63506 llvm::detail::PassModel<llvm::Function, llvm::CodeGenPreparePass, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (./opt+0x1adf506)
 #5 0x0000557b3bb2c660 llvm::detail::PassModel<llvm::Function, llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (./opt+0xba8660)
 #6 0x0000557b3f27b7ea llvm::ModuleToFunctionPassAdaptor::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (./opt+0x42f77ea)
 #7 0x0000557b3bb1fa36 llvm::detail::PassModel<llvm::Module, llvm::ModuleToFunctionPassAdaptor, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (./opt+0xb9ba36)
 #8 0x0000557b3f2785e7 llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (./opt+0x42f45e7)
 #9 0x0000557b3b6b7fd6 llvm::runPassPipeline(llvm::StringRef, llvm::Module&, llvm::TargetMachine*, llvm::TargetLibraryInfoImpl*, llvm::ToolOutputFile*, llvm::ToolOutputFile*, llvm::ToolOutputFile*, llvm::StringRef, llvm::ArrayRef<llvm::PassPlugin>, llvm::ArrayRef<std::function<void (llvm::PassBuilder&)>>, llvm::opt_tool::OutputKind, llvm::opt_tool::VerifierKind, bool, bool, bool, bool, bool, bool, bool) (./opt+0x733fd6)
#10 0x0000557b3b6ab897 optMain (./opt+0x727897)
#11 0x00007f99e9862d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)
#12 0x00007f99e9862e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)
#13 0x0000557b3b6a22d5 _start (./opt+0x71e2d5)
Segmentation fault (core dumped)
@dtcxzyw dtcxzyw added invalid Resolved as invalid, i.e. not a bug and removed new issue labels May 15, 2024
@dtcxzyw
Copy link
Member

dtcxzyw commented May 15, 2024

Can you try ./opt -passes='require<profile-summary>,function(codegenprepare)' input.ll?

See #77182.
cc @nickleus27

@dtcxzyw dtcxzyw closed this as not planned Won't fix, can't repro, duplicate, stale May 15, 2024
@zhangxiaosa
Copy link
Author

Here is the result:

$ ./opt -passes='require<profile-summary>,function(codegenprepare)' input.ll
WARNING: You're attempting to print out a bitcode file.
This is inadvisable as it may cause display problems. If
you REALLY want to taste LLVM bitcode first-hand, you
can force output with the `-f' option.

PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
Stack dump:
0.	Program arguments: ./opt -passes=require<profile-summary>,function(codegenprepare) input.ll
 #0 0x0000563cfb908740 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (./opt+0x44fd740)
 #1 0x0000563cfb905d0e SignalHandler(int) Signals.cpp:0:0
 #2 0x00007f6a6674a520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
 #3 0x0000563cf9c126ad llvm::CodeGenPreparePass::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (./opt+0x28076ad)
 #4 0x0000563cf8eea506 llvm::detail::PassModel<llvm::Function, llvm::CodeGenPreparePass, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (./opt+0x1adf506)
 #5 0x0000563cf7fb3660 llvm::detail::PassModel<llvm::Function, llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (./opt+0xba8660)
 #6 0x0000563cfb7027ea llvm::ModuleToFunctionPassAdaptor::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (./opt+0x42f77ea)
 #7 0x0000563cf7fa6a36 llvm::detail::PassModel<llvm::Module, llvm::ModuleToFunctionPassAdaptor, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (./opt+0xb9ba36)
 #8 0x0000563cfb6ff5e7 llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (./opt+0x42f45e7)
 #9 0x0000563cf7b3efd6 llvm::runPassPipeline(llvm::StringRef, llvm::Module&, llvm::TargetMachine*, llvm::TargetLibraryInfoImpl*, llvm::ToolOutputFile*, llvm::ToolOutputFile*, llvm::ToolOutputFile*, llvm::StringRef, llvm::ArrayRef<llvm::PassPlugin>, llvm::ArrayRef<std::function<void (llvm::PassBuilder&)>>, llvm::opt_tool::OutputKind, llvm::opt_tool::VerifierKind, bool, bool, bool, bool, bool, bool, bool) (./opt+0x733fd6)
#10 0x0000563cf7b32897 optMain (./opt+0x727897)
#11 0x00007f6a66731d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)
#12 0x00007f6a66731e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)
#13 0x0000563cf7b292d5 _start (./opt+0x71e2d5)
Segmentation fault (core dumped)

@dtcxzyw
Copy link
Member

dtcxzyw commented May 16, 2024

Oh, I forgot to tell you to specify target triple.

target triple = "x86_64-unknown-linux-gnu"
define i32 @a() { ret i32 0 }

It should work without crash.

@zhangxiaosa
Copy link
Author

Yes, it does not crash this time. Thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
invalid Resolved as invalid, i.e. not a bug
Projects
None yet
Development

No branches or pull requests

2 participants