71 lines · plain
1; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --check-globals --version 22; Test that hoisting conditional branches copies the debug and profiling info3; metadata from the branch being hoisted.4; RUN: opt -S -passes=licm -licm-control-flow-hoisting=1 %s -o - | FileCheck %s5 6define void @triangle_phi(i32 %x, ptr %p) {7; CHECK-LABEL: define void @triangle_phi8; CHECK-SAME: (i32 [[X:%.*]], ptr [[P:%.*]]) {9; CHECK-NEXT: entry:10; CHECK-NEXT: [[CMP1:%.*]] = icmp sgt i32 [[X]], 011; CHECK-NEXT: br i1 [[CMP1]], label [[IF_LICM:%.*]], label [[THEN_LICM:%.*]], !prof [[PROF2:![0-9]+]]12; CHECK: if.licm:13; CHECK-NEXT: [[ADD:%.*]] = add i32 [[X]], 114; CHECK-NEXT: br label [[THEN_LICM]]15; CHECK: then.licm:16; CHECK-NEXT: [[PHI:%.*]] = phi i32 [ [[ADD]], [[IF_LICM]] ], [ [[X]], [[ENTRY:%.*]] ]17; CHECK-NEXT: store i32 [[PHI]], ptr [[P]], align 418; CHECK-NEXT: [[CMP2:%.*]] = icmp ne i32 [[PHI]], 019; CHECK-NEXT: br label [[LOOP:%.*]]20; CHECK: loop:21; CHECK-NEXT: br i1 [[CMP1]], label [[IF:%.*]], label [[THEN:%.*]], !dbg [[DBG3:![0-9]+]], !prof [[PROF2]]22; CHECK: if:23; CHECK-NEXT: br label [[THEN]]24; CHECK: then:25; CHECK-NEXT: br i1 [[CMP2]], label [[LOOP]], label [[END:%.*]], !dbg [[DBG7:![0-9]+]], !prof [[PROF8:![0-9]+]]26; CHECK: end:27; CHECK-NEXT: ret void28;29entry:30 br label %loop, !dbg !531loop:32 %cmp1 = icmp sgt i32 %x, 033 br i1 %cmp1, label %if, label %then, !dbg !6, !prof !834if:35 %add = add i32 %x, 136 br label %then37 38then:39 %phi = phi i32 [ %add, %if ], [ %x, %loop ]40 store i32 %phi, ptr %p41 %cmp2 = icmp ne i32 %phi, 042 br i1 %cmp2, label %loop, label %end, !dbg !7, !prof !943 44end:45 ret void46}47 48!llvm.module.flags = !{!2, !3}49 50!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus_14, file: !1)51!1 = !DIFile(filename: "t", directory: "/")52!2 = !{i32 7, !"Dwarf Version", i32 5}53!3 = !{i32 2, !"Debug Info Version", i32 3}54!4 = distinct !DISubprogram(name: "triangle_phi", linkageName: "triangle_phi", scope: !1, file: !1, line: 1, unit: !0)55!5 = !DILocation(line: 1, column: 22, scope: !4)56!6 = !DILocation(line: 2, column: 22, scope: !4)57!7 = !DILocation(line: 3, column: 22, scope: !4)58!8 = !{!"branch_weights", i32 5, i32 7}59!9 = !{!"branch_weights", i32 13, i32 11}60;.61; CHECK: [[META0:![0-9]+]] = !{i32 7, !"Dwarf Version", i32 5}62; CHECK: [[META1:![0-9]+]] = !{i32 2, !"Debug Info Version", i32 3}63; CHECK: [[PROF2]] = !{!"branch_weights", i32 5, i32 7}64; CHECK: [[DBG3]] = !DILocation(line: 2, column: 22, scope: [[META4:![0-9]+]])65; CHECK: [[META4]] = distinct !DISubprogram(name: "triangle_phi", linkageName: "triangle_phi", scope: [[META5:![0-9]+]], file: [[META5]], line: 1, spFlags: DISPFlagDefinition, unit: [[META6:![0-9]+]])66; CHECK: [[META5]] = !DIFile(filename: "{{.*}}t", directory: {{.*}})67; CHECK: [[META6]] = distinct !DICompileUnit(language: DW_LANG_C_plus_plus_14, file: [[META5]], isOptimized: false, runtimeVersion: 0, emissionKind: NoDebug)68; CHECK: [[DBG7]] = !DILocation(line: 3, column: 22, scope: [[META4]])69; CHECK: [[PROF8]] = !{!"branch_weights", i32 13, i32 11}70;.71