; LLVM IR from NVIDIA/DALI :: dali/pipeline/executor/executor2/exec_graph.ll (ZN4dali5exec28ExecNode11AddDataDepsEv)

; Unoptimized IR (clang -disable-llvm-passes):
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"

%"class.dali::exec2::ExecNode" = type { %"class.dali::SmallVector", %"class.dali::SmallVector.3", %"class.std::shared_ptr", %"class.std::shared_ptr", %"class.std::unique_ptr", %"struct.dali::exec2::ExecEnv", %"class.std::__cxx11::basic_string", i32, i8, i8, i8, %"class.std::shared_ptr.8", %"class.std::shared_ptr.8", %"class.std::shared_ptr.8", %"class.std::unique_ptr.11", i8, %"class.dali::CUDASharedEvent", %"class.std::any" }
%"class.dali::SmallVector" = type { %union.anon.2, i64 }
%union.anon.2 = type { %struct.anon, [48 x i8] }
%struct.anon = type { ptr, i64 }
%"class.dali::SmallVector.3" = type { %union.anon.6, i64 }
%union.anon.6 = type { %struct.anon.7, [176 x i8] }
%struct.anon.7 = type { ptr, i64 }
%"class.std::shared_ptr" = type { %"class.std::__shared_ptr" }
%"class.std::__shared_ptr" = type { ptr, %"class.std::__shared_count" }
%"class.std::__shared_count" = type { ptr }
%"class.std::unique_ptr" = type { %"struct.std::__uniq_ptr_data" }
%"struct.std::__uniq_ptr_data" = type { %"class.std::__uniq_ptr_impl" }
%"class.std::__uniq_ptr_impl" = type { %"class.std::tuple" }
%"class.std::tuple" = type { %"struct.std::_Tuple_impl" }
%"struct.std::_Tuple_impl" = type { %"struct.std::_Head_base.1" }
%"struct.std::_Head_base.1" = type { ptr }
%"struct.dali::exec2::ExecEnv" = type { ptr, %"class.dali::AccessOrder" }
%"class.dali::AccessOrder" = type <{ ptr, i32, [4 x i8] }>
%"class.std::__cxx11::basic_string" = type { %"struct.std::__cxx11::basic_string<char>::_Alloc_hider", i64, %union.anon }
%"struct.std::__cxx11::basic_string<char>::_Alloc_hider" = type { ptr }
%union.anon = type { i64, [8 x i8] }
%"class.std::shared_ptr.8" = type { %"class.std::__shared_ptr.9" }
%"class.std::__shared_ptr.9" = type { ptr, %"class.std::__shared_count" }
%"class.std::unique_ptr.11" = type { %"struct.std::__uniq_ptr_data.12" }
%"struct.std::__uniq_ptr_data.12" = type { %"class.std::__uniq_ptr_impl.13" }
%"class.std::__uniq_ptr_impl.13" = type { %"class.std::tuple.14" }
%"class.std::tuple.14" = type { %"struct.std::_Tuple_impl.15" }
%"struct.std::_Tuple_impl.15" = type { %"struct.std::_Head_base.18" }
%"struct.std::_Head_base.18" = type { ptr }
%"class.dali::CUDASharedEvent" = type { %"class.std::shared_ptr.19" }
%"class.std::shared_ptr.19" = type { %"class.std::__shared_ptr.20" }
%"class.std::__shared_ptr.20" = type { ptr, %"class.std::__shared_count" }
%"class.std::any" = type { ptr, %"union.std::any::_Storage" }
%"union.std::any::_Storage" = type { ptr }
%"struct.dali::exec2::ExecEdge" = type <{ ptr, ptr, i32, i32, i32, i8, [3 x i8] }>

@.str.6 = external hidden unnamed_addr constant [92 x i8], align 1
@.str.16 = external hidden unnamed_addr constant [27 x i8], align 1
@__PRETTY_FUNCTION__._ZN4dali5exec28ExecNode11AddDataDepsEv = external hidden unnamed_addr constant [42 x i8], align 1

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

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

; Function Attrs: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) #1

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZNKSt12__shared_ptrIN4dali7tasking4TaskELN9__gnu_cxx12_Lock_policyE2EEcvbEv(ptr noundef nonnull align 8 dereferenceable(16)) #2 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef ptr @_ZNKSt19__shared_ptr_accessIN4dali7tasking4TaskELN9__gnu_cxx12_Lock_policyE2ELb0ELb0EEptEv(ptr noundef nonnull align 1 dereferenceable(1)) #2 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef ptr @_ZN4dali11SmallVectorIPNS_5exec28ExecEdgeELm8ESaIS3_EE5beginEv(ptr noundef nonnull align 8 dereferenceable(72)) #3 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef ptr @_ZN4dali11SmallVectorIPNS_5exec28ExecEdgeELm8ESaIS3_EE3endEv(ptr noundef nonnull align 8 dereferenceable(72)) #3 align 2

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN4dali5exec28ExecNode11AddDataDepsEv(ptr noundef nonnull align 8 dereferenceable(472) %0) #4 align 2 {
  %2 = alloca ptr, align 8
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  store ptr %0, ptr %2, align 8, !tbaa !5
  %7 = load ptr, ptr %2, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #5
  %8 = getelementptr inbounds %"class.dali::exec2::ExecNode", ptr %7, i32 0, i32 0
  store ptr %8, ptr %3, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #5
  %9 = load ptr, ptr %3, align 8, !tbaa !5
  %10 = call noundef ptr @_ZN4dali11SmallVectorIPNS_5exec28ExecEdgeELm8ESaIS3_EE5beginEv(ptr noundef nonnull align 8 dereferenceable(72) %9)
  store ptr %10, ptr %4, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #5
  %11 = load ptr, ptr %3, align 8, !tbaa !5
  %12 = call noundef ptr @_ZN4dali11SmallVectorIPNS_5exec28ExecEdgeELm8ESaIS3_EE3endEv(ptr noundef nonnull align 8 dereferenceable(72) %11)
  store ptr %12, ptr %5, align 8, !tbaa !5
  br label %13

13:                                               ; preds = %42, %1
  %14 = load ptr, ptr %4, align 8, !tbaa !5
  %15 = load ptr, ptr %5, align 8, !tbaa !5
  %16 = icmp ne ptr %14, %15
  br i1 %16, label %18, label %17

17:                                               ; preds = %13
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #5
  br label %45

18:                                               ; preds = %13
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #5
  %19 = load ptr, ptr %4, align 8, !tbaa !5
  store ptr %19, ptr %6, align 8, !tbaa !5
  %20 = load ptr, ptr %6, align 8, !tbaa !5
  %21 = load ptr, ptr %20, align 8, !tbaa !5
  %22 = getelementptr inbounds %"struct.dali::exec2::ExecEdge", ptr %21, i32 0, i32 0
  %23 = load ptr, ptr %22, align 8, !tbaa !9
  %24 = getelementptr inbounds %"class.dali::exec2::ExecNode", ptr %23, i32 0, i32 12
  %25 = call noundef zeroext i1 @_ZNKSt12__shared_ptrIN4dali7tasking4TaskELN9__gnu_cxx12_Lock_policyE2EEcvbEv(ptr noundef nonnull align 8 dereferenceable(16) %24) #5
  br i1 %25, label %26, label %27

26:                                               ; preds = %18
  br label %29

27:                                               ; preds = %18
  call void @__assert_fail(ptr noundef @.str.16, ptr noundef @.str.6, i32 noundef 181, ptr noundef @__PRETTY_FUNCTION__._ZN4dali5exec28ExecNode11AddDataDepsEv) #6
  unreachable

28:                                               ; No predecessors!
  br label %29

29:                                               ; preds = %28, %26
  %30 = getelementptr inbounds %"class.dali::exec2::ExecNode", ptr %7, i32 0, i32 12
  %31 = call noundef ptr @_ZNKSt19__shared_ptr_accessIN4dali7tasking4TaskELN9__gnu_cxx12_Lock_policyE2ELb0ELb0EEptEv(ptr noundef nonnull align 1 dereferenceable(1) %30) #5
  %32 = load ptr, ptr %6, align 8, !tbaa !5
  %33 = load ptr, ptr %32, align 8, !tbaa !5
  %34 = getelementptr inbounds %"struct.dali::exec2::ExecEdge", ptr %33, i32 0, i32 0
  %35 = load ptr, ptr %34, align 8, !tbaa !9
  %36 = getelementptr inbounds %"class.dali::exec2::ExecNode", ptr %35, i32 0, i32 12
  %37 = load ptr, ptr %6, align 8, !tbaa !5
  %38 = load ptr, ptr %37, align 8, !tbaa !5
  %39 = getelementptr inbounds %"struct.dali::exec2::ExecEdge", ptr %38, i32 0, i32 2
  %40 = load i32, ptr %39, align 8, !tbaa !14
  %41 = call noundef ptr @_ZN4dali7tasking4Task9SubscribeERKSt10shared_ptrIS1_Ei(ptr noundef nonnull align 8 dereferenceable(536) %31, ptr noundef nonnull align 8 dereferenceable(16) %36, i32 noundef %40)
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #5
  br label %42

42:                                               ; preds = %29
  %43 = load ptr, ptr %4, align 8, !tbaa !5
  %44 = getelementptr inbounds ptr, ptr %43, i32 1
  store ptr %44, ptr %4, align 8, !tbaa !5
  br label %13

45:                                               ; preds = %17
  ret void
}

; Function Attrs: mustprogress uwtable
declare dso_local noundef ptr @_ZN4dali7tasking4Task9SubscribeERKSt10shared_ptrIS1_Ei(ptr noundef nonnull align 8 dereferenceable(536), ptr noundef nonnull align 8 dereferenceable(16), i32 noundef) #4 align 2

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { noreturn nounwind "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 #2 = { mustprogress 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 #3 = { inlinehint mustprogress 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 #4 = { mustprogress 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 #5 = { nounwind }
attributes #6 = { noreturn 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 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !6, i64 0}
!10 = !{!"_ZTSN4dali5exec28ExecEdgeE", !6, i64 0, !6, i64 8, !11, i64 16, !11, i64 20, !12, i64 24, !13, i64 28}
!11 = !{!"int", !7, i64 0}
!12 = !{!"_ZTSN4dali13StorageDeviceE", !7, i64 0}
!13 = !{!"bool", !7, i64 0}
!14 = !{!10, !11, i64 16}


; Optimized IR (opt -passes='default<O3>'):
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"

@.str.6 = external hidden unnamed_addr constant [92 x i8], align 1
@.str.16 = external hidden unnamed_addr constant [27 x i8], align 1
@__PRETTY_FUNCTION__._ZN4dali5exec28ExecNode11AddDataDepsEv = external hidden unnamed_addr constant [42 x i8], align 1

; Function Attrs: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) local_unnamed_addr #0

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZNKSt12__shared_ptrIN4dali7tasking4TaskELN9__gnu_cxx12_Lock_policyE2EEcvbEv(ptr noundef nonnull align 8 dereferenceable(16)) local_unnamed_addr #1 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef ptr @_ZNKSt19__shared_ptr_accessIN4dali7tasking4TaskELN9__gnu_cxx12_Lock_policyE2ELb0ELb0EEptEv(ptr noundef nonnull align 1 dereferenceable(1)) local_unnamed_addr #1 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef ptr @_ZN4dali11SmallVectorIPNS_5exec28ExecEdgeELm8ESaIS3_EE5beginEv(ptr noundef nonnull align 8 dereferenceable(72)) local_unnamed_addr #2 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef ptr @_ZN4dali11SmallVectorIPNS_5exec28ExecEdgeELm8ESaIS3_EE3endEv(ptr noundef nonnull align 8 dereferenceable(72)) local_unnamed_addr #2 align 2

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN4dali5exec28ExecNode11AddDataDepsEv(ptr noundef nonnull align 8 dereferenceable(472) %0) local_unnamed_addr #3 align 2 {
  %2 = tail call noundef ptr @_ZN4dali11SmallVectorIPNS_5exec28ExecEdgeELm8ESaIS3_EE5beginEv(ptr noundef nonnull align 8 dereferenceable(72) %0)
  %3 = tail call noundef ptr @_ZN4dali11SmallVectorIPNS_5exec28ExecEdgeELm8ESaIS3_EE3endEv(ptr noundef nonnull align 8 dereferenceable(72) %0)
  %.not10 = icmp eq ptr %2, %3
  br i1 %.not10, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %1
  %4 = getelementptr inbounds i8, ptr %0, i64 392
  br label %5

._crit_edge:                                      ; preds = %11, %1
  ret void

5:                                                ; preds = %.lr.ph, %11
  %.011 = phi ptr [ %2, %.lr.ph ], [ %19, %11 ]
  %6 = load ptr, ptr %.011, align 8, !tbaa !5
  %7 = load ptr, ptr %6, align 8, !tbaa !9
  %8 = getelementptr inbounds i8, ptr %7, i64 392
  %9 = tail call noundef zeroext i1 @_ZNKSt12__shared_ptrIN4dali7tasking4TaskELN9__gnu_cxx12_Lock_policyE2EEcvbEv(ptr noundef nonnull align 8 dereferenceable(16) %8) #4
  br i1 %9, label %11, label %10

10:                                               ; preds = %5
  tail call void @__assert_fail(ptr noundef nonnull @.str.16, ptr noundef nonnull @.str.6, i32 noundef 181, ptr noundef nonnull @__PRETTY_FUNCTION__._ZN4dali5exec28ExecNode11AddDataDepsEv) #5
  unreachable

11:                                               ; preds = %5
  %12 = tail call noundef ptr @_ZNKSt19__shared_ptr_accessIN4dali7tasking4TaskELN9__gnu_cxx12_Lock_policyE2ELb0ELb0EEptEv(ptr noundef nonnull align 1 dereferenceable(1) %4) #4
  %13 = load ptr, ptr %.011, align 8, !tbaa !5
  %14 = load ptr, ptr %13, align 8, !tbaa !9
  %15 = getelementptr inbounds i8, ptr %14, i64 392
  %16 = getelementptr inbounds i8, ptr %13, i64 16
  %17 = load i32, ptr %16, align 8, !tbaa !14
  %18 = tail call noundef ptr @_ZN4dali7tasking4Task9SubscribeERKSt10shared_ptrIS1_Ei(ptr noundef nonnull align 8 dereferenceable(536) %12, ptr noundef nonnull align 8 dereferenceable(16) %15, i32 noundef %17)
  %19 = getelementptr inbounds i8, ptr %.011, i64 8
  %.not = icmp eq ptr %19, %3
  br i1 %.not, label %._crit_edge, label %5
}

; Function Attrs: mustprogress uwtable
declare dso_local noundef ptr @_ZN4dali7tasking4Task9SubscribeERKSt10shared_ptrIS1_Ei(ptr noundef nonnull align 8 dereferenceable(536), ptr noundef nonnull align 8 dereferenceable(16), i32 noundef) local_unnamed_addr #3 align 2

attributes #0 = { noreturn nounwind "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 = { mustprogress 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 #2 = { inlinehint mustprogress 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 #3 = { mustprogress 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 #4 = { nounwind }
attributes #5 = { noreturn 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 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !6, i64 0}
!10 = !{!"_ZTSN4dali5exec28ExecEdgeE", !6, i64 0, !6, i64 8, !11, i64 16, !11, i64 20, !12, i64 24, !13, i64 28}
!11 = !{!"int", !7, i64 0}
!12 = !{!"_ZTSN4dali13StorageDeviceE", !7, i64 0}
!13 = !{!"bool", !7, i64 0}
!14 = !{!10, !11, i64 16}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,SROAPass,SimplifyCFGPass,TailCallElimPass