blob: 03b098fc0c5365b8a7979985920803d5208c9bd2 [file] [edit]
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 6
; RUN: opt -S -passes=dfa-jump-threading %s | FileCheck %s
;; Tests that when we perform jump threading, creating a new path which doesn't
;; require a switch statement at its end, we keep the switch statement's
;; DebugLoc on the final unconditional branch, since the unconditional branch
;; represents the switch (with a known outcome).
define i32 @widget() !dbg !5 {
; CHECK-LABEL: define i32 @widget(
; CHECK-SAME: ) !dbg [[DBG5:![0-9]+]] {
; CHECK-NEXT: [[BB:.*:]]
; CHECK-NEXT: br label %[[BB1:.*]], !dbg [[DBG8:![0-9]+]]
; CHECK: [[BB1]]:
; CHECK-NEXT: switch i32 0, label %[[BB2_JT0:.*]] [
; CHECK-NEXT: i32 -2147467260, label %[[BB2_JT0]]
; CHECK-NEXT: ], !dbg [[DBG9:![0-9]+]]
; CHECK: [[BB3:.*:]]
; CHECK-NEXT: switch i32 poison, label %[[BB4:.*]] [
; CHECK-NEXT: i32 0, label %[[BB4]]
; CHECK-NEXT: i32 4, label %[[BB4]]
; CHECK-NEXT: ], !dbg [[DBG10:![0-9]+]]
; CHECK: [[BB2_JT0]]:
; CHECK-NEXT: [[PHI_JT0:%.*]] = phi i32 [ 0, %[[BB1]] ], [ 0, %[[BB1]] ], !dbg [[DBG11:![0-9]+]]
; CHECK-NEXT: br label %[[BB4]]
; CHECK: [[BB4]]:
; CHECK-NEXT: br label %[[BB1]], !dbg [[DBG12:![0-9]+]]
;
bb:
br label %bb1, !dbg !8
bb1: ; preds = %bb4, %bb
switch i32 0, label %bb2 [
i32 -2147467260, label %bb2
], !dbg !9
bb2: ; preds = %bb1, %bb1
%phi = phi i32 [ 0, %bb1 ], [ 0, %bb1 ], !dbg !10
switch i32 %phi, label %bb4 [
i32 0, label %bb4
i32 4, label %bb4
], !dbg !12
bb4: ; preds = %bb3, %bb3, %bb3
br label %bb1, !dbg !13
}
!llvm.dbg.cu = !{!0}
!llvm.debugify = !{!2, !3}
!llvm.module.flags = !{!4}
!0 = distinct !DICompileUnit(language: DW_LANG_C, file: !1, producer: "debugify", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug)
!1 = !DIFile(filename: "reduced.ll", directory: "/")
!2 = !{i32 6}
!3 = !{i32 0}
!4 = !{i32 2, !"Debug Info Version", i32 3}
!5 = distinct !DISubprogram(name: "widget", linkageName: "widget", scope: null, file: !1, line: 1, type: !6, scopeLine: 1, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0)
!6 = !DISubroutineType(types: !7)
!7 = !{}
!8 = !DILocation(line: 1, column: 1, scope: !5)
!9 = !DILocation(line: 2, column: 1, scope: !5)
!10 = !DILocation(line: 3, column: 1, scope: !5)
!11 = !DILocation(line: 4, column: 1, scope: !5)
!12 = !DILocation(line: 5, column: 1, scope: !5)
!13 = !DILocation(line: 6, column: 1, scope: !5)
;.
; CHECK: [[META0:![0-9]+]] = distinct !DICompileUnit(language: DW_LANG_C, file: [[META1:![0-9]+]], producer: "debugify", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug)
; CHECK: [[META1]] = !DIFile(filename: "{{.*}}reduced.ll", directory: {{.*}})
; CHECK: [[DBG5]] = distinct !DISubprogram(name: "widget", linkageName: "widget", scope: null, file: [[META1]], line: 1, type: [[META6:![0-9]+]], scopeLine: 1, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: [[META0]])
; CHECK: [[META6]] = !DISubroutineType(types: [[META7:![0-9]+]])
; CHECK: [[META7]] = !{}
; CHECK: [[DBG8]] = !DILocation(line: 1, column: 1, scope: [[DBG5]])
; CHECK: [[DBG9]] = !DILocation(line: 2, column: 1, scope: [[DBG5]])
; CHECK: [[DBG10]] = !DILocation(line: 5, column: 1, scope: [[DBG5]])
; CHECK: [[DBG11]] = !DILocation(line: 3, column: 1, scope: [[DBG5]])
; CHECK: [[DBG12]] = !DILocation(line: 6, column: 1, scope: [[DBG5]])
;.