80 lines · plain
1; RUN: opt %s -S -passes=instcombine -o - \2; RUN: | FileCheck %s3 4;; $ cat test.cpp5;; void esc(int*);6;; void fun() {7;; int local[5];8;; __builtin_memset(local, 8, 4 * 4);9;; __builtin_memset(local, 0, 2 * 4);10;; esc(local);11;; }12;; IR grabbed before instcombine in:13;; clang++ -O2 -g -Xclang -fexperimental-assignment-tracking14 15;; Instcombine is going to turn the second memset into a store. Check that it16;; inherits the DIAssignID from the memset and that the dbg.assign's value17;; component is correct.18 19; CHECK: store i64 0, ptr %local, align 16{{.*}}, !DIAssignID ![[ID:[0-9]+]]20; CHECK-NEXT: #dbg_assign(i64 0, !{{.*}}, !DIExpression(DW_OP_LLVM_fragment, 0, 64), ![[ID]], ptr %local, !DIExpression(),21 22define dso_local void @_Z3funv() local_unnamed_addr #0 !dbg !7 {23entry:24 %local = alloca [5 x i32], align 16, !DIAssignID !1625 call void @llvm.dbg.assign(metadata i1 undef, metadata !11, metadata !DIExpression(), metadata !16, metadata ptr %local, metadata !DIExpression()), !dbg !1726 %0 = bitcast ptr %local to ptr, !dbg !1827 call void @llvm.lifetime.start.p0(i64 20, ptr %0) #5, !dbg !1828 %arraydecay = getelementptr inbounds [5 x i32], ptr %local, i64 0, i64 0, !dbg !1929 %1 = bitcast ptr %arraydecay to ptr, !dbg !1930 call void @llvm.memset.p0.i64(ptr align 16 %1, i8 8, i64 16, i1 false), !dbg !19, !DIAssignID !2031 call void @llvm.dbg.assign(metadata i8 8, metadata !11, metadata !DIExpression(DW_OP_LLVM_fragment, 0, 128), metadata !20, metadata ptr %1, metadata !DIExpression()), !dbg !1732 call void @llvm.memset.p0.i64(ptr align 16 %1, i8 0, i64 8, i1 false), !dbg !21, !DIAssignID !2233 call void @llvm.dbg.assign(metadata i8 0, metadata !11, metadata !DIExpression(DW_OP_LLVM_fragment, 0, 64), metadata !22, metadata ptr %1, metadata !DIExpression()), !dbg !1734 call void @_Z3escPi(ptr noundef %arraydecay), !dbg !2335 call void @llvm.lifetime.end.p0(i64 20, ptr %0) #5, !dbg !2436 ret void, !dbg !2437}38 39declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture)40declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg)41declare !dbg !25 dso_local void @_Z3escPi(ptr noundef) local_unnamed_addr42declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture)43declare void @llvm.dbg.assign(metadata, metadata, metadata, metadata, metadata, metadata)44 45!llvm.dbg.cu = !{!0}46!llvm.module.flags = !{!2, !3, !4, !5, !1000}47!llvm.ident = !{!6}48 49!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus_14, file: !1, producer: "clang version 14.0.0", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, splitDebugInlining: false, nameTableKind: None)50!1 = !DIFile(filename: "test.cpp", directory: "/")51!2 = !{i32 7, !"Dwarf Version", i32 5}52!3 = !{i32 2, !"Debug Info Version", i32 3}53!4 = !{i32 1, !"wchar_size", i32 4}54!5 = !{i32 7, !"uwtable", i32 1}55!6 = !{!"clang version 14.0.0"}56!7 = distinct !DISubprogram(name: "fun", linkageName: "_Z3funv", scope: !1, file: !1, line: 2, type: !8, scopeLine: 2, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !10)57!8 = !DISubroutineType(types: !9)58!9 = !{null}59!10 = !{!11}60!11 = !DILocalVariable(name: "local", scope: !7, file: !1, line: 3, type: !12)61!12 = !DICompositeType(tag: DW_TAG_array_type, baseType: !13, size: 160, elements: !14)62!13 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)63!14 = !{!15}64!15 = !DISubrange(count: 5)65!16 = distinct !DIAssignID()66!17 = !DILocation(line: 0, scope: !7)67!18 = !DILocation(line: 3, column: 3, scope: !7)68!19 = !DILocation(line: 4, column: 3, scope: !7)69!20 = distinct !DIAssignID()70!21 = !DILocation(line: 5, column: 3, scope: !7)71!22 = distinct !DIAssignID()72!23 = !DILocation(line: 6, column: 3, scope: !7)73!24 = !DILocation(line: 7, column: 1, scope: !7)74!25 = !DISubprogram(name: "esc", linkageName: "_Z3escPi", scope: !1, file: !1, line: 1, type: !26, flags: DIFlagPrototyped, spFlags: DISPFlagOptimized, retainedNodes: !29)75!26 = !DISubroutineType(types: !27)76!27 = !{null, !28}77!28 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !13, size: 64)78!29 = !{}79!1000 = !{i32 7, !"debug-info-assignment-tracking", i1 true}80