xref: /llvm-project/llvm/test/DebugInfo/X86/sroasplit-dbg-declare.ll (revision 094572701dce4aaf36f4521d6cf750420d39f206)
1; RUN: opt -S -passes='sroa' -o - %s | FileCheck %s
2; RUN: opt --try-experimental-debuginfo-iterators -S -passes='sroa' -o - %s | FileCheck %s
3
4; SROA should split the alloca in two new ones, each with its own dbg.declare.
5; The original alloca and dbg.declare should be removed.
6
7define void @f1() {
8entry:
9  %0 = alloca [9 x i32]
10  call void @llvm.dbg.declare(metadata ptr %0, metadata !11, metadata !DIExpression()), !dbg !17
11  call void @llvm.memset.p0.i64(ptr align 16 %0, i8 0, i64 36, i1 true)
12  store volatile i32 1, ptr %0
13  ret void
14}
15
16; Function Attrs: nounwind readnone speculatable
17declare void @llvm.dbg.declare(metadata, metadata, metadata) #1
18
19; Function Attrs: argmemonly nounwind
20declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1) #0
21
22attributes #0 = { argmemonly nounwind }
23attributes #1 = { nounwind readnone speculatable }
24
25!llvm.dbg.cu = !{!0}
26!llvm.module.flags = !{!3, !4, !5}
27!llvm.ident = !{!6}
28
29!0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang version 6.0.0", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2)
30!1 = !DIFile(filename: "foo.c", directory: "/bar")
31!2 = !{}
32!3 = !{i32 2, !"Dwarf Version", i32 4}
33!4 = !{i32 2, !"Debug Info Version", i32 3}
34!5 = !{i32 1, !"wchar_size", i32 4}
35!6 = !{!"clang version 6.0.0"}
36!7 = distinct !DISubprogram(name: "f1", scope: !1, file: !1, line: 1, type: !8, isLocal: false, isDefinition: true, scopeLine: 2, flags: DIFlagPrototyped, isOptimized: true, unit: !0, retainedNodes: !10)
37!8 = !DISubroutineType(types: !9)
38!9 = !{null}
39!10 = !{!11}
40!11 = !DILocalVariable(name: "b", scope: !7, file: !1, line: 3, type: !12)
41!12 = !DICompositeType(tag: DW_TAG_array_type, baseType: !13, size: 288, elements: !15)
42!13 = !DIDerivedType(tag: DW_TAG_volatile_type, baseType: !14)
43!14 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
44!15 = !{!16}
45!16 = !DISubrange(count: 9)
46!17 = !DILocation(line: 3, column: 18, scope: !7)
47
48; CHECK-NOT:  = alloca [9 x i32]
49; CHECK-NOT:  #dbg_declare(ptr
50
51; CHECK:      %[[VAR1:.*]] = alloca i32
52; CHECK-NEXT: %[[VAR2:.*]] = alloca [8 x i32]
53; CHECK-NEXT: #dbg_declare(ptr %[[VAR1]]
54; CHECK-NEXT: #dbg_declare(ptr %[[VAR2]]
55
56; CHECK-NOT:  = alloca [9 x i32]
57; CHECK-NOT:  #dbg_declare(ptr
58
59