xref: /llvm-project/llvm/test/DebugInfo/Generic/assignment-tracking/sroa/unspecified-var-size.ll (revision 094572701dce4aaf36f4521d6cf750420d39f206)
1; RUN: opt -S %s -passes=sroa -o - | FileCheck %s
2; RUN: opt --try-experimental-debuginfo-iterators -S %s -passes=sroa -o - | FileCheck %s
3
4;; $ cat test.cpp
5;; #include <cstddef>
6;; void fun(std::nullptr_t) {}
7;;
8;; Check that migrateDebugInfo doesn't crash when encountering an alloca for a
9;; variable with a type of unspecified size (e.g. DW_TAG_unspecified_type).
10
11; CHECK: #dbg_value(ptr %0,{{.+}}, !DIExpression(),
12;; There should be no new fragment and the value component should remain as %0.
13
14define dso_local void @_Z3funDn(ptr %0) #0 !dbg !14 {
15entry:
16  %.addr = alloca ptr, align 8, !DIAssignID !22
17  call void @llvm.dbg.assign(metadata i1 undef, metadata !21, metadata !DIExpression(), metadata !22, metadata ptr %.addr, metadata !DIExpression()), !dbg !23
18  store ptr %0, ptr %.addr, align 8, !DIAssignID !28
19  call void @llvm.dbg.assign(metadata ptr %0, metadata !21, metadata !DIExpression(), metadata !28, metadata ptr %.addr, metadata !DIExpression()), !dbg !23
20  ret void, !dbg !29
21}
22
23declare void @llvm.dbg.declare(metadata, metadata, metadata) #1
24declare void @llvm.dbg.assign(metadata, metadata, metadata, metadata, metadata, metadata) #1
25
26!llvm.dbg.cu = !{!0}
27!llvm.module.flags = !{!10, !11, !12, !1000}
28!llvm.ident = !{!13}
29
30!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, imports: !3, splitDebugInlining: false, nameTableKind: None)
31!1 = !DIFile(filename: "test.cpp", directory: "/")
32!2 = !{}
33!3 = !{!4}
34!4 = !DIImportedEntity(tag: DW_TAG_imported_declaration, scope: !5, entity: !6, file: !9, line: 56)
35!5 = !DINamespace(name: "std", scope: null)
36!6 = !DIDerivedType(tag: DW_TAG_typedef, name: "max_align_t", file: !7, line: 24, baseType: !8)
37!7 = !DIFile(filename: "clang/12.0.0/include/__stddef_max_align_t.h", directory: "/")
38!8 = !DICompositeType(tag: DW_TAG_structure_type, file: !7, line: 19, size: 256, flags: DIFlagFwdDecl, identifier: "_ZTS11max_align_t")
39!9 = !DIFile(filename: "include/c++/7.5.0/cstddef", directory: "")
40!10 = !{i32 7, !"Dwarf Version", i32 4}
41!11 = !{i32 2, !"Debug Info Version", i32 3}
42!12 = !{i32 1, !"wchar_size", i32 4}
43!13 = !{!"clang version 12.0.0"}
44!14 = distinct !DISubprogram(name: "fun", linkageName: "_Z3funDn", scope: !1, file: !1, line: 20, type: !15, scopeLine: 20, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !20)
45!15 = !DISubroutineType(types: !16)
46!16 = !{null, !17}
47!17 = !DIDerivedType(tag: DW_TAG_typedef, name: "nullptr_t", scope: !5, file: !18, line: 235, baseType: !19)
48!18 = !DIFile(filename: "include/x86_64-linux-gnu/c++/7.5.0/bits/c++config.h", directory: "")
49!19 = !DIBasicType(tag: DW_TAG_unspecified_type, name: "decltype(nullptr)")
50!20 = !{!21}
51!21 = !DILocalVariable(arg: 1, scope: !14, file: !1, line: 20, type: !17)
52!22 = distinct !DIAssignID()
53!23 = !DILocation(line: 0, scope: !14)
54!28 = distinct !DIAssignID()
55!29 = !DILocation(line: 20, column: 27, scope: !14)
56!1000 = !{i32 7, !"debug-info-assignment-tracking", i1 true}
57