120 lines · plain
1; RUN: llc %s -stop-after=finalize-isel -o - \2; RUN: | FileCheck %s --implicit-check-not=DBG_3 4;; $ cat test.cpp5;; int d();6;; void e();7;; void es(int*);8;; int *g;9;; int f(int a, int b, int c) {10;; do {11;; /* stuff */12;; c *= c;13;; a = b;14;; e();15;; } while (d());16;; es(&a);17;; return a + c;18;; }19 20;; The variable of interest is `a`, which has a store that is hoisted out of the21;; loop into the entry BB. Check the memory location is not used after the22;; hoisted store until the assignment position within the loop.23 24; CHECK-DAG: ![[A:[0-9]+]] = !DILocalVariable(name: "a",25 26; CHECK: bb.0.entry:27; CHECK: DBG_VALUE $edi, $noreg, ![[A]], !DIExpression()28 29; CHECK: bb.1.do.body:30; CHECK: DBG_VALUE %stack.0.a.addr, $noreg, ![[A]], !DIExpression(DW_OP_deref)31 32target triple = "x86_64-unknown-linux-gnu"33 34@g = dso_local local_unnamed_addr global ptr null, align 8, !dbg !035 36define dso_local noundef i32 @_Z1fiii(i32 noundef %a, i32 noundef %b, i32 noundef %c) local_unnamed_addr #0 !dbg !12 {37entry:38 %a.addr = alloca i32, align 4, !DIAssignID !1939 call void @llvm.dbg.assign(metadata i1 undef, metadata !16, metadata !DIExpression(), metadata !19, metadata ptr %a.addr, metadata !DIExpression()), !dbg !2040 call void @llvm.dbg.assign(metadata i32 %a, metadata !16, metadata !DIExpression(), metadata !21, metadata ptr %a.addr, metadata !DIExpression()), !dbg !2041 store i32 %b, ptr %a.addr, align 4, !DIAssignID !2842 br label %do.body, !dbg !2943 44do.body: ; preds = %do.body, %entry45 %c.addr.0 = phi i32 [ %c, %entry ], [ %mul, %do.body ]46 %mul = mul nsw i32 %c.addr.0, %c.addr.0, !dbg !3047 call void @llvm.dbg.assign(metadata i32 %b, metadata !16, metadata !DIExpression(), metadata !28, metadata ptr %a.addr, metadata !DIExpression()), !dbg !2048 tail call void @_Z1ev(), !dbg !3349 %call = tail call noundef i32 @_Z1dv(), !dbg !3450 %tobool.not = icmp eq i32 %call, 0, !dbg !3451 br i1 %tobool.not, label %do.end, label %do.body, !dbg !35, !llvm.loop !3652 53do.end: ; preds = %do.body54 call void @_Z2esPi(ptr noundef nonnull %a.addr), !dbg !3955 %0 = load i32, ptr %a.addr, align 4, !dbg !4056 %add = add nsw i32 %0, %mul, !dbg !4157 ret i32 %add, !dbg !4258}59 60declare !dbg !43 dso_local void @_Z1ev() local_unnamed_addr #161declare !dbg !47 dso_local noundef i32 @_Z1dv() local_unnamed_addr #162declare !dbg !50 dso_local void @_Z2esPi(ptr noundef) local_unnamed_addr #163declare void @llvm.dbg.assign(metadata, metadata, metadata, metadata, metadata, metadata) #264declare void @llvm.dbg.value(metadata, metadata, metadata) #365 66!llvm.dbg.cu = !{!2}67!llvm.module.flags = !{!7, !8, !9, !10, !1000}68!llvm.ident = !{!11}69 70!0 = !DIGlobalVariableExpression(var: !1, expr: !DIExpression())71!1 = distinct !DIGlobalVariable(name: "g", scope: !2, file: !3, line: 4, type: !5, isLocal: false, isDefinition: true)72!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)73!3 = !DIFile(filename: "test.cpp", directory: "/")74!4 = !{!0}75!5 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !6, size: 64)76!6 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)77!7 = !{i32 7, !"Dwarf Version", i32 5}78!8 = !{i32 2, !"Debug Info Version", i32 3}79!9 = !{i32 1, !"wchar_size", i32 4}80!10 = !{i32 7, !"uwtable", i32 1}81!11 = !{!"clang version 14.0.0"}82!12 = distinct !DISubprogram(name: "f", linkageName: "_Z1fiii", scope: !3, file: !3, line: 5, type: !13, scopeLine: 5, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !2, retainedNodes: !15)83!13 = !DISubroutineType(types: !14)84!14 = !{!6, !6, !6, !6}85!15 = !{!16, !17, !18}86!16 = !DILocalVariable(name: "a", arg: 1, scope: !12, file: !3, line: 5, type: !6)87!17 = !DILocalVariable(name: "b", arg: 2, scope: !12, file: !3, line: 5, type: !6)88!18 = !DILocalVariable(name: "c", arg: 3, scope: !12, file: !3, line: 5, type: !6)89!19 = distinct !DIAssignID()90!20 = !DILocation(line: 0, scope: !12)91!21 = distinct !DIAssignID()92!22 = distinct !DIAssignID()93!23 = distinct !DIAssignID()94!28 = distinct !DIAssignID()95!29 = !DILocation(line: 6, column: 3, scope: !12)96!30 = !DILocation(line: 8, column: 7, scope: !31)97!31 = distinct !DILexicalBlock(scope: !12, file: !3, line: 6, column: 6)98!32 = distinct !DIAssignID()99!33 = !DILocation(line: 10, column: 5, scope: !31)100!34 = !DILocation(line: 11, column: 12, scope: !12)101!35 = !DILocation(line: 11, column: 3, scope: !31)102!36 = distinct !{!36, !29, !37, !38}103!37 = !DILocation(line: 11, column: 15, scope: !12)104!38 = !{!"llvm.loop.mustprogress"}105!39 = !DILocation(line: 12, column: 3, scope: !12)106!40 = !DILocation(line: 13, column: 10, scope: !12)107!41 = !DILocation(line: 13, column: 12, scope: !12)108!42 = !DILocation(line: 13, column: 3, scope: !12)109!43 = !DISubprogram(name: "e", linkageName: "_Z1ev", scope: !3, file: !3, line: 2, type: !44, flags: DIFlagPrototyped, spFlags: DISPFlagOptimized, retainedNodes: !46)110!44 = !DISubroutineType(types: !45)111!45 = !{null}112!46 = !{}113!47 = !DISubprogram(name: "d", linkageName: "_Z1dv", scope: !3, file: !3, line: 1, type: !48, flags: DIFlagPrototyped, spFlags: DISPFlagOptimized, retainedNodes: !46)114!48 = !DISubroutineType(types: !49)115!49 = !{!6}116!50 = !DISubprogram(name: "es", linkageName: "_Z2esPi", scope: !3, file: !3, line: 3, type: !51, flags: DIFlagPrototyped, spFlags: DISPFlagOptimized, retainedNodes: !46)117!51 = !DISubroutineType(types: !52)118!52 = !{null, !5}119!1000 = !{i32 7, !"debug-info-assignment-tracking", i1 true}120