xref: /llvm-project/llvm/test/DebugInfo/COFF/cpp-mangling.ll (revision 10b03e66629aedad79a804e22d23b575077303b3)
1; RUN: llc -mcpu=core2 -mtriple=i686-pc-win32 -o - -O0 -filetype=obj < %s \
2; RUN:   | llvm-readobj --codeview - | FileCheck %s
3
4; RUN: llc --try-experimental-debuginfo-iterators -mcpu=core2 -mtriple=i686-pc-win32 -o - -O0 -filetype=obj < %s \
5; RUN:   | llvm-readobj --codeview - | FileCheck %s
6
7; C++ source to regenerate:
8; namespace foo {
9; int bar(int x) { return x * 2; }
10; }
11; template <typename T, int (*)(int)>
12; void fn_tmpl() {}
13; template void fn_tmpl<int, foo::bar>();
14; struct S { void operator<<(int i) {} };
15; void f() {
16;   fn_tmpl<int, foo::bar>();
17;   S s;
18;   s << 3;
19; }
20
21; CHECK:        {{.*}}Proc{{.*}}Sym {
22; CHECK:         FunctionType: bar ({{.*}})
23; CHECK:         DisplayName: foo::bar{{$}}
24; CHECK-NEXT:    LinkageName: ?bar@foo@@YAHH@Z
25
26; CHECK:        {{.*}}Proc{{.*}}Sym {
27; CHECK:         FunctionType: operator<< ({{.*}})
28; CHECK:         DisplayName: S::operator<<
29; CHECK-NEXT:    LinkageName: ??6S@@QAEXH@Z
30
31; CHECK:        {{.*}}Proc{{.*}}Sym {
32; CHECK:         FunctionType: fn_tmpl ({{.*}})
33; CHECK:         DisplayName: foo::fn_tmpl<int,&foo::bar>
34; CHECK-NEXT:    LinkageName: ??$fn_tmpl@H$1?bar@foo@@YAHH@Z@foo@@YAXXZ
35
36; ModuleID = 't.cpp'
37source_filename = "t.cpp"
38target datalayout = "e-m:x-p:32:32-i64:64-f80:32-n8:16:32-a:0:32-S32"
39target triple = "i386-pc-windows-msvc19.0.23918"
40
41%struct.S = type { i8 }
42
43$"\01??$fn_tmpl@H$1?bar@foo@@YAHH@Z@foo@@YAXXZ" = comdat any
44
45$"??6S@@QAEXH@Z" = comdat any
46
47; Function Attrs: nounwind
48define i32 @"\01?bar@foo@@YAHH@Z"(i32 %x) #0 !dbg !6 {
49entry:
50  %x.addr = alloca i32, align 4
51  store i32 %x, ptr %x.addr, align 4
52  call void @llvm.dbg.declare(metadata ptr %x.addr, metadata !11, metadata !12), !dbg !13
53  %0 = load i32, ptr %x.addr, align 4, !dbg !14
54  %mul = mul nsw i32 %0, 2, !dbg !15
55  ret i32 %mul, !dbg !16
56}
57
58; Function Attrs: nounwind readnone
59declare void @llvm.dbg.declare(metadata, metadata, metadata) #1
60
61; Function Attrs: nounwind
62define weak_odr void @"\01??$fn_tmpl@H$1?bar@foo@@YAHH@Z@foo@@YAXXZ"() #0 comdat !dbg !17 {
63entry:
64  ret void, !dbg !24
65}
66
67; Function Attrs: nounwind
68define linkonce_odr void @"??6S@@QAEXH@Z"(ptr nonnull dereferenceable(1) %this, i32 %i) #0 !dbg !31 {
69entry:
70  %i.addr = alloca i32, align 4
71  %this.addr = alloca ptr, align 4
72  store i32 %i, ptr %i.addr, align 4
73  store ptr %this, ptr %this.addr, align 4
74  %this1 = load ptr, ptr %this.addr, align 4
75  ret void, !dbg !32
76}
77
78attributes #0 = { nounwind "disable-tail-calls"="false" "less-precise-fpmad"="false" "frame-pointer"="all" "no-infs-fp-math"="false" "no-jump-tables"="false" "no-nans-fp-math"="false" "stack-protector-buffer-size"="8" "target-cpu"="pentium4" "target-features"="+fxsr,+mmx,+sse,+sse2,+x87" "unsafe-fp-math"="false" "use-soft-float"="false" }
79attributes #1 = { nounwind readnone }
80
81!llvm.dbg.cu = !{!0}
82!llvm.module.flags = !{!3, !4}
83!llvm.ident = !{!5}
84
85!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !1, producer: "clang version 3.9.0 ", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !2)
86!1 = !DIFile(filename: "t.cpp", directory: "D:\5Csrc\5Cllvm\5Cbuild")
87!2 = !{}
88!3 = !{i32 2, !"CodeView", i32 1}
89!4 = !{i32 2, !"Debug Info Version", i32 3}
90!5 = !{!"clang version 3.9.0 "}
91!6 = distinct !DISubprogram(name: "bar", linkageName: "\01?bar@foo@@YAHH@Z", scope: !7, file: !1, line: 2, type: !8, isLocal: false, isDefinition: true, scopeLine: 2, flags: DIFlagPrototyped, isOptimized: false, unit: !0, retainedNodes: !2)
92!7 = !DINamespace(name: "foo", scope: null)
93!8 = !DISubroutineType(types: !9)
94!9 = !{!10, !10}
95!10 = !DIBasicType(name: "int", size: 32, align: 32, encoding: DW_ATE_signed)
96!11 = !DILocalVariable(name: "x", arg: 1, scope: !6, file: !1, line: 2, type: !10)
97!12 = !DIExpression()
98!13 = !DILocation(line: 2, column: 13, scope: !6)
99!14 = !DILocation(line: 2, column: 25, scope: !6)
100!15 = !DILocation(line: 2, column: 27, scope: !6)
101!16 = !DILocation(line: 2, column: 18, scope: !6)
102!17 = distinct !DISubprogram(name: "fn_tmpl<int,&foo::bar>", linkageName: "\01??$fn_tmpl@H$1?bar@foo@@YAHH@Z@foo@@YAXXZ", scope: !7, file: !1, line: 4, type: !18, isLocal: false, isDefinition: true, scopeLine: 4, flags: DIFlagPrototyped, isOptimized: false, unit: !0, templateParams: !20, retainedNodes: !2)
103!18 = !DISubroutineType(types: !19)
104!19 = !{null}
105!20 = !{!21, !22}
106!21 = !DITemplateTypeParameter(name: "T", type: !10)
107!22 = !DITemplateValueParameter(type: !23, value: ptr @"\01?bar@foo@@YAHH@Z")
108!23 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !8, size: 32, align: 32)
109!24 = !DILocation(line: 4, column: 17, scope: !17)
110!25 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "S", file: !1, line: 7, size: 8, flags: DIFlagTypePassByValue, elements: !26, identifier: ".?AUS@@")
111!26 = !{!27}
112!27 = !DISubprogram(name: "operator<<", linkageName: "??6S@@QAEXH@Z", scope: !25, file: !1, line: 8, type: !28, scopeLine: 8, flags: DIFlagPrototyped, spFlags: 0)
113!28 = !DISubroutineType(cc: DW_CC_BORLAND_thiscall, types: !29)
114!29 = !{null, !30, !10}
115!30 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !25, size: 32, flags: DIFlagArtificial | DIFlagObjectPointer)
116!31 = distinct !DISubprogram(name: "operator<<", linkageName: "??6S@@QAEXH@Z", scope: !25, file: !1, line: 8, type: !28, scopeLine: 8, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !0, declaration: !27, retainedNodes: !2)
117!32 = !DILocation(line: 8, column: 27, scope: !31)
118