88 lines · plain
1; RUN: opt %s -S -passes=inline -o - | FileCheck %s2 3;; Check that all DIAssignID metadata that are inlined are replaced with new4;; versions. Otherwise two inlined instances of an assignment will be considered5;; to be the same assignment.6;;7;; $cat test.cpp8;; __attribute__((always_inline))9;; int get() { int val = 5; return val; }10;; void fun() {11;; get();12;; get();13;; }14 15; CHECK-LABEL: _Z3funv16;17; CHECK: store i32 5, ptr %val.i, align 4{{.*}}, !DIAssignID [[ID_0:![0-9]+]]18; CHECK-NEXT: #dbg_assign(i32 5, [[val:![0-9]+]], !DIExpression(), [[ID_0]], ptr %val.i, !DIExpression(), [[dl_inline_0:![0-9]+]]19;20; CHECK: store i32 5, ptr %val.i1, align 4{{.*}}, !DIAssignID [[ID_1:![0-9]+]]21; CHECK-NEXT: #dbg_assign(i32 5, [[val]], !DIExpression(), [[ID_1]], ptr %val.i1, !DIExpression(), [[dl_inline_1:![0-9]+]]22;23; CHECK-DAG: [[val]] = !DILocalVariable(name: "val",24; CHECK-DAG: [[dl_inline_0]] = !DILocation({{.*}}inlinedAt25; CHECK-DAG: [[dl_inline_1]] = !DILocation({{.*}}inlinedAt26; CHECK-DAG: [[ID_0]] = distinct !DIAssignID()27; CHECK-DAG: [[ID_1]] = distinct !DIAssignID()28 29define dso_local i32 @_Z3getv() !dbg !7 {30entry:31 %val = alloca i32, align 4, !DIAssignID !1332 call void @llvm.dbg.assign(metadata i1 undef, metadata !12, metadata !DIExpression(), metadata !13, metadata ptr %val, metadata !DIExpression()), !dbg !1433 %0 = bitcast ptr %val to ptr, !dbg !1534 call void @llvm.lifetime.start.p0(i64 4, ptr %0), !dbg !1535 store i32 5, ptr %val, align 4, !dbg !16, !DIAssignID !2136 call void @llvm.dbg.assign(metadata i32 5, metadata !12, metadata !DIExpression(), metadata !21, metadata ptr %val, metadata !DIExpression()), !dbg !1437 %1 = load i32, ptr %val, align 4, !dbg !2238 %2 = bitcast ptr %val to ptr, !dbg !2339 call void @llvm.lifetime.end.p0(i64 4, ptr %2), !dbg !2340 ret i32 %1, !dbg !2441}42 43declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture)44declare void @llvm.dbg.declare(metadata, metadata, metadata)45declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture)46declare void @llvm.dbg.assign(metadata, metadata, metadata, metadata, metadata, metadata)47 48; Function Attrs: nounwind uwtable mustprogress49define dso_local void @_Z3funv() !dbg !25 {50entry:51 %call = call i32 @_Z3getv(), !dbg !2852 %call1 = call i32 @_Z3getv(), !dbg !2953 ret void, !dbg !3054}55 56!llvm.dbg.cu = !{!0}57!llvm.module.flags = !{!3, !4, !5, !1000}58!llvm.ident = !{!6}59 60!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus_14, file: !1, producer: "clang version 12.0.0", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, splitDebugInlining: false, nameTableKind: None)61!1 = !DIFile(filename: "test.cpp", directory: "")62!2 = !{}63!3 = !{i32 7, !"Dwarf Version", i32 4}64!4 = !{i32 2, !"Debug Info Version", i32 3}65!5 = !{i32 1, !"wchar_size", i32 4}66!6 = !{!"clang version 12.0.0"}67!7 = distinct !DISubprogram(name: "get", linkageName: "_Z3getv", scope: !1, file: !1, line: 2, type: !8, scopeLine: 2, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !11)68!8 = !DISubroutineType(types: !9)69!9 = !{!10}70!10 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)71!11 = !{!12}72!12 = !DILocalVariable(name: "val", scope: !7, file: !1, line: 2, type: !10)73!13 = distinct !DIAssignID()74!14 = !DILocation(line: 0, scope: !7)75!15 = !DILocation(line: 2, column: 13, scope: !7)76!16 = !DILocation(line: 2, column: 17, scope: !7)77!21 = distinct !DIAssignID()78!22 = !DILocation(line: 2, column: 33, scope: !7)79!23 = !DILocation(line: 2, column: 38, scope: !7)80!24 = !DILocation(line: 2, column: 26, scope: !7)81!25 = distinct !DISubprogram(name: "fun", linkageName: "_Z3funv", scope: !1, file: !1, line: 3, type: !26, scopeLine: 3, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !2)82!26 = !DISubroutineType(types: !27)83!27 = !{null}84!28 = !DILocation(line: 4, column: 3, scope: !25)85!29 = !DILocation(line: 5, column: 3, scope: !25)86!30 = !DILocation(line: 6, column: 1, scope: !25)87!1000 = !{i32 7, !"debug-info-assignment-tracking", i1 true}88