1; Test that SROA can deal with allocas that have more than one
2; dbg.declare hanging off of it.
3
4; RUN: opt < %s -passes=sroa -S | FileCheck %s
5source_filename = "/tmp/inlinesplit.cpp"
6target datalayout = "e-m:o-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
7target triple = "x86_64-apple-macosx10.15.0"
8
9%struct.pair = type { i64, i64 }
10
11; Function Attrs: noinline optnone ssp uwtable
12define i64 @_Z1g4pair(i64 %p.coerce0, i64 %p.coerce1) #0 !dbg !8 {
13entry:
14  %p = alloca %struct.pair, align 8
15  store i64 %p.coerce0, ptr %p, align 8
16  %0 = getelementptr inbounds %struct.pair, ptr %p, i32 0, i32 1
17  store i64 %p.coerce1, ptr %0, align 8
18  ; CHECK-DAG: call void @llvm.dbg.value(metadata i64 %p.coerce0, metadata ![[VAR:[0-9]+]], metadata !DIExpression(DW_OP_LLVM_fragment, 0, 64)), !dbg ![[LOC:[0-9]+]]
19  ; CHECK-DAG: call void @llvm.dbg.value(metadata i64 %p.coerce1, metadata ![[VAR]], metadata !DIExpression(DW_OP_LLVM_fragment, 64, 64)), !dbg ![[LOC]]
20  ; CHECK-DAG: call void @llvm.dbg.value(metadata i64 %p.coerce0, metadata ![[INLINED_VAR:[0-9]+]], metadata !DIExpression(DW_OP_LLVM_fragment, 0, 64)), !dbg ![[INLINED_LOC:[0-9]+]]
21  ; CHECK-DAG: call void @llvm.dbg.value(metadata i64 %p.coerce1, metadata ![[INLINED_VAR]], metadata !DIExpression(DW_OP_LLVM_fragment, 64, 64)), !dbg ![[INLINED_LOC]]
22  call void @llvm.dbg.declare(metadata ptr %p, metadata !17, metadata !DIExpression()), !dbg !18
23  call void @llvm.dbg.declare(metadata ptr %p, metadata !21, metadata !DIExpression()), !dbg !23
24  %x2 = load i64, ptr %p, align 8, !dbg !25
25  ret i64 %x2, !dbg !26
26}
27
28; Function Attrs: nounwind readnone speculatable willreturn
29declare void @llvm.dbg.declare(metadata, metadata, metadata) #1
30
31; Function Attrs: argmemonly nounwind willreturn
32declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #2
33
34attributes #0 = { noinline ssp uwtable }
35attributes #1 = { nounwind readnone speculatable willreturn }
36attributes #2 = { argmemonly nounwind willreturn }
37
38!llvm.dbg.cu = !{!0}
39!llvm.module.flags = !{!3, !4, !5, !6}
40
41!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus_14, file: !1, producer: "clang version 12.0.0 ([email protected]:llvm/llvm-project 5110fd0343c2d06c8ae538741fbef13ece5e68de)", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, nameTableKind: None, sysroot: "/")
42!1 = !DIFile(filename: "/tmp/inlinesplit.cpp", directory: "/Volumes/Data/llvm-project")
43!2 = !{}
44!3 = !{i32 7, !"Dwarf Version", i32 4}
45!4 = !{i32 2, !"Debug Info Version", i32 3}
46!5 = !{i32 1, !"wchar_size", i32 4}
47!6 = !{i32 7, !"PIC Level", i32 2}
48!8 = distinct !DISubprogram(name: "g", linkageName: "_Z1g4pair", scope: !9, file: !9, line: 9, type: !10, scopeLine: 9, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !0, retainedNodes: !2)
49!9 = !DIFile(filename: "/tmp/inlinesplit.cpp", directory: "")
50!10 = !DISubroutineType(types: !11)
51!11 = !{!12, !13}
52!12 = !DIBasicType(name: "long long unsigned int", size: 64, encoding: DW_ATE_unsigned)
53!13 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "pair", file: !9, line: 1, size: 128, flags: DIFlagTypePassByValue, elements: !14, identifier: "_ZTS4pair")
54!14 = !{!15, !16}
55!15 = !DIDerivedType(tag: DW_TAG_member, name: "a", scope: !13, file: !9, line: 1, baseType: !12, size: 64)
56!16 = !DIDerivedType(tag: DW_TAG_member, name: "b", scope: !13, file: !9, line: 1, baseType: !12, size: 64, offset: 64)
57!17 = !DILocalVariable(name: "p", arg: 1, scope: !8, file: !9, line: 9, type: !13)
58; CHECK: ![[LOC]] = !DILocation
59; CHECK-NOT: inlinedAt
60; CHECK: =
61!18 = !DILocation(line: 9, column: 27, scope: !8)
62!19 = !DILocation(line: 10, column: 12, scope: !8)
63!20 = !DILocation(line: 10, column: 10, scope: !8)
64!21 = !DILocalVariable(name: "p", arg: 1, scope: !22, file: !9, line: 5, type: !13)
65!22 = distinct !DISubprogram(name: "f", linkageName: "_ZL1f4pair", scope: !9, file: !9, line: 5, type: !10, scopeLine: 5, flags: DIFlagPrototyped, spFlags: DISPFlagLocalToUnit | DISPFlagDefinition, unit: !0, retainedNodes: !2)
66; CHECK: ![[INLINED_LOC]] = !DILocation({{.*}}inlinedAt
67!23 = !DILocation(line: 5, column: 27, scope: !22, inlinedAt: !24)
68!24 = distinct !DILocation(line: 10, column: 10, scope: !8)
69!25 = !DILocation(line: 6, column: 12, scope: !22, inlinedAt: !24)
70!26 = !DILocation(line: 10, column: 3, scope: !8)
71