blob: 274eea5bac6fd7cdfbdbd817feda2ee86ac660a8 [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 we attempt to propagate debug locations to the generated branch
;; instructions when we replace a select instruction with control flow.
;; The first select (%select) is replaced with a pair of new blocks, one using a
;; condbr and the other using a br, and both take the select's debug location.
;; The second select (%select3) and the branch from its block are both replaced
;; with a new condbr and a new block with a br, so both new branches take the
;; merge of the select and branch debug locations.
define void @widget() !dbg !5 {
; CHECK-LABEL: define void @widget(
; CHECK-SAME: ) !dbg [[DBG5:![0-9]+]] {
; CHECK-NEXT: [[BB:.*:]]
; CHECK-NEXT: br label %[[BB1:.*]], !dbg [[DBG8:![0-9]+]]
; CHECK: [[BB1]]:
; CHECK-NEXT: br i1 false, label %[[BB2:.*]], label %[[BB4:.*]], !dbg [[DBG9:![0-9]+]]
; CHECK: [[BB2]]:
; CHECK-NEXT: br i1 false, label %[[BB4]], label %[[SELECT_SI_UNFOLD_TRUE:.*]], !dbg [[DBG10:![0-9]+]]
; CHECK: [[SELECT_SI_UNFOLD_TRUE]]:
; CHECK-NEXT: [[DOTSI_UNFOLD_PHI:%.*]] = phi i32 [ 0, %[[BB2]] ]
; CHECK-NEXT: br i1 false, label %[[SELECT3_SI_UNFOLD_FALSE:.*]], label %[[SELECT_SI_UNFOLD_FALSE:.*]], !dbg [[DBG11:![0-9]+]]
; CHECK: [[SELECT_SI_UNFOLD_FALSE]]:
; CHECK-NEXT: [[DOTSI_UNFOLD_PHI1:%.*]] = phi i32 [ 0, %[[SELECT_SI_UNFOLD_TRUE]] ]
; CHECK-NEXT: br label %[[SELECT3_SI_UNFOLD_FALSE]], !dbg [[DBG11]]
; CHECK: [[SELECT3_SI_UNFOLD_FALSE]]:
; CHECK-NEXT: [[SELECT_SI_UNFOLD_PHI:%.*]] = phi i32 [ [[DOTSI_UNFOLD_PHI1]], %[[SELECT_SI_UNFOLD_FALSE]] ], [ [[DOTSI_UNFOLD_PHI]], %[[SELECT_SI_UNFOLD_TRUE]] ]
; CHECK-NEXT: br label %[[BB4]], !dbg [[DBG10]]
; CHECK: [[BB4]]:
; CHECK-NEXT: [[PHI:%.*]] = phi i32 [ 0, %[[BB2]] ], [ 0, %[[BB1]] ], [ [[SELECT_SI_UNFOLD_PHI]], %[[SELECT3_SI_UNFOLD_FALSE]] ], !dbg [[DBG12:![0-9]+]]
; CHECK-NEXT: br label %[[BB5:.*]], !dbg [[DBG13:![0-9]+]]
; CHECK: [[BB5]]:
; CHECK-NEXT: switch i32 [[PHI]], label %[[BB6:.*]] [
; CHECK-NEXT: ], !dbg [[DBG14:![0-9]+]]
; CHECK: [[BB6]]:
; CHECK-NEXT: br label %[[BB5]], !dbg [[DBG15:![0-9]+]]
;
bb:
br label %bb1, !dbg !8
bb1: ; preds = %bb
br i1 false, label %bb2, label %bb4, !dbg !9
bb2: ; preds = %bb1
%select = select i1 false, i32 0, i32 0, !dbg !10
%select3 = select i1 false, i32 0, i32 %select, !dbg !11
br label %bb4, !dbg !12
bb4: ; preds = %bb2, %bb1
%phi = phi i32 [ %select3, %bb2 ], [ 0, %bb1 ], !dbg !13
br label %bb5, !dbg !14
bb5: ; preds = %bb6, %bb4
switch i32 %phi, label %bb6 [
], !dbg !15
bb6: ; preds = %bb5
br label %bb5, !dbg !16
}
!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 9}
!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: 4, column: 5, scope: !5)
!13 = !DILocation(line: 6, column: 1, scope: !5)
!14 = !DILocation(line: 7, column: 1, scope: !5)
!15 = !DILocation(line: 8, column: 1, scope: !5)
!16 = !DILocation(line: 9, 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: 4, scope: [[DBG5]])
; CHECK: [[DBG11]] = !DILocation(line: 3, column: 1, scope: [[DBG5]])
; CHECK: [[DBG12]] = !DILocation(line: 6, column: 1, scope: [[DBG5]])
; CHECK: [[DBG13]] = !DILocation(line: 7, column: 1, scope: [[DBG5]])
; CHECK: [[DBG14]] = !DILocation(line: 8, column: 1, scope: [[DBG5]])
; CHECK: [[DBG15]] = !DILocation(line: 9, column: 1, scope: [[DBG5]])
;.