108 lines · plain
1; NOTE: Assertions have been autogenerated by utils/update_test_checks.py2; RUN: opt -passes='loop-mssa(simple-loop-unswitch<nontrivial>),verify<loops>' -S < %s | FileCheck %s3;4;; Check that when we duplicate the load in the loop header, we also duplicate5;; the corresponding dbg.value.6;; FIXME: the hoisted load dominates the duplicated dbg.value, however as it's7;; not subsequently used in the loop, so it doesn't get remapped into the8;; debug user and we get a undef/poison dbg.value. This is suboptimal, but it's9;; important that the dbg.value gets duplicated nonetheless.10 11declare void @clobber()12declare void @llvm.dbg.value(metadata, metadata, metadata)13 14define i32 @partial_unswitch_true_successor(ptr %ptr, i32 %N) {15; CHECK-LABEL: @partial_unswitch_true_successor(16; CHECK-NEXT: entry:17; CHECK-NEXT: [[TMP0:%.*]] = load i32, ptr [[PTR:%.*]], align 418; CHECK-NEXT: [[TMP1:%.*]] = icmp eq i32 [[TMP0]], 10019; CHECK-NEXT: br i1 [[TMP1]], label [[ENTRY_SPLIT_US:%.*]], label [[ENTRY_SPLIT:%.*]]20; CHECK: entry.split.us:21; CHECK-NEXT: br label [[LOOP_HEADER_US:%.*]]22; CHECK: loop.header.us:23; CHECK-NEXT: [[IV_US:%.*]] = phi i32 [ 0, [[ENTRY_SPLIT_US]] ], [ [[IV_NEXT_US:%.*]], [[LOOP_LATCH_US:%.*]] ]24; CHECK-NEXT: #dbg_value(i32 poison, [[META3:![0-9]+]], !DIExpression(), [[META8:![0-9]+]])25; CHECK-NEXT: br label [[NOCLOBBER_US:%.*]]26; CHECK: noclobber.us:27; CHECK-NEXT: br label [[LOOP_LATCH_US]]28; CHECK: loop.latch.us:29; CHECK-NEXT: [[C_US:%.*]] = icmp ult i32 [[IV_US]], [[N:%.*]]30; CHECK-NEXT: [[IV_NEXT_US]] = add i32 [[IV_US]], 131; CHECK-NEXT: br i1 [[C_US]], label [[LOOP_HEADER_US]], label [[EXIT_SPLIT_US:%.*]]32; CHECK: exit.split.us:33; CHECK-NEXT: br label [[EXIT:%.*]]34; CHECK: entry.split:35; CHECK-NEXT: br label [[LOOP_HEADER:%.*]]36; CHECK: loop.header:37; CHECK-NEXT: [[IV:%.*]] = phi i32 [ 0, [[ENTRY_SPLIT]] ], [ [[IV_NEXT:%.*]], [[LOOP_LATCH:%.*]] ]38; CHECK-NEXT: [[LV:%.*]] = load i32, ptr [[PTR]], align 439; CHECK-NEXT: #dbg_value(i32 [[LV]], [[META3]], !DIExpression(), [[META8]])40; CHECK-NEXT: [[SC:%.*]] = icmp eq i32 [[LV]], 10041; CHECK-NEXT: br i1 [[SC]], label [[NOCLOBBER:%.*]], label [[CLOBBER:%.*]]42; CHECK: noclobber:43; CHECK-NEXT: br label [[LOOP_LATCH]]44; CHECK: clobber:45; CHECK-NEXT: call void @clobber()46; CHECK-NEXT: br label [[LOOP_LATCH]]47; CHECK: loop.latch:48; CHECK-NEXT: [[C:%.*]] = icmp ult i32 [[IV]], [[N]]49; CHECK-NEXT: [[IV_NEXT]] = add i32 [[IV]], 150; CHECK-NEXT: br i1 [[C]], label [[LOOP_HEADER]], label [[EXIT_SPLIT:%.*]], !llvm.loop [[LOOP9:![0-9]+]]51; CHECK: exit.split:52; CHECK-NEXT: br label [[EXIT]]53; CHECK: exit:54; CHECK-NEXT: ret i32 1055;56entry:57 br label %loop.header58 59loop.header:60 %iv = phi i32 [ 0, %entry ], [ %iv.next, %loop.latch ]61 %lv = load i32, ptr %ptr62 call void @llvm.dbg.value(metadata i32 %lv, metadata !6, metadata !DIExpression()), !dbg !763 %sc = icmp eq i32 %lv, 10064 br i1 %sc, label %noclobber, label %clobber65 66noclobber:67 br label %loop.latch68 69clobber:70 call void @clobber()71 br label %loop.latch72 73loop.latch:74 %c = icmp ult i32 %iv, %N75 %iv.next = add i32 %iv, 176 br i1 %c, label %loop.header, label %exit77 78exit:79 ret i32 1080}81 82!llvm.module.flags = !{!21}83!llvm.dbg.cu = !{!2}84 85!0 = distinct !DISubprogram(name: "foo", line: 2, isLocal: false, isDefinition: true, virtualIndex: 6, flags: DIFlagPrototyped, isOptimized: false, unit: !2, file: !20, scope: !1, type: !3)86!1 = !DIFile(filename: "b.c", directory: "/private/tmp")87!2 = distinct !DICompileUnit(language: DW_LANG_C99, producer: "clang", isOptimized: true, emissionKind: FullDebug, file: !20)88!3 = !DISubroutineType(types: !4)89!4 = !{!5}90!5 = !DIBasicType(tag: DW_TAG_base_type, name: "int", size: 32, align: 32, encoding: DW_ATE_signed)91!6 = !DILocalVariable(name: "i", line: 2, arg: 1, scope: !0, file: !1, type: !5)92!7 = !DILocation(line: 2, column: 13, scope: !0)93!9 = !DILocalVariable(name: "k", line: 3, scope: !10, file: !1, type: !5)94!10 = distinct !DILexicalBlock(line: 2, column: 16, file: !20, scope: !0)95!11 = !DILocation(line: 3, column: 12, scope: !10)96!12 = !DILocation(line: 4, column: 3, scope: !10)97!13 = !DILocation(line: 5, column: 5, scope: !14)98!14 = distinct !DILexicalBlock(line: 4, column: 10, file: !20, scope: !10)99!15 = !DILocation(line: 6, column: 3, scope: !14)100!16 = !DILocation(line: 7, column: 5, scope: !17)101!17 = distinct !DILexicalBlock(line: 6, column: 10, file: !20, scope: !10)102!18 = !DILocation(line: 8, column: 3, scope: !17)103!19 = !DILocation(line: 9, column: 3, scope: !10)104!20 = !DIFile(filename: "b.c", directory: "/private/tmp")105!21 = !{i32 1, !"Debug Info Version", i32 3}106 107 108