1 ; RUN: not llc < %s -filetype=obj 2>&1 | FileCheck %s
3 ; Verify the compiler produces an error message when trying to emit circular
4 ; references to unnamed structs which are not supported in CodeView debug
7 ; -- types-recursive-unnamed.cpp begin -----------------------------------------
8 ; struct named_struct {
11 ; } unnamed_struct_with_method;
14 ; void named_struct::anchor() {}
15 ; -- types-recursive-unnamed.cpp end -------------------------------------------
17 ; To rebuild the reproducer:
18 ; 1. First, compile the source code:
19 ; $ clang -S -emit-llvm -g -gcodeview unnamed.cpp
20 ; 2. Remove all "name" and "identifier" attributes with a value matching
21 ; the form: "<unnamed-type-".
23 ; CHECK: LLVM ERROR: cannot debug circular reference to unnamed type
25 ; ModuleID = 'types-recursive-unnamed.cpp'
26 source_filename = "types-recursive-unnamed.cpp"
27 target datalayout = "e-m:w-i64:64-f80:128-n8:16:32:64-S128"
28 target triple = "x86_64-pc-windows-msvc19.0.24210"
30 %struct.named_struct = type { %struct.anon }
31 %struct.anon = type { i8 }
33 ; Function Attrs: noinline nounwind uwtable
34 define void @"\01?anchor@named_struct@@QEAAXXZ"(%struct.named_struct* %this) #0 align 2 !dbg !7 {
36 %this.addr = alloca %struct.named_struct*, align 8
37 store %struct.named_struct* %this, %struct.named_struct** %this.addr, align 8
38 call void @llvm.dbg.declare(metadata %struct.named_struct** %this.addr, metadata !21, metadata !23), !dbg !24
39 %this1 = load %struct.named_struct*, %struct.named_struct** %this.addr, align 8
43 ; Function Attrs: nounwind readnone
44 declare void @llvm.dbg.declare(metadata, metadata, metadata) #1
46 attributes #0 = { noinline nounwind uwtable "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "less-precise-fpmad"="false" "no-frame-pointer-elim"="false" "no-infs-fp-math"="false" "no-jump-tables"="false" "no-nans-fp-math"="false" "no-signed-zeros-fp-math"="false" "no-trapping-math"="false" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+fxsr,+mmx,+sse,+sse2,+x87" "unsafe-fp-math"="false" "use-soft-float"="false" }
47 attributes #1 = { nounwind readnone }
50 !llvm.module.flags = !{!3, !4, !5}
53 !0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !1, producer: "clang version 5.0.0", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !2)
54 !1 = !DIFile(filename: "types-recursive-unnamed.cpp", directory: "C:\5Cpath\5Cto\5Cdirectory", checksumkind: CSK_MD5, checksum: "59a90813f3338cfe690d9664215089df")
56 !3 = !{i32 2, !"CodeView", i32 1}
57 !4 = !{i32 2, !"Debug Info Version", i32 3}
58 !5 = !{i32 1, !"PIC Level", i32 2}
59 !6 = !{!"clang version 5.0.0"}
60 !7 = distinct !DISubprogram(name: "anchor", linkageName: "\01?anchor@named_struct@@QEAAXXZ", scope: !8, file: !1, line: 7, type: !18, isLocal: false, isDefinition: true, scopeLine: 7, flags: DIFlagPrototyped, isOptimized: false, unit: !0, declaration: !17, retainedNodes: !2)
61 !8 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "named_struct", file: !1, line: 1, size: 8, elements: !9, identifier: ".?AUnamed_struct@@")
63 !10 = distinct !DICompositeType(tag: DW_TAG_structure_type, scope: !8, file: !1, line: 2, size: 8, elements: !11)
65 !12 = !DISubprogram(name: "method", linkageName: "\01?method@<unnamed-type-unnamed_struct_with_method>@named_struct@@QEAAXXZ", scope: !10, file: !1, line: 3, type: !13, isLocal: false, isDefinition: false, scopeLine: 3, flags: DIFlagPrototyped, isOptimized: false)
66 !13 = !DISubroutineType(types: !14)
68 !15 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !10, size: 64, flags: DIFlagArtificial | DIFlagObjectPointer)
69 !16 = !DIDerivedType(tag: DW_TAG_member, name: "unnamed_struct_with_method", scope: !8, file: !1, line: 4, baseType: !10, size: 8)
70 !17 = !DISubprogram(name: "anchor", linkageName: "\01?anchor@named_struct@@QEAAXXZ", scope: !8, file: !1, line: 5, type: !18, isLocal: false, isDefinition: false, scopeLine: 5, flags: DIFlagPrototyped, isOptimized: false)
71 !18 = !DISubroutineType(types: !19)
73 !20 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !8, size: 64, flags: DIFlagArtificial | DIFlagObjectPointer)
74 !21 = !DILocalVariable(name: "this", arg: 1, scope: !7, type: !22, flags: DIFlagArtificial | DIFlagObjectPointer)
75 !22 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !8, size: 64)
77 !24 = !DILocation(line: 0, scope: !7)
78 !25 = !DILocation(line: 7, column: 30, scope: !7)