<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/68529>68529</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            opt crash with -passes="adce,instcombine,mem2reg,jump-threading,sink" 
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            new issue
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          Bazoka13
      </td>
    </tr>
</table>

<pre>
    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)
```

```llvm
; 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"}
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzkWVtvoz4W_zTuixUE5v7QhySdaKud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