|  | 
|  | 1 | +; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 5 | 
|  | 2 | +; RUN: opt --passes=loop-rotate %s -S -o - | FileCheck %s | 
|  | 3 | + | 
|  | 4 | +;; Check the duplicated store and br get remapped atoms. | 
|  | 5 | + | 
|  | 6 | +@glob = global i32 0 | 
|  | 7 | + | 
|  | 8 | +define void @test1() #0 !dbg !5 { | 
|  | 9 | +; CHECK-LABEL: define void @test1( | 
|  | 10 | +; CHECK-SAME: ) #[[ATTR0:[0-9]+]] !dbg [[DBG5:![0-9]+]] { | 
|  | 11 | +; CHECK-NEXT:  [[ENTRY:.*]]: | 
|  | 12 | +; CHECK-NEXT:    [[ARRAY:%.*]] = alloca [20 x i32], align 16 | 
|  | 13 | +; CHECK-NEXT:    store i32 0, ptr @glob, align 16, !dbg [[DBG8:![0-9]+]] | 
|  | 14 | +; CHECK-NEXT:    br label %[[FOR_BODY:.*]], !dbg [[DBG9:![0-9]+]] | 
|  | 15 | +; CHECK:       [[FOR_BODY]]: | 
|  | 16 | +; CHECK-NEXT:    [[I_01:%.*]] = phi i32 [ 0, %[[ENTRY]] ], [ [[INC:%.*]], %[[FOR_BODY]] ] | 
|  | 17 | +; CHECK-NEXT:    [[INC]] = add nsw i32 [[I_01]], 1 | 
|  | 18 | +; CHECK-NEXT:    store i32 0, ptr [[ARRAY]], align 16 | 
|  | 19 | +; CHECK-NEXT:    store i32 [[INC]], ptr @glob, align 16, !dbg [[DBG10:![0-9]+]] | 
|  | 20 | +; CHECK-NEXT:    [[CMP:%.*]] = icmp slt i32 [[INC]], 100, !dbg [[DBG11:![0-9]+]] | 
|  | 21 | +; CHECK-NEXT:    br i1 [[CMP]], label %[[FOR_BODY]], label %[[FOR_END:.*]], !dbg [[DBG12:![0-9]+]] | 
|  | 22 | +; CHECK:       [[FOR_END]]: | 
|  | 23 | +; CHECK-NEXT:    [[ARRAYIDX_LCSSA:%.*]] = phi ptr [ [[ARRAY]], %[[FOR_BODY]] ] | 
|  | 24 | +; CHECK-NEXT:    call void @g(ptr [[ARRAYIDX_LCSSA]]) | 
|  | 25 | +; CHECK-NEXT:    ret void | 
|  | 26 | +; | 
|  | 27 | +entry: | 
|  | 28 | +  %array = alloca [20 x i32], align 16 | 
|  | 29 | +  br label %for.cond | 
|  | 30 | + | 
|  | 31 | +for.cond:                                         ; preds = %for.body, %entry | 
|  | 32 | +  %i.0 = phi i32 [ 0, %entry ], [ %inc, %for.body ] | 
|  | 33 | +  store i32 %i.0, ptr @glob, align 16, !dbg !11 | 
|  | 34 | +  %cmp = icmp slt i32 %i.0, 100, !dbg !12 | 
|  | 35 | +  br i1 %cmp, label %for.body, label %for.end, !dbg !13 | 
|  | 36 | + | 
|  | 37 | +for.body:                                         ; preds = %for.cond | 
|  | 38 | +  %inc = add nsw i32 %i.0, 1 | 
|  | 39 | +  store i32 0, ptr %array, align 16 | 
|  | 40 | +  br label %for.cond | 
|  | 41 | + | 
|  | 42 | +for.end:                                          ; preds = %for.cond | 
|  | 43 | +  %arrayidx.lcssa = phi ptr [ %array, %for.cond ] | 
|  | 44 | +  call void @g(ptr %arrayidx.lcssa) | 
|  | 45 | +  ret void | 
|  | 46 | +} | 
|  | 47 | + | 
|  | 48 | +declare void @g(ptr) | 
|  | 49 | + | 
|  | 50 | +attributes #0 = { nounwind ssp } | 
|  | 51 | +attributes #1 = { noduplicate } | 
|  | 52 | + | 
|  | 53 | +!llvm.dbg.cu = !{!0} | 
|  | 54 | +!llvm.debugify = !{!2, !3} | 
|  | 55 | +!llvm.module.flags = !{!4} | 
|  | 56 | + | 
|  | 57 | +!0 = distinct !DICompileUnit(language: DW_LANG_C, file: !1, producer: "debugify", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug) | 
|  | 58 | +!1 = !DIFile(filename: "test.ll", directory: "/") | 
|  | 59 | +!2 = !{i32 12} | 
|  | 60 | +!3 = !{i32 0} | 
|  | 61 | +!4 = !{i32 2, !"Debug Info Version", i32 3} | 
|  | 62 | +!5 = distinct !DISubprogram(name: "test1", linkageName: "test1", scope: null, file: !1, line: 1, type: !6, scopeLine: 1, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0) | 
|  | 63 | +!6 = !DISubroutineType(types: !7) | 
|  | 64 | +!7 = !{} | 
|  | 65 | +!11 = !DILocation(line: 4, column: 1, scope: !5, atomGroup: 1, atomRank: 1) | 
|  | 66 | +!12 = !DILocation(line: 5, column: 1, scope: !5, atomGroup: 2, atomRank: 2) | 
|  | 67 | +!13 = !DILocation(line: 6, column: 1, scope: !5, atomGroup: 2, atomRank: 1) | 
|  | 68 | +;. | 
|  | 69 | +; CHECK: [[META0:![0-9]+]] = distinct !DICompileUnit(language: DW_LANG_C, file: [[META1:![0-9]+]], producer: "debugify", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug) | 
|  | 70 | +; CHECK: [[META1]] = !DIFile(filename: "test.ll", directory: {{.*}}) | 
|  | 71 | +; CHECK: [[DBG5]] = distinct !DISubprogram(name: "test1", linkageName: "test1", scope: null, file: [[META1]], line: 1, type: [[META6:![0-9]+]], scopeLine: 1, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: [[META0]]) | 
|  | 72 | +; CHECK: [[META6]] = !DISubroutineType(types: [[META7:![0-9]+]]) | 
|  | 73 | +; CHECK: [[META7]] = !{} | 
|  | 74 | +; CHECK: [[DBG8]] = !DILocation(line: 4, column: 1, scope: [[DBG5]], atomGroup: 3, atomRank: 1) | 
|  | 75 | +; CHECK: [[DBG9]] = !DILocation(line: 6, column: 1, scope: [[DBG5]], atomGroup: 4, atomRank: 1) | 
|  | 76 | +; CHECK: [[DBG10]] = !DILocation(line: 4, column: 1, scope: [[DBG5]], atomGroup: 1, atomRank: 1) | 
|  | 77 | +; CHECK: [[DBG11]] = !DILocation(line: 5, column: 1, scope: [[DBG5]], atomGroup: 2, atomRank: 2) | 
|  | 78 | +; CHECK: [[DBG12]] = !DILocation(line: 6, column: 1, scope: [[DBG5]], atomGroup: 2, atomRank: 1) | 
|  | 79 | +;. | 
0 commit comments