; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
; RUN: llc < %s -global-isel -mtriple=arm64-linux-gnu -global-isel-abort=1 | FileCheck %s
target datalayout = "e-m:o-i64:64-i128:128-n32:64-S128"
target triple = "arm64-apple-ios9.0.0"

; Check we don't fall back due to hitting a DBG_VALUE with a deleted vreg.

%0 = type { %1, %3, %5, %8, i8, i32, i8, i64, [4096 x %9], i64, i64, [4096 x %11], i64, i64, %13, %21, i8*, %35, i64, [504 x i8] }
%1 = type { [32 x %2] }
%2 = type { i32, i32 }
%3 = type { [32 x %4] }
%4 = type { i64, i64 }
%5 = type { [32 x %6] }
%6 = type { %7, %7 }
%7 = type { i8, [64 x i8] }
%8 = type { [1024 x %7], %7 }
%9 = type { %10*, i64 }
%10 = type { i8*, i8*, i8, i8 }
%11 = type { %12*, %12* }
%12 = type { i64, i64 }
%13 = type { %14 }
%14 = type { %15*, %17, %19 }
%15 = type { %16* }
%16 = type <{ %15, %16*, %15*, i8, [7 x i8] }>
%17 = type { %18 }
%18 = type { %15 }
%19 = type { %20 }
%20 = type { i64 }
%21 = type { %22 }
%22 = type <{ %23, %30, %32, %33, [4 x i8] }>
%23 = type { %24 }
%24 = type { %25, %27 }
%25 = type { %26** }
%26 = type { %26* }
%27 = type { %28 }
%28 = type { %29 }
%29 = type { %20 }
%30 = type { %31 }
%31 = type { %26 }
%32 = type { %20 }
%33 = type { %34 }
%34 = type { float }
%35 = type { [1024 x i64] }

@global = external hidden global %0, align 512

define void @baz(i8* %arg) !dbg !6 {
; CHECK-LABEL: baz:
; CHECK:       .Lfunc_begin0:
; CHECK-NEXT:    .file 1 "/" "tmp.ll"
; CHECK-NEXT:    .loc 1 1 0 // tmp.ll:1:0
; CHECK-NEXT:    .cfi_startproc
; CHECK-NEXT:  // %bb.0: // %bb
; CHECK-NEXT:    //DEBUG_VALUE: baz:3 <- undef
; CHECK-NEXT:    .loc 1 4 1 prologue_end // tmp.ll:4:1
; CHECK-NEXT:    lsl x8, x0, #4
; CHECK-NEXT:    .loc 1 0 0 is_stmt 0 // tmp.ll:0:0
; CHECK-NEXT:    adrp x9, global+202752
; CHECK-NEXT:    .loc 1 4 1 // tmp.ll:4:1
; CHECK-NEXT:    and x8, x8, #0x1ff0
; CHECK-NEXT:    .loc 1 0 0 // tmp.ll:0:0
; CHECK-NEXT:    add x9, x9, :lo12:global+202752
; CHECK-NEXT:    .loc 1 5 1 is_stmt 1 // tmp.ll:5:1
; CHECK-NEXT:    str xzr, [x9, x8]
; CHECK-NEXT:    .loc 1 6 1 // tmp.ll:6:1
; CHECK-NEXT:    ret
; CHECK-NEXT:  .Ltmp0:
bb:
  %tmp = ptrtoint i8* %arg to i64, !dbg !14
  %tmp1 = shl i64 %tmp, 1, !dbg !15
  %tmp2 = and i64 %tmp1, 1022, !dbg !16
  call void @llvm.dbg.value(metadata i64 %tmp2, metadata !12, metadata !DIExpression()), !dbg !16
  %tmp3 = getelementptr inbounds %0, %0* @global, i64 0, i32 17, i32 0, i64 %tmp2, !dbg !17
  store i64 0, i64* %tmp3, align 16, !dbg !18
  ret void, !dbg !19
}

; Function Attrs: nofree nosync nounwind readnone speculatable willreturn
declare void @llvm.dbg.value(metadata, metadata, metadata) #1

attributes #1 = { nofree nosync nounwind readnone speculatable willreturn }

!llvm.module.flags = !{!0}
!llvm.dbg.cu = !{!1}
!llvm.debugify = !{!4, !5}

!0 = !{i32 2, !"Debug Info Version", i32 3}
!1 = distinct !DICompileUnit(language: DW_LANG_C, file: !2, producer: "debugify", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !3)
!2 = !DIFile(filename: "tmp.ll", directory: "/")
!3 = !{}
!4 = !{i32 6}
!5 = !{i32 4}
!6 = distinct !DISubprogram(name: "baz", linkageName: "baz", scope: null, file: !2, line: 1, type: !7, scopeLine: 1, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !1, retainedNodes: !8)
!7 = !DISubroutineType(types: !3)
!8 = !{!9, !11, !12, !13}
!9 = !DILocalVariable(name: "1", scope: !6, file: !2, line: 1, type: !10)
!10 = !DIBasicType(name: "ty64", size: 64, encoding: DW_ATE_unsigned)
!11 = !DILocalVariable(name: "2", scope: !6, file: !2, line: 2, type: !10)
!12 = !DILocalVariable(name: "3", scope: !6, file: !2, line: 3, type: !10)
!13 = !DILocalVariable(name: "4", scope: !6, file: !2, line: 4, type: !10)
!14 = !DILocation(line: 1, column: 1, scope: !6)
!15 = !DILocation(line: 2, column: 1, scope: !6)
!16 = !DILocation(line: 3, column: 1, scope: !6)
!17 = !DILocation(line: 4, column: 1, scope: !6)
!18 = !DILocation(line: 5, column: 1, scope: !6)
!19 = !DILocation(line: 6, column: 1, scope: !6)
