1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; Test that the getelementptr generated when the dse pass determines that
3 ; a memset can be shortened has the debugloc carried over from the memset.
5 ; RUN: opt -S -march=native -passes=dse < %s| FileCheck %s
6 ; CHECK: %{{[0-9]+}} = getelementptr inbounds i8, ptr %b, i64 32, !dbg ![[DBG:[0-9]+]]
7 ; CHECK-NEXT: call void @llvm.memset.p0.i64(ptr align 16 %0, i8 0, i64 8, i1 false), !dbg ![[DBG:[0-9]+]]
8 ; CHECK: ![[DBG]] = !DILocation(line: 2,
10 ; The test IR is generated by running:
12 ; clang Debugify_Dead_Store_Elimination.cpp -Wno-c++11-narrowing -S \
13 ; -emit-llvm -O0 -w -Xclang -disable-O0-optnone -march=native -fdeclspec \
14 ; --target=x86_64-gnu-linux-unknown -Werror=unreachable-code -o -
16 ; Where Debugify_Dead_Store_Elimination.cpp contains:
19 ; long b[]{2, 2, 2, 2, 0};
25 declare void @use(ptr)
27 define dso_local i32 @_Z1av() !dbg !7 {
29 %retval = alloca i32, align 4
30 %b = alloca [5 x i64], align 16
31 call void @llvm.dbg.declare(metadata ptr %b, metadata !11, metadata !DIExpression()), !dbg !16
32 call void @llvm.memset.p0.i64(ptr align 16 %b, i8 0, i64 40, i1 false), !dbg !16
33 store i64 2, ptr %b, align 16, !dbg !16
34 %0 = getelementptr inbounds [5 x i64], ptr %b, i32 0, i32 1, !dbg !16
35 store i64 2, ptr %0, align 8, !dbg !16
36 %1 = getelementptr inbounds [5 x i64], ptr %b, i32 0, i32 2, !dbg !16
37 store i64 2, ptr %1, align 16, !dbg !16
38 %2 = getelementptr inbounds [5 x i64], ptr %b, i32 0, i32 3, !dbg !16
39 store i64 2, ptr %2, align 8, !dbg !16
40 call void @use(ptr %b)
41 %call = call i32 @_Z1av(), !dbg !17
42 %tobool = icmp ne i32 %call, 0, !dbg !17
43 br i1 %tobool, label %if.then, label %if.end, !dbg !19
45 if.then: ; preds = %entry
46 br label %if.end, !dbg !19
48 if.end: ; preds = %if.then, %entry
49 call void @llvm.trap(), !dbg !20
52 return: ; No predecessors!
53 %3 = load i32, ptr %retval, align 4, !dbg !21
57 ; Function Attrs: nounwind readnone speculatable
58 declare void @llvm.dbg.declare(metadata, metadata, metadata)
60 ; Function Attrs: argmemonly nounwind
61 declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg)
63 ; Function Attrs: cold noreturn nounwind
64 declare void @llvm.trap()
66 !llvm.module.flags = !{!3, !4, !5}
69 !0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !1, producer: "clang version 9.0.0 (https://github.com/llvm/llvm-project.git eb1a156d7f7ba56ea8f9a26da36e6a93d1e98bda)", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, nameTableKind: None)
70 !1 = !DIFile(filename: "Debugify_Dead_Store_Elimination.cpp", directory: "")
72 !3 = !{i32 2, !"Dwarf Version", i32 4}
73 !4 = !{i32 2, !"Debug Info Version", i32 3}
74 !5 = !{i32 1, !"wchar_size", i32 4}
75 !6 = !{!"clang version 9.0.0 (https://github.com/llvm/llvm-project.git eb1a156d7f7ba56ea8f9a26da36e6a93d1e98bda)"}
76 !7 = distinct !DISubprogram(name: "a", linkageName: "_Z1av", scope: !1, file: !1, line: 1, type: !8, scopeLine: 1, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !0, retainedNodes: !2)
77 !8 = !DISubroutineType(types: !9)
79 !10 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
80 !11 = !DILocalVariable(name: "b", scope: !7, file: !1, line: 2, type: !12)
81 !12 = !DICompositeType(tag: DW_TAG_array_type, baseType: !13, size: 320, elements: !14)
82 !13 = !DIBasicType(name: "long int", size: 64, encoding: DW_ATE_signed)
84 !15 = !DISubrange(count: 5)
85 !16 = !DILocation(line: 2, column: 8, scope: !7)
86 !17 = !DILocation(line: 3, column: 7, scope: !18)
87 !18 = distinct !DILexicalBlock(scope: !7, file: !1, line: 3, column: 7)
88 !19 = !DILocation(line: 3, column: 7, scope: !7)
89 !20 = !DILocation(line: 3, column: 9, scope: !18)
90 !21 = !DILocation(line: 5, column: 1, scope: !7)