brintos

brintos / llvm-project-archived public Read only

0
0
Text · 5.1 KiB · d5ac821 Raw
107 lines · plain
1; RUN: opt -passes=licm %s -S | FileCheck %s2 3;; Ensure that we correctly merge the DIAssignID's from the sunk stores, add it4;; to the new new store instruction, and update the dbg.assign intrinsics using5;; them to use it instead.6 7;; Generated from the following, with some changes to the IR by hand:8;; $ cat test.c9;; void b(int c) {10;;   esc(&c);11;;   for (; c;  c++) // NOTE: I've added another store to c in the loop by hand.12;;   ;13;; }14;; $ clang -O2 -Xclang -disable-llvm-passes -g -emit-llvm -S -o a.ll15;; $ opt -passes=declare-to-assign,sroa,instcombine,simplifycfg,loop-simplify,lcssa,loop-rotate a.ll16 17; CHECK-LABEL: for.inc:18;; Check that the stores have actually been removed from this block, otherwise19;; this test is useless.20; CHECK-NOT: store i32 %inc, ptr %c.addr21;; Check that the two dbg.assigns now have the same (merged) !DIAssingID ID.22; CHECK: #dbg_assign(i32 %inc, ![[VAR_C:[0-9]+]], !DIExpression(), ![[ID:[0-9]+]], ptr %c.addr, !DIExpression(),23; CHECK-NOT: store i32 %inc, ptr %c.addr24; CHECK: #dbg_assign(i32 %inc, ![[VAR_C]], !DIExpression(), ![[ID]], ptr %c.addr, !DIExpression(),25 26; CHECK-LABEL: for.cond.for.end_crit_edge:27; CHECK-NEXT: %[[PHI:.*]] = phi i32 [ %inc, %for.inc ]28; CHECK-NEXT: store i32 %[[PHI]], ptr %c.addr{{.*}}, !DIAssignID ![[ID]]29; CHECK-NOT:  {{.*}}llvm.dbg{{.*}}30; CHECK-NEXT: br label %for.end31 32; CHECK: ![[VAR_C]] = !DILocalVariable(name: "c",33 34define dso_local void @b(i32 %c) !dbg !7 {35entry:36  %c.addr = alloca i32, align 437  store i32 %c, ptr %c.addr, align 4, !DIAssignID !3638  call void @llvm.dbg.assign(metadata i32 %c, metadata !12, metadata !DIExpression(), metadata !36, metadata ptr %c.addr, metadata !DIExpression()), !dbg !1339  call void @esc(ptr nonnull %c.addr), !dbg !1840  %0 = load i32, ptr %c.addr, align 4, !dbg !1941  %tobool.not1 = icmp eq i32 %0, 0, !dbg !2242  br i1 %tobool.not1, label %for.end, label %for.inc.lr.ph, !dbg !2243 44for.inc.lr.ph:                                    ; preds = %entry45  br label %for.inc, !dbg !2246 47for.inc:                                          ; preds = %for.inc.lr.ph, %for.inc48  %1 = load i32, ptr %c.addr, align 4, !dbg !2349  %inc = add nsw i32 %1, 1, !dbg !2350  store i32 %inc, ptr %c.addr, align 4, !dbg !23, !DIAssignID !3851  call void @llvm.dbg.assign(metadata i32 %inc, metadata !12, metadata !DIExpression(), metadata !38, metadata ptr %c.addr, metadata !DIExpression()), !dbg !1352  ;; The following store and dbg.assign intrinsics are copies of those above,53  ;; with a new DIAssignID.54  store i32 %inc, ptr %c.addr, align 4, !dbg !23, !DIAssignID !3755  call void @llvm.dbg.assign(metadata i32 %inc, metadata !12, metadata !DIExpression(), metadata !37, metadata ptr %c.addr, metadata !DIExpression()), !dbg !1356  %2 = load i32, ptr %c.addr, align 4, !dbg !1957  %tobool.not = icmp eq i32 %2, 0, !dbg !2258  br i1 %tobool.not, label %for.cond.for.end_crit_edge, label %for.inc, !dbg !22, !llvm.loop !2459 60for.cond.for.end_crit_edge:                       ; preds = %for.inc61  br label %for.end, !dbg !2262 63for.end:                                          ; preds = %for.cond.for.end_crit_edge, %entry64  ret void, !dbg !2765}66 67 68declare void @llvm.dbg.assign(metadata, metadata, metadata, metadata, metadata, metadata)69declare !dbg !28 dso_local void @esc(ptr)70 71!llvm.dbg.cu = !{!0}72!llvm.module.flags = !{!3, !4, !5, !1000}73!llvm.ident = !{!6}74 75!0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang version 12.0.0", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, splitDebugInlining: false, nameTableKind: None)76!1 = !DIFile(filename: "test.c", directory: "/")77!2 = !{}78!3 = !{i32 7, !"Dwarf Version", i32 4}79!4 = !{i32 2, !"Debug Info Version", i32 3}80!5 = !{i32 1, !"wchar_size", i32 4}81!6 = !{!"clang version 12.0.0"}82!7 = distinct !DISubprogram(name: "b", scope: !1, file: !1, line: 2, type: !8, scopeLine: 2, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !11)83!8 = !DISubroutineType(types: !9)84!9 = !{null, !10}85!10 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)86!11 = !{!12}87!12 = !DILocalVariable(name: "c", arg: 1, scope: !7, file: !1, line: 2, type: !10)88!13 = !DILocation(line: 0, scope: !7)89!18 = !DILocation(line: 3, column: 3, scope: !7)90!19 = !DILocation(line: 4, column: 10, scope: !20)91!20 = distinct !DILexicalBlock(scope: !21, file: !1, line: 4, column: 3)92!21 = distinct !DILexicalBlock(scope: !7, file: !1, line: 4, column: 3)93!22 = !DILocation(line: 4, column: 3, scope: !21)94!23 = !DILocation(line: 4, column: 15, scope: !20)95!24 = distinct !{!24, !22, !25, !26}96!25 = !DILocation(line: 5, column: 3, scope: !21)97!26 = !{!"llvm.loop.mustprogress"}98!27 = !DILocation(line: 6, column: 1, scope: !7)99!28 = !DISubprogram(name: "esc", scope: !1, file: !1, line: 1, type: !29, flags: DIFlagPrototyped, spFlags: DISPFlagOptimized, retainedNodes: !2)100!29 = !DISubroutineType(types: !30)101!30 = !{null, !31}102!31 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !10, size: 64)103!36 = distinct !DIAssignID()104!37 = distinct !DIAssignID()105!38 = distinct !DIAssignID()106!1000 = !{i32 7, !"debug-info-assignment-tracking", i1 true}107