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

opt crash with -passes="adce,instcombine,mem2reg,jump-threading,sink" #68529

Closed
Bazoka13 opened this issue Oct 8, 2023 · 1 comment · Fixed by #68576
Closed

opt crash with -passes="adce,instcombine,mem2reg,jump-threading,sink" #68529

Bazoka13 opened this issue Oct 8, 2023 · 1 comment · Fixed by #68576

Comments

@Bazoka13
Copy link

Bazoka13 commented Oct 8, 2023

opt -passes="adce,instcombine,mem2reg,jump-threading,sink" -o a.opt.bc a.ll

PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
Stack dump:
0. Program arguments: /home/llvm-project-17.0.2.src/build/bin/opt -passes=adce,instcombine,mem2reg,jump-threading,sink -o a.opt.bc a.ll
 #0 0x00005585c2609bff llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/home/llvm-project-17.0.2.src/build/bin/opt+0x309abff)
 #1 0x00005585c2607674 SignalHandler(int) Signals.cpp:0:0
 #2 0x00007f377910e420 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x14420)
 #3 0x00005585c24e9b6c iterativelySinkInstructions(llvm::Function&, llvm::DominatorTree&, llvm::LoopInfo&, llvm::AAResults&) Sink.cpp:0:0
 #4 0x00005585c24ea68b llvm::SinkingPass::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/home/llvm-project-17.0.2.src/build/bin/opt+0x2f7b68b)
 #5 0x00005585c2832ef6 llvm::detail::PassModel<llvm::Function, llvm::SinkingPass, llvm::PreservedAnalyses, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/home/llvm-project-17.0.2.src/build/bin/opt+0x32c3ef6)
 #6 0x00005585c015bb94 llvm::detail::PassModel<llvm::Function, llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>, llvm::PreservedAnalyses, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/home/llvm-project-17.0.2.src/build/bin/opt+0xbecb94)
 #7 0x00005585c1f76eae llvm::ModuleToFunctionPassAdaptor::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/home/llvm-project-17.0.2.src/build/bin/opt+0x2a07eae)
 #8 0x00005585c0151776 llvm::detail::PassModel<llvm::Module, llvm::ModuleToFunctionPassAdaptor, llvm::PreservedAnalyses, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/home/llvm-project-17.0.2.src/build/bin/opt+0xbe2776)
 #9 0x00005585bfd3e7d7 llvm::runPassPipeline(llvm::StringRef, llvm::Module&, llvm::TargetMachine*, llvm::TargetLibraryInfoImpl*, llvm::ToolOutputFile*, llvm::ToolOutputFile*, llvm::ToolOutputFile*, llvm::StringRef, llvm::ArrayRef<llvm::PassPlugin>, llvm::opt_tool::OutputKind, llvm::opt_tool::VerifierKind, bool, bool, bool, bool, bool, bool, bool) (/home/llvm-project-17.0.2.src/build/bin/opt+0x7cf7d7)
#10 0x00005585bfc53f37 main (/home/llvm-project-17.0.2.src/build/bin/opt+0x6e4f37)
#11 0x00007f3778b8c083 __libc_start_main /build/glibc-SzIz7B/glibc-2.31/csu/../csu/libc-start.c:342:3
#12 0x00005585bfd32dbe _start (/home/llvm-project-17.0.2.src/build/bin/opt+0x7c3dbe)
Segmentation fault (core dumped)
; ModuleID = 'a.c'
source_filename = "a.c"
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"

; Function Attrs: nounwind uwtable
define dso_local i32 @a(i32 noundef %0) #0 {
  %2 = alloca i32, align 4
  %3 = alloca i32, align 4
  store i32 %0, ptr %2, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #2
  %4 = load i32, ptr %2, align 4, !tbaa !5
  %5 = icmp ne i32 %4, 0
  br i1 %5, label %6, label %15

6:                                                ; preds = %1
  %7 = load i32, ptr %3, align 4, !tbaa !5
  %8 = trunc i32 %7 to i16
  %9 = zext i16 %8 to i32
  store i32 %9, ptr %2, align 4, !tbaa !5
  %10 = icmp ne i32 %9, 0
  br i1 %10, label %11, label %12

11:                                               ; preds = %6
  br label %12

12:                                               ; preds = %11, %6
  %13 = phi i1 [ false, %6 ], [ true, %11 ]
  %14 = zext i1 %13 to i32
  br label %15

15:                                               ; preds = %12, %1
  %16 = load i32, ptr %2, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #2
  ret i32 %16
}

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #1

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1

; Function Attrs: nounwind uwtable
define dso_local i32 @main() #0 {
  ret i32 0
}

attributes #0 = { nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #1 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { nounwind }

!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 17.0.2"}
!5 = !{!6, !6, i64 0}
!6 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
@XChy
Copy link
Member

XChy commented Oct 9, 2023

Reduced IR before sink pass.

@XChy XChy self-assigned this Oct 9, 2023
@XChy XChy removed their assignment Oct 9, 2023
nstester pushed a commit to nstester/llvm-project that referenced this issue Oct 9, 2023
Resolve llvm#68529.
Sink pass doesn't consider whether Basicblock from phi is unreachable.
This patch moves unreachability check after checking phi.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants