brintos

brintos / llvm-project-archived public Read only

0
0
Text · 5.3 KiB · fcd5196 Raw
116 lines · plain
1; RUN: llc %s -stop-after=finalize-isel -o - \2; RUN: | FileCheck %s --implicit-check-not=DBG3 4;; Tiny loop with a store sunk out of it:5;; void e();6;; void es(int*);7;; int *g;8;; int getInt();9;; int f(int a, int b) {10;;   int z = getInt();11;;   while (g) {12;;     e();13;;     a = z;14;;   }15;;   es(&a);16;;   return a;17;; }18;;19;; Store to `a` has been sunk out the loop - there's a dbg.assign left in the20;; loop that is linked the store that is now outside it. Check that the memory21;; location is not used inside the loop and is reinstated after the sunk store.22 23; CHECK-DAG: ![[A:[0-9]+]] = !DILocalVariable(name: "a",24 25; CHECK-LABEL: bb.0.entry:26; CHECK: DBG_VALUE $edi, $noreg, ![[A]], !DIExpression()27; CHECK: CALL64pcrel32 @getInt{{.*}}debug-instr-number 128 29; CHECK-LABEL: bb.2.while.body:30; CHECK: DBG_INSTR_REF ![[A]], !DIExpression(DW_OP_LLVM_arg, 0), dbg-instr-ref(1, 6)31 32; CHECK-LABEL: bb.3.while.end:33; CHECK: MOV32mr %stack.0.a.addr, 1, $noreg, 0, $noreg, %134; CHECK-NEXT: DBG_VALUE %stack.0.a.addr, $noreg, ![[A]], !DIExpression(DW_OP_deref)35 36target triple = "x86_64-unknown-linux-gnu"37 38@g = dso_local local_unnamed_addr global ptr null, align 8, !dbg !039 40; Function Attrs: mustprogress uwtable41define dso_local noundef i32 @_Z1fii(i32 noundef %a, i32 noundef %b) local_unnamed_addr #0 !dbg !12 {42entry:43  %a.addr = alloca i32, align 4, !DIAssignID !1844  call void @llvm.dbg.assign(metadata i1 undef, metadata !16, metadata !DIExpression(), metadata !18, metadata ptr %a.addr, metadata !DIExpression()), !dbg !1945  call void @llvm.dbg.assign(metadata i32 %a, metadata !16, metadata !DIExpression(), metadata !20, metadata ptr %a.addr, metadata !DIExpression()), !dbg !1946  %z = call i32 @getInt()47  %0 = load ptr, ptr @g, align 8, !dbg !2248  %tobool.not1 = icmp eq ptr %0, null, !dbg !2249  br i1 %tobool.not1, label %while.end, label %while.body, !dbg !2750 51while.body:                                       ; preds = %entry, %while.body52  tail call void @_Z1ev(), !dbg !2853  call void @llvm.dbg.assign(metadata i32 %z, metadata !16, metadata !DIExpression(), metadata !20, metadata ptr %a.addr, metadata !DIExpression()), !dbg !1954  %1 = load ptr, ptr @g, align 8, !dbg !2255  %tobool.not = icmp eq ptr %1, null, !dbg !2256  br i1 %tobool.not, label %while.end, label %while.body, !dbg !27, !llvm.loop !3057 58while.end:                                        ; preds = %while.body, %entry59  %storemerge.lcssa = phi i32 [ %a, %entry ], [ %b, %while.body ]60  store i32 %storemerge.lcssa, ptr %a.addr, align 4, !DIAssignID !2061  call void @_Z2esPi(ptr noundef nonnull %a.addr), !dbg !3562  %2 = load i32, ptr %a.addr, align 4, !dbg !3663  %r = add i32 %2, %z64  ret i32 %r, !dbg !3765}66 67declare !dbg !38 dso_local void @_Z1ev() local_unnamed_addr #168declare !dbg !42 dso_local void @_Z2esPi(ptr noundef) local_unnamed_addr #169declare void @llvm.dbg.assign(metadata, metadata, metadata, metadata, metadata, metadata) #270declare dso_local i32 @getInt()71 72!llvm.dbg.cu = !{!2}73!llvm.module.flags = !{!7, !8, !9, !10, !1000}74!llvm.ident = !{!11}75 76!0 = !DIGlobalVariableExpression(var: !1, expr: !DIExpression())77!1 = distinct !DIGlobalVariable(name: "g", scope: !2, file: !3, line: 4, type: !5, isLocal: false, isDefinition: true)78!2 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus_14, file: !3, producer: "clang version 14.0.0", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, globals: !4, splitDebugInlining: false, nameTableKind: None)79!3 = !DIFile(filename: "test.cpp", directory: "/")80!4 = !{!0}81!5 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !6, size: 64)82!6 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)83!7 = !{i32 7, !"Dwarf Version", i32 5}84!8 = !{i32 2, !"Debug Info Version", i32 3}85!9 = !{i32 1, !"wchar_size", i32 4}86!10 = !{i32 7, !"uwtable", i32 1}87!11 = !{!"clang version 14.0.0"}88!12 = distinct !DISubprogram(name: "f", linkageName: "_Z1fii", scope: !3, file: !3, line: 5, type: !13, scopeLine: 5, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !2, retainedNodes: !15)89!13 = !DISubroutineType(types: !14)90!14 = !{!6, !6, !6}91!15 = !{!16, !17}92!16 = !DILocalVariable(name: "a", arg: 1, scope: !12, file: !3, line: 5, type: !6)93!17 = !DILocalVariable(name: "b", arg: 2, scope: !12, file: !3, line: 5, type: !6)94!18 = distinct !DIAssignID()95!19 = !DILocation(line: 0, scope: !12)96!20 = distinct !DIAssignID()97!21 = distinct !DIAssignID()98!22 = !DILocation(line: 6, column: 10, scope: !12)99!27 = !DILocation(line: 6, column: 3, scope: !12)100!28 = !DILocation(line: 7, column: 5, scope: !29)101!29 = distinct !DILexicalBlock(scope: !12, file: !3, line: 6, column: 13)102!30 = distinct !{!30, !27, !31, !32}103!31 = !DILocation(line: 9, column: 3, scope: !12)104!32 = !{!"llvm.loop.mustprogress"}105!35 = !DILocation(line: 10, column: 3, scope: !12)106!36 = !DILocation(line: 11, column: 10, scope: !12)107!37 = !DILocation(line: 11, column: 3, scope: !12)108!38 = !DISubprogram(name: "e", linkageName: "_Z1ev", scope: !3, file: !3, line: 2, type: !39, flags: DIFlagPrototyped, spFlags: DISPFlagOptimized, retainedNodes: !41)109!39 = !DISubroutineType(types: !40)110!40 = !{null}111!41 = !{}112!42 = !DISubprogram(name: "es", linkageName: "_Z2esPi", scope: !3, file: !3, line: 3, type: !43, flags: DIFlagPrototyped, spFlags: DISPFlagOptimized, retainedNodes: !41)113!43 = !DISubroutineType(types: !44)114!44 = !{null, !5}115!1000 = !{i32 7, !"debug-info-assignment-tracking", i1 true}116