1; RUN: llc < %s -filetype=obj | llvm-readobj - --codeview | FileCheck %s
2; RUN: llc < %s | llvm-mc -filetype=obj --triple=x86_64-windows | llvm-readobj - --codeview | FileCheck %s
3;
4; Command to generate function-options.ll
5; $ clang++ function-options.cpp -S -emit-llvm -g -gcodeview -o function-options.ll
6;
7; #define DEFINE_FUNCTION(T) \
8;   T Func_##T(T &arg) { return arg; }
9;
10; class AClass {};
11; DEFINE_FUNCTION(AClass); // Expect: FO = None
12;
13; class BClass {
14; private:
15;   explicit BClass(); // Expect ctor: FO = Constructor
16; };
17; DEFINE_FUNCTION(BClass); // Expect: FO = CxxReturnUdt
18;
19; class C1Class {
20; public:
21;   C1Class() = default; // Note: Clang generates one defaulted ctor (FO = None) while MSVC doesn't.
22; };
23; DEFINE_FUNCTION(C1Class); // Expect: FO = None
24;
25; class C2Class { // Note: MSVC-specific dtor, i.e. __vecDelDtor won't be verified in this case.
26; public:
27;   ~C2Class() {} // Expect ~C2Class: FO = None
28; };
29; DEFINE_FUNCTION(C2Class); // Expect: FO = CxxReturnUdt
30;
31; class DClass : public BClass {}; // Note: MSVC yields one compiler-generated ctor for DClass while clang doesn't.
32; DEFINE_FUNCTION(DClass); // Expect: FO = CxxReturnUdt
33;
34; class FClass {
35;   static int x;
36;   AClass Member_AClass(AClass &);
37;   BClass Member_BClass(BClass &);
38; };
39; DEFINE_FUNCTION(FClass); // Expect FO = None
40;
41; struct AStruct {};
42; DEFINE_FUNCTION(AStruct); // Expect FO = None
43;
44; struct BStruct { BStruct(); }; // Expect ctor: FO = Constructor
45; DEFINE_FUNCTION(BStruct); // Expect FO = CxxReturnUdt
46;
47; union AUnion {};
48; DEFINE_FUNCTION(AUnion); // Expect FO = None
49;
50; union BUnion { BUnion() = default; }; // Note: Clang generates one defaulted ctor (FO = None) while MSVC does not.
51; DEFINE_FUNCTION(BUnion); // Expect FO = None
52
53
54; CHECK: Format: COFF-x86-64
55; CHECK: Arch: x86_64
56; CHECK: AddressSize: 64bit
57; CHECK: CodeViewTypes [
58; CHECK:   Section: .debug$T ({{.*}})
59; CHECK:   Magic: 0x4
60; CHECK:   Procedure ([[SP_A:.*]]) {
61; CHECK:     TypeLeafKind: LF_PROCEDURE (0x1008)
62; CHECK:     ReturnType: AClass ({{.*}})
63; CHECK:     CallingConvention: NearC (0x0)
64; CHECK:     FunctionOptions [ (0x0)
65; CHECK:     ]
66; CHECK:     NumParameters: 1
67; CHECK:     ArgListType: (AClass&) ({{.*}})
68; CHECK:   }
69; CHECK:   FuncId ({{.*}}) {
70; CHECK:     TypeLeafKind: LF_FUNC_ID (0x1601)
71; CHECK:     ParentScope: 0x0
72; CHECK:     FunctionType: AClass (AClass&) ([[SP_A]])
73; CHECK:     Name: Func_AClass
74; CHECK:   }
75; CHECK:   Procedure ([[SP_B:.*]]) {
76; CHECK:     TypeLeafKind: LF_PROCEDURE (0x1008)
77; CHECK:     ReturnType: BClass ({{.*}})
78; CHECK:     CallingConvention: NearC (0x0)
79; CHECK:     FunctionOptions [ (0x1)
80; CHECK:       CxxReturnUdt (0x1)
81; CHECK:     ]
82; CHECK:     NumParameters: 1
83; CHECK:     ArgListType: (BClass&) ({{.*}})
84; CHECK:   }
85; CHECK:   MemberFunction ([[CTOR_B:.*]]) {
86; CHECK:     TypeLeafKind: LF_MFUNCTION (0x1009)
87; CHECK:     ReturnType: void (0x3)
88; CHECK:     ClassType: BClass ({{.*}})
89; CHECK:     ThisType: BClass* {{.*}}
90; CHECK:     CallingConvention: NearC (0x0)
91; CHECK:     FunctionOptions [ (0x2)
92; CHECK:       Constructor (0x2)
93; CHECK:     ]
94; CHECK:     NumParameters: 0
95; CHECK:     ArgListType: () ({{.*}})
96; CHECK:     ThisAdjustment: 0
97; CHECK:   }
98; CHECK:   FieldList ({{.*}}) {
99; CHECK:     TypeLeafKind: LF_FIELDLIST (0x1203)
100; CHECK:     OneMethod {
101; CHECK:       TypeLeafKind: LF_ONEMETHOD (0x1511)
102; CHECK:       AccessSpecifier: Private (0x1)
103; CHECK:       Type: void BClass::() ([[CTOR_B]])
104; CHECK:       Name: BClass
105; CHECK:     }
106; CHECK:   }
107; CHECK:   FuncId ({{.*}}) {
108; CHECK:     TypeLeafKind: LF_FUNC_ID (0x1601)
109; CHECK:     ParentScope: 0x0
110; CHECK:     FunctionType: BClass (BClass&) ([[SP_B]])
111; CHECK:     Name: Func_BClass
112; CHECK:   }
113; CHECK:   Procedure ([[SP_C1:.*]]) {
114; CHECK:     TypeLeafKind: LF_PROCEDURE (0x1008)
115; CHECK:     ReturnType: C1Class ({{.*}})
116; CHECK:     CallingConvention: NearC (0x0)
117; CHECK:     FunctionOptions [ (0x0)
118; CHECK:     ]
119; CHECK:     NumParameters: 1
120; CHECK:     ArgListType: (C1Class&) ({{.*}})
121; CHECK:   }
122; CHECK:   MemberFunction ([[CTOR_C1:.*]]) {
123; CHECK:     TypeLeafKind: LF_MFUNCTION (0x1009)
124; CHECK:     ReturnType: void (0x3)
125; CHECK:     ClassType: C1Class ({{.*}})
126; CHECK:     ThisType: C1Class* {{.*}}
127; CHECK:     CallingConvention: NearC (0x0)
128; CHECK:     FunctionOptions [ (0x0)
129; CHECK:     ]
130; CHECK:     NumParameters: 0
131; CHECK:     ArgListType: () ({{.*}})
132; CHECK:     ThisAdjustment: 0
133; CHECK:   }
134; CHECK:   FieldList ({{.*}}) {
135; CHECK:     TypeLeafKind: LF_FIELDLIST (0x1203)
136; CHECK:     OneMethod {
137; CHECK:       TypeLeafKind: LF_ONEMETHOD (0x1511)
138; CHECK:       AccessSpecifier: Public (0x3)
139; CHECK:       Type: void C1Class::() ([[CTOR_C1]])
140; CHECK:       Name: C1Class
141; CHECK:     }
142; CHECK:   }
143; CHECK:   FuncId ({{.*}}) {
144; CHECK:     TypeLeafKind: LF_FUNC_ID (0x1601)
145; CHECK:     ParentScope: 0x0
146; CHECK:     FunctionType: C1Class (C1Class&) ([[SP_C1]])
147; CHECK:     Name: Func_C1Class
148; CHECK:   }
149; CHECK:   Procedure ([[SP_C2:.*]]) {
150; CHECK:     TypeLeafKind: LF_PROCEDURE (0x1008)
151; CHECK:     ReturnType: C2Class ({{.*}})
152; CHECK:     CallingConvention: NearC (0x0)
153; CHECK:     FunctionOptions [ (0x1)
154; CHECK:       CxxReturnUdt (0x1)
155; CHECK:     ]
156; CHECK:     NumParameters: 1
157; CHECK:     ArgListType: (C2Class&) ({{.*}})
158; CHECK:   }
159; CHECK:   MemberFunction ([[CTOR_C2:.*]]) {
160; CHECK:     TypeLeafKind: LF_MFUNCTION (0x1009)
161; CHECK:     ReturnType: void (0x3)
162; CHECK:     ClassType: C2Class ({{.*}})
163; CHECK:     ThisType: C2Class* {{.*}}
164; CHECK:     CallingConvention: NearC (0x0)
165; CHECK:     FunctionOptions [ (0x0)
166; CHECK:     ]
167; CHECK:     NumParameters: 0
168; CHECK:     ArgListType: () ({{.*}})
169; CHECK:     ThisAdjustment: 0
170; CHECK:   }
171; CHECK:   FieldList ({{.*}}) {
172; CHECK:     TypeLeafKind: LF_FIELDLIST (0x1203)
173; CHECK:     OneMethod {
174; CHECK:       TypeLeafKind: LF_ONEMETHOD (0x1511)
175; CHECK:       AccessSpecifier: Public (0x3)
176; CHECK:       Type: void C2Class::() ([[CTOR_C2]])
177; CHECK:       Name: ~C2Class
178; CHECK:     }
179; CHECK:   }
180; CHECK:   FuncId ({{.*}}) {
181; CHECK:     TypeLeafKind: LF_FUNC_ID (0x1601)
182; CHECK:     ParentScope: 0x0
183; CHECK:     FunctionType: C2Class (C2Class&) ([[SP_C2]])
184; CHECK:     Name: Func_C2Class
185; CHECK:   }
186; CHECK:   Procedure ([[SP_D:.*]]) {
187; CHECK:     TypeLeafKind: LF_PROCEDURE (0x1008)
188; CHECK:     ReturnType: DClass ({{.*}})
189; CHECK:     CallingConvention: NearC (0x0)
190; CHECK:     FunctionOptions [ (0x1)
191; CHECK:       CxxReturnUdt (0x1)
192; CHECK:     ]
193; CHECK:     NumParameters: 1
194; CHECK:     ArgListType: (DClass&) ({{.*}})
195; CHECK:   }
196; CHECK:   FieldList ({{.*}}) {
197; CHECK:     TypeLeafKind: LF_FIELDLIST (0x1203)
198; CHECK:     BaseClass {
199; CHECK:       TypeLeafKind: LF_BCLASS (0x1400)
200; CHECK:       AccessSpecifier: Public (0x3)
201; CHECK:       BaseType: BClass ({{.*}})
202; CHECK:       BaseOffset: 0x0
203; CHECK:     }
204; CHECK:   }
205; CHECK:   FuncId ({{.*}}) {
206; CHECK:     TypeLeafKind: LF_FUNC_ID (0x1601)
207; CHECK:     ParentScope: 0x0
208; CHECK:     FunctionType: DClass (DClass&) ([[SP_D]])
209; CHECK:     Name: Func_DClass
210; CHECK:   }
211; CHECK:   Procedure ([[SP_F:.*]]) {
212; CHECK:     TypeLeafKind: LF_PROCEDURE (0x1008)
213; CHECK:     ReturnType: FClass ({{.*}})
214; CHECK:     CallingConvention: NearC (0x0)
215; CHECK:     FunctionOptions [ (0x0)
216; CHECK:     ]
217; CHECK:     NumParameters: 1
218; CHECK:     ArgListType: (FClass&) ({{.*}})
219; CHECK:   }
220; CHECK:   MemberFunction ([[MF_A:.*]]) {
221; CHECK:     TypeLeafKind: LF_MFUNCTION (0x1009)
222; CHECK:     ReturnType: AClass ({{.*}})
223; CHECK:     ClassType: FClass ({{.*}})
224; CHECK:     ThisType: FClass* {{.*}}
225; CHECK:     CallingConvention: NearC (0x0)
226; CHECK:     FunctionOptions [ (0x1)
227; CHECK:       CxxReturnUdt (0x1)
228; CHECK:     ]
229; CHECK:     NumParameters: 1
230; CHECK:     ArgListType: (AClass&) ({{.*}})
231; CHECK:     ThisAdjustment: 0
232; CHECK:   }
233; CHECK:   MemberFunction ([[MF_B:.*]]) {
234; CHECK:     TypeLeafKind: LF_MFUNCTION (0x1009)
235; CHECK:     ReturnType: BClass ({{.*}})
236; CHECK:     ClassType: FClass ({{.*}})
237; CHECK:     ThisType: FClass* {{.*}}
238; CHECK:     CallingConvention: NearC (0x0)
239; CHECK:     FunctionOptions [ (0x1)
240; CHECK:       CxxReturnUdt (0x1)
241; CHECK:     ]
242; CHECK:     NumParameters: 1
243; CHECK:     ArgListType: (BClass&) ({{.*}})
244; CHECK:     ThisAdjustment: 0
245; CHECK:   }
246; CHECK:   FieldList ({{.*}}) {
247; CHECK:     TypeLeafKind: LF_FIELDLIST (0x1203)
248; CHECK:     StaticDataMember {
249; CHECK:       TypeLeafKind: LF_STMEMBER (0x150E)
250; CHECK:       AccessSpecifier: Private (0x1)
251; CHECK:       Type: int (0x74)
252; CHECK:       Name: x
253; CHECK:     }
254; CHECK:     OneMethod {
255; CHECK:       TypeLeafKind: LF_ONEMETHOD (0x1511)
256; CHECK:       AccessSpecifier: Private (0x1)
257; CHECK:       Type: AClass FClass::(AClass&) ([[MF_A]])
258; CHECK:       Name: Member_AClass
259; CHECK:     }
260; CHECK:     OneMethod {
261; CHECK:       TypeLeafKind: LF_ONEMETHOD (0x1511)
262; CHECK:       AccessSpecifier: Private (0x1)
263; CHECK:       Type: BClass FClass::(BClass&) ([[MF_B]])
264; CHECK:       Name: Member_BClass
265; CHECK:     }
266; CHECK:   }
267; CHECK:   FuncId ({{.*}}) {
268; CHECK:     TypeLeafKind: LF_FUNC_ID (0x1601)
269; CHECK:     ParentScope: 0x0
270; CHECK:     FunctionType: FClass (FClass&) ([[SP_F]])
271; CHECK:     Name: Func_FClass
272; CHECK:   }
273; CHECK:   Procedure ([[SP_AS:.*]]) {
274; CHECK:     TypeLeafKind: LF_PROCEDURE (0x1008)
275; CHECK:     ReturnType: AStruct ({{.*}})
276; CHECK:     CallingConvention: NearC (0x0)
277; CHECK:     FunctionOptions [ (0x0)
278; CHECK:     ]
279; CHECK:     NumParameters: 1
280; CHECK:     ArgListType: (AStruct&) ({{.*}})
281; CHECK:   }
282; CHECK:   FuncId ({{.*}}) {
283; CHECK:     TypeLeafKind: LF_FUNC_ID (0x1601)
284; CHECK:     ParentScope: 0x0
285; CHECK:     FunctionType: AStruct (AStruct&) ([[SP_AS]])
286; CHECK:     Name: Func_AStruct
287; CHECK:   }
288; CHECK:   Procedure ([[SP_BS:.*]]) {
289; CHECK:     TypeLeafKind: LF_PROCEDURE (0x1008)
290; CHECK:     ReturnType: BStruct ({{.*}})
291; CHECK:     CallingConvention: NearC (0x0)
292; CHECK:     FunctionOptions [ (0x1)
293; CHECK:       CxxReturnUdt (0x1)
294; CHECK:     ]
295; CHECK:     NumParameters: 1
296; CHECK:     ArgListType: (BStruct&) ({{.*}})
297; CHECK:   }
298; CHECK:   MemberFunction ([[CTOR_BS:.*]]) {
299; CHECK:     TypeLeafKind: LF_MFUNCTION (0x1009)
300; CHECK:     ReturnType: void (0x3)
301; CHECK:     ClassType: BStruct ({{.*}})
302; CHECK:     ThisType: BStruct* {{.*}}
303; CHECK:     CallingConvention: NearC (0x0)
304; CHECK:     FunctionOptions [ (0x2)
305; CHECK:       Constructor (0x2)
306; CHECK:     ]
307; CHECK:     NumParameters: 0
308; CHECK:     ArgListType: () ({{.*}})
309; CHECK:     ThisAdjustment: 0
310; CHECK:   }
311; CHECK:   FieldList ({{.*}}) {
312; CHECK:     TypeLeafKind: LF_FIELDLIST (0x1203)
313; CHECK:     OneMethod {
314; CHECK:       TypeLeafKind: LF_ONEMETHOD (0x1511)
315; CHECK:       AccessSpecifier: Public (0x3)
316; CHECK:       Type: void BStruct::() ([[CTOR_BS]])
317; CHECK:       Name: BStruct
318; CHECK:     }
319; CHECK:   }
320; CHECK:   FuncId ({{.*}}) {
321; CHECK:     TypeLeafKind: LF_FUNC_ID (0x1601)
322; CHECK:     ParentScope: 0x0
323; CHECK:     FunctionType: BStruct (BStruct&) ([[SP_BS]])
324; CHECK:     Name: Func_BStruct
325; CHECK:   }
326; CHECK:   Procedure ([[SP_AU:.*]]) {
327; CHECK:     TypeLeafKind: LF_PROCEDURE (0x1008)
328; CHECK:     ReturnType: AUnion ({{.*}})
329; CHECK:     CallingConvention: NearC (0x0)
330; CHECK:     FunctionOptions [ (0x0)
331; CHECK:     ]
332; CHECK:     NumParameters: 1
333; CHECK:     ArgListType: (AUnion&) ({{.*}})
334; CHECK:   }
335; CHECK:   FuncId ({{.*}}) {
336; CHECK:     TypeLeafKind: LF_FUNC_ID (0x1601)
337; CHECK:     ParentScope: 0x0
338; CHECK:     FunctionType: AUnion (AUnion&) ([[SP_AU]])
339; CHECK:     Name: Func_AUnion
340; CHECK:   }
341; CHECK:   Procedure ([[SP_BU:.*]]) {
342; CHECK:     TypeLeafKind: LF_PROCEDURE (0x1008)
343; CHECK:     ReturnType: BUnion ({{.*}})
344; CHECK:     CallingConvention: NearC (0x0)
345; CHECK:     FunctionOptions [ (0x0)
346; CHECK:     ]
347; CHECK:     NumParameters: 1
348; CHECK:     ArgListType: (BUnion&) ({{.*}})
349; CHECK:   }
350; CHECK:   MemberFunction ([[CTOR_BU:.*]]) {
351; CHECK:     TypeLeafKind: LF_MFUNCTION (0x1009)
352; CHECK:     ReturnType: void (0x3)
353; CHECK:     ClassType: BUnion ({{.*}})
354; CHECK:     ThisType: BUnion* {{.*}}
355; CHECK:     CallingConvention: NearC (0x0)
356; CHECK:     FunctionOptions [ (0x0)
357; CHECK:     ]
358; CHECK:     NumParameters: 0
359; CHECK:     ArgListType: () ({{.*}})
360; CHECK:     ThisAdjustment: 0
361; CHECK:   }
362; CHECK:   FieldList ({{.*}}) {
363; CHECK:     TypeLeafKind: LF_FIELDLIST (0x1203)
364; CHECK:     OneMethod {
365; CHECK:       TypeLeafKind: LF_ONEMETHOD (0x1511)
366; CHECK:       AccessSpecifier: Public (0x3)
367; CHECK:       Type: void BUnion::() ([[CTOR_BU]])
368; CHECK:       Name: BUnion
369; CHECK:     }
370; CHECK:   }
371; CHECK:   FuncId ({{.*}}) {
372; CHECK:     TypeLeafKind: LF_FUNC_ID (0x1601)
373; CHECK:     ParentScope: 0x0
374; CHECK:     FunctionType: BUnion (BUnion&) ([[SP_BU]])
375; CHECK:     Name: Func_BUnion
376; CHECK:   }
377; CHECK: ]
378
379; ModuleID = 't.cpp'
380source_filename = "t.cpp"
381target datalayout = "e-m:w-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
382target triple = "x86_64-pc-windows-msvc19.23.28106"
383
384%class.AClass = type { i8 }
385%class.BClass = type { i8 }
386%class.C1Class = type { i8 }
387%class.C2Class = type { i8 }
388%class.DClass = type { i8 }
389%class.FClass = type { i8 }
390%struct.AStruct = type { i8 }
391%struct.BStruct = type { i8 }
392%union.AUnion = type { i8 }
393%union.BUnion = type { i8 }
394
395; Function Attrs: noinline nounwind optnone uwtable
396define dso_local i8 @"?Func_AClass@@YA?AVAClass@@AEAV1@@Z"(%class.AClass* dereferenceable(1) %arg) #0 !dbg !8 {
397entry:
398  %retval = alloca %class.AClass, align 1
399  %arg.addr = alloca %class.AClass*, align 8
400  store %class.AClass* %arg, %class.AClass** %arg.addr, align 8
401  call void @llvm.dbg.declare(metadata %class.AClass** %arg.addr, metadata !13, metadata !DIExpression()), !dbg !14
402  %0 = load %class.AClass*, %class.AClass** %arg.addr, align 8, !dbg !14
403  %coerce.dive = getelementptr inbounds %class.AClass, %class.AClass* %retval, i32 0, i32 0, !dbg !14
404  %1 = load i8, i8* %coerce.dive, align 1, !dbg !14
405  ret i8 %1, !dbg !14
406}
407
408; Function Attrs: nounwind readnone speculatable willreturn
409declare void @llvm.dbg.declare(metadata, metadata, metadata) #1
410
411; Function Attrs: noinline nounwind optnone uwtable
412define dso_local void @"?Func_BClass@@YA?AVBClass@@AEAV1@@Z"(%class.BClass* noalias sret(%class.BClass) %agg.result, %class.BClass* dereferenceable(1) %arg) #0 !dbg !15 {
413entry:
414  %result.ptr = alloca i8*, align 8
415  %arg.addr = alloca %class.BClass*, align 8
416  %0 = bitcast %class.BClass* %agg.result to i8*
417  store i8* %0, i8** %result.ptr, align 8
418  store %class.BClass* %arg, %class.BClass** %arg.addr, align 8
419  call void @llvm.dbg.declare(metadata %class.BClass** %arg.addr, metadata !25, metadata !DIExpression()), !dbg !26
420  %1 = load %class.BClass*, %class.BClass** %arg.addr, align 8, !dbg !26
421  ret void, !dbg !26
422}
423
424; Function Attrs: noinline nounwind optnone uwtable
425define dso_local void @"?Func_C1Class@@YA?AVC1Class@@AEAV1@@Z"(%class.C1Class* noalias sret(%class.C1Class) %agg.result, %class.C1Class* dereferenceable(1) %arg) #0 !dbg !27 {
426entry:
427  %result.ptr = alloca i8*, align 8
428  %arg.addr = alloca %class.C1Class*, align 8
429  %0 = bitcast %class.C1Class* %agg.result to i8*
430  store i8* %0, i8** %result.ptr, align 8
431  store %class.C1Class* %arg, %class.C1Class** %arg.addr, align 8
432  call void @llvm.dbg.declare(metadata %class.C1Class** %arg.addr, metadata !37, metadata !DIExpression()), !dbg !38
433  %1 = load %class.C1Class*, %class.C1Class** %arg.addr, align 8, !dbg !38
434  ret void, !dbg !38
435}
436
437; Function Attrs: noinline nounwind optnone uwtable
438define dso_local void @"?Func_C2Class@@YA?AVC2Class@@AEAV1@@Z"(%class.C2Class* noalias sret(%class.C2Class) %agg.result, %class.C2Class* dereferenceable(1) %arg) #0 !dbg !39 {
439entry:
440  %result.ptr = alloca i8*, align 8
441  %arg.addr = alloca %class.C2Class*, align 8
442  %0 = bitcast %class.C2Class* %agg.result to i8*
443  store i8* %0, i8** %result.ptr, align 8
444  store %class.C2Class* %arg, %class.C2Class** %arg.addr, align 8
445  call void @llvm.dbg.declare(metadata %class.C2Class** %arg.addr, metadata !49, metadata !DIExpression()), !dbg !50
446  %1 = load %class.C2Class*, %class.C2Class** %arg.addr, align 8, !dbg !50
447  ret void, !dbg !50
448}
449
450; Function Attrs: noinline nounwind optnone uwtable
451define dso_local void @"?Func_DClass@@YA?AVDClass@@AEAV1@@Z"(%class.DClass* noalias sret(%class.DClass) %agg.result, %class.DClass* dereferenceable(1) %arg) #0 !dbg !51 {
452entry:
453  %result.ptr = alloca i8*, align 8
454  %arg.addr = alloca %class.DClass*, align 8
455  %0 = bitcast %class.DClass* %agg.result to i8*
456  store i8* %0, i8** %result.ptr, align 8
457  store %class.DClass* %arg, %class.DClass** %arg.addr, align 8
458  call void @llvm.dbg.declare(metadata %class.DClass** %arg.addr, metadata !58, metadata !DIExpression()), !dbg !59
459  %1 = load %class.DClass*, %class.DClass** %arg.addr, align 8, !dbg !59
460  ret void, !dbg !59
461}
462
463; Function Attrs: noinline nounwind optnone uwtable
464define dso_local i8 @"?Func_FClass@@YA?AVFClass@@AEAV1@@Z"(%class.FClass* dereferenceable(1) %arg) #0 !dbg !60 {
465entry:
466  %retval = alloca %class.FClass, align 1
467  %arg.addr = alloca %class.FClass*, align 8
468  store %class.FClass* %arg, %class.FClass** %arg.addr, align 8
469  call void @llvm.dbg.declare(metadata %class.FClass** %arg.addr, metadata !75, metadata !DIExpression()), !dbg !76
470  %0 = load %class.FClass*, %class.FClass** %arg.addr, align 8, !dbg !76
471  %coerce.dive = getelementptr inbounds %class.FClass, %class.FClass* %retval, i32 0, i32 0, !dbg !76
472  %1 = load i8, i8* %coerce.dive, align 1, !dbg !76
473  ret i8 %1, !dbg !76
474}
475
476; Function Attrs: noinline nounwind optnone uwtable
477define dso_local i8 @"?Func_AStruct@@YA?AUAStruct@@AEAU1@@Z"(%struct.AStruct* dereferenceable(1) %arg) #0 !dbg !77 {
478entry:
479  %retval = alloca %struct.AStruct, align 1
480  %arg.addr = alloca %struct.AStruct*, align 8
481  store %struct.AStruct* %arg, %struct.AStruct** %arg.addr, align 8
482  call void @llvm.dbg.declare(metadata %struct.AStruct** %arg.addr, metadata !82, metadata !DIExpression()), !dbg !83
483  %0 = load %struct.AStruct*, %struct.AStruct** %arg.addr, align 8, !dbg !83
484  %coerce.dive = getelementptr inbounds %struct.AStruct, %struct.AStruct* %retval, i32 0, i32 0, !dbg !83
485  %1 = load i8, i8* %coerce.dive, align 1, !dbg !83
486  ret i8 %1, !dbg !83
487}
488
489; Function Attrs: noinline nounwind optnone uwtable
490define dso_local void @"?Func_BStruct@@YA?AUBStruct@@AEAU1@@Z"(%struct.BStruct* noalias sret(%struct.BStruct) %agg.result, %struct.BStruct* dereferenceable(1) %arg) #0 !dbg !84 {
491entry:
492  %result.ptr = alloca i8*, align 8
493  %arg.addr = alloca %struct.BStruct*, align 8
494  %0 = bitcast %struct.BStruct* %agg.result to i8*
495  store i8* %0, i8** %result.ptr, align 8
496  store %struct.BStruct* %arg, %struct.BStruct** %arg.addr, align 8
497  call void @llvm.dbg.declare(metadata %struct.BStruct** %arg.addr, metadata !94, metadata !DIExpression()), !dbg !95
498  %1 = load %struct.BStruct*, %struct.BStruct** %arg.addr, align 8, !dbg !95
499  ret void, !dbg !95
500}
501
502; Function Attrs: noinline nounwind optnone uwtable
503define dso_local i8 @"?Func_AUnion@@YA?ATAUnion@@AEAT1@@Z"(%union.AUnion* dereferenceable(1) %arg) #0 !dbg !96 {
504entry:
505  %retval = alloca %union.AUnion, align 1
506  %arg.addr = alloca %union.AUnion*, align 8
507  store %union.AUnion* %arg, %union.AUnion** %arg.addr, align 8
508  call void @llvm.dbg.declare(metadata %union.AUnion** %arg.addr, metadata !101, metadata !DIExpression()), !dbg !102
509  %0 = load %union.AUnion*, %union.AUnion** %arg.addr, align 8, !dbg !102
510  %coerce.dive = getelementptr inbounds %union.AUnion, %union.AUnion* %retval, i32 0, i32 0, !dbg !102
511  %1 = load i8, i8* %coerce.dive, align 1, !dbg !102
512  ret i8 %1, !dbg !102
513}
514
515; Function Attrs: noinline nounwind optnone uwtable
516define dso_local void @"?Func_BUnion@@YA?ATBUnion@@AEAT1@@Z"(%union.BUnion* noalias sret(%union.BUnion) %agg.result, %union.BUnion* dereferenceable(1) %arg) #0 !dbg !103 {
517entry:
518  %result.ptr = alloca i8*, align 8
519  %arg.addr = alloca %union.BUnion*, align 8
520  %0 = bitcast %union.BUnion* %agg.result to i8*
521  store i8* %0, i8** %result.ptr, align 8
522  store %union.BUnion* %arg, %union.BUnion** %arg.addr, align 8
523  call void @llvm.dbg.declare(metadata %union.BUnion** %arg.addr, metadata !113, metadata !DIExpression()), !dbg !114
524  %1 = load %union.BUnion*, %union.BUnion** %arg.addr, align 8, !dbg !114
525  ret void, !dbg !114
526}
527
528; Function Attrs: noinline norecurse nounwind optnone uwtable
529define dso_local i32 @main() #2 !dbg !115 {
530entry:
531  %retval = alloca i32, align 4
532  store i32 0, i32* %retval, align 4
533  ret i32 0, !dbg !118
534}
535
536attributes #0 = { noinline nounwind optnone uwtable "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "frame-pointer"="none" "less-precise-fpmad"="false" "min-legal-vector-width"="0" "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"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "unsafe-fp-math"="false" "use-soft-float"="false" }
537attributes #1 = { nounwind readnone speculatable willreturn }
538attributes #2 = { noinline norecurse nounwind optnone uwtable "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "frame-pointer"="none" "less-precise-fpmad"="false" "min-legal-vector-width"="0" "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"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "unsafe-fp-math"="false" "use-soft-float"="false" }
539
540!llvm.dbg.cu = !{!0}
541!llvm.module.flags = !{!3, !4, !5, !6}
542!llvm.ident = !{!7}
543
544!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus_14, file: !1, producer: "clang version 11.0.0 (https://github.com/llvm/llvm-project.git 48992717b0e3466cf8814a188e9568c9d71b59c2)", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, nameTableKind: None)
545!1 = !DIFile(filename: "t.cpp", directory: "C:\\src\\tests\\duplicate-types\\llvm-test", checksumkind: CSK_MD5, checksum: "c4c61c0e2135d713d0c99a1ba9ab568b")
546!2 = !{}
547!3 = !{i32 2, !"CodeView", i32 1}
548!4 = !{i32 2, !"Debug Info Version", i32 3}
549!5 = !{i32 1, !"wchar_size", i32 2}
550!6 = !{i32 7, !"PIC Level", i32 2}
551!7 = !{!"clang version 11.0.0 (https://github.com/llvm/llvm-project.git 48992717b0e3466cf8814a188e9568c9d71b59c2)"}
552!8 = distinct !DISubprogram(name: "Func_AClass", linkageName: "?Func_AClass@@YA?AVAClass@@AEAV1@@Z", scope: !1, file: !1, line: 5, type: !9, scopeLine: 5, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !0, retainedNodes: !2)
553!9 = !DISubroutineType(types: !10)
554!10 = !{!11, !12}
555!11 = distinct !DICompositeType(tag: DW_TAG_class_type, name: "AClass", file: !1, line: 4, size: 8, flags: DIFlagTypePassByValue, elements: !2, identifier: ".?AVAClass@@")
556!12 = !DIDerivedType(tag: DW_TAG_reference_type, baseType: !11, size: 64)
557!13 = !DILocalVariable(name: "arg", arg: 1, scope: !8, file: !1, line: 5, type: !12)
558!14 = !DILocation(line: 5, scope: !8)
559!15 = distinct !DISubprogram(name: "Func_BClass", linkageName: "?Func_BClass@@YA?AVBClass@@AEAV1@@Z", scope: !1, file: !1, line: 11, type: !16, scopeLine: 11, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !0, retainedNodes: !2)
560!16 = !DISubroutineType(types: !17)
561!17 = !{!18, !24}
562!18 = distinct !DICompositeType(tag: DW_TAG_class_type, name: "BClass", file: !1, line: 7, size: 8, flags: DIFlagTypePassByValue | DIFlagNonTrivial, elements: !19, identifier: ".?AVBClass@@")
563!19 = !{!20}
564!20 = !DISubprogram(name: "BClass", scope: !18, file: !1, line: 9, type: !21, scopeLine: 9, flags: DIFlagExplicit | DIFlagPrototyped, spFlags: 0)
565!21 = !DISubroutineType(types: !22)
566!22 = !{null, !23}
567!23 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !18, size: 64, flags: DIFlagArtificial | DIFlagObjectPointer)
568!24 = !DIDerivedType(tag: DW_TAG_reference_type, baseType: !18, size: 64)
569!25 = !DILocalVariable(name: "arg", arg: 1, scope: !15, file: !1, line: 11, type: !24)
570!26 = !DILocation(line: 11, scope: !15)
571!27 = distinct !DISubprogram(name: "Func_C1Class", linkageName: "?Func_C1Class@@YA?AVC1Class@@AEAV1@@Z", scope: !1, file: !1, line: 17, type: !28, scopeLine: 17, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !0, retainedNodes: !2)
572!28 = !DISubroutineType(types: !29)
573!29 = !{!30, !36}
574!30 = distinct !DICompositeType(tag: DW_TAG_class_type, name: "C1Class", file: !1, line: 13, size: 8, flags: DIFlagTypePassByValue, elements: !31, identifier: ".?AVC1Class@@")
575!31 = !{!32}
576!32 = !DISubprogram(name: "C1Class", scope: !30, file: !1, line: 15, type: !33, scopeLine: 15, flags: DIFlagPublic | DIFlagPrototyped, spFlags: 0)
577!33 = !DISubroutineType(types: !34)
578!34 = !{null, !35}
579!35 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !30, size: 64, flags: DIFlagArtificial | DIFlagObjectPointer)
580!36 = !DIDerivedType(tag: DW_TAG_reference_type, baseType: !30, size: 64)
581!37 = !DILocalVariable(name: "arg", arg: 1, scope: !27, file: !1, line: 17, type: !36)
582!38 = !DILocation(line: 17, scope: !27)
583!39 = distinct !DISubprogram(name: "Func_C2Class", linkageName: "?Func_C2Class@@YA?AVC2Class@@AEAV1@@Z", scope: !1, file: !1, line: 23, type: !40, scopeLine: 23, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !0, retainedNodes: !2)
584!40 = !DISubroutineType(types: !41)
585!41 = !{!42, !48}
586!42 = distinct !DICompositeType(tag: DW_TAG_class_type, name: "C2Class", file: !1, line: 19, size: 8, flags: DIFlagTypePassByValue | DIFlagNonTrivial, elements: !43, identifier: ".?AVC2Class@@")
587!43 = !{!44}
588!44 = !DISubprogram(name: "~C2Class", scope: !42, file: !1, line: 21, type: !45, scopeLine: 21, flags: DIFlagPublic | DIFlagPrototyped, spFlags: 0)
589!45 = !DISubroutineType(types: !46)
590!46 = !{null, !47}
591!47 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !42, size: 64, flags: DIFlagArtificial | DIFlagObjectPointer)
592!48 = !DIDerivedType(tag: DW_TAG_reference_type, baseType: !42, size: 64)
593!49 = !DILocalVariable(name: "arg", arg: 1, scope: !39, file: !1, line: 23, type: !48)
594!50 = !DILocation(line: 23, scope: !39)
595!51 = distinct !DISubprogram(name: "Func_DClass", linkageName: "?Func_DClass@@YA?AVDClass@@AEAV1@@Z", scope: !1, file: !1, line: 26, type: !52, scopeLine: 26, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !0, retainedNodes: !2)
596!52 = !DISubroutineType(types: !53)
597!53 = !{!54, !57}
598!54 = distinct !DICompositeType(tag: DW_TAG_class_type, name: "DClass", file: !1, line: 25, size: 8, flags: DIFlagTypePassByValue | DIFlagNonTrivial, elements: !55, identifier: ".?AVDClass@@")
599!55 = !{!56}
600!56 = !DIDerivedType(tag: DW_TAG_inheritance, scope: !54, baseType: !18, flags: DIFlagPublic, extraData: i32 0)
601!57 = !DIDerivedType(tag: DW_TAG_reference_type, baseType: !54, size: 64)
602!58 = !DILocalVariable(name: "arg", arg: 1, scope: !51, file: !1, line: 26, type: !57)
603!59 = !DILocation(line: 26, scope: !51)
604!60 = distinct !DISubprogram(name: "Func_FClass", linkageName: "?Func_FClass@@YA?AVFClass@@AEAV1@@Z", scope: !1, file: !1, line: 33, type: !61, scopeLine: 33, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !0, retainedNodes: !2)
605!61 = !DISubroutineType(types: !62)
606!62 = !{!63, !74}
607!63 = distinct !DICompositeType(tag: DW_TAG_class_type, name: "FClass", file: !1, line: 28, size: 8, flags: DIFlagTypePassByValue, elements: !64, identifier: ".?AVFClass@@")
608!64 = !{!65, !67, !71}
609!65 = !DIDerivedType(tag: DW_TAG_member, name: "x", scope: !63, file: !1, line: 29, baseType: !66, flags: DIFlagStaticMember)
610!66 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
611!67 = !DISubprogram(name: "Member_AClass", linkageName: "?Member_AClass@FClass@@AEAA?AVAClass@@AEAV2@@Z", scope: !63, file: !1, line: 30, type: !68, scopeLine: 30, flags: DIFlagPrototyped, spFlags: 0)
612!68 = !DISubroutineType(types: !69)
613!69 = !{!11, !70, !12}
614!70 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !63, size: 64, flags: DIFlagArtificial | DIFlagObjectPointer)
615!71 = !DISubprogram(name: "Member_BClass", linkageName: "?Member_BClass@FClass@@AEAA?AVBClass@@AEAV2@@Z", scope: !63, file: !1, line: 31, type: !72, scopeLine: 31, flags: DIFlagPrototyped, spFlags: 0)
616!72 = !DISubroutineType(types: !73)
617!73 = !{!18, !70, !24}
618!74 = !DIDerivedType(tag: DW_TAG_reference_type, baseType: !63, size: 64)
619!75 = !DILocalVariable(name: "arg", arg: 1, scope: !60, file: !1, line: 33, type: !74)
620!76 = !DILocation(line: 33, scope: !60)
621!77 = distinct !DISubprogram(name: "Func_AStruct", linkageName: "?Func_AStruct@@YA?AUAStruct@@AEAU1@@Z", scope: !1, file: !1, line: 36, type: !78, scopeLine: 36, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !0, retainedNodes: !2)
622!78 = !DISubroutineType(types: !79)
623!79 = !{!80, !81}
624!80 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "AStruct", file: !1, line: 35, size: 8, flags: DIFlagTypePassByValue, elements: !2, identifier: ".?AUAStruct@@")
625!81 = !DIDerivedType(tag: DW_TAG_reference_type, baseType: !80, size: 64)
626!82 = !DILocalVariable(name: "arg", arg: 1, scope: !77, file: !1, line: 36, type: !81)
627!83 = !DILocation(line: 36, scope: !77)
628!84 = distinct !DISubprogram(name: "Func_BStruct", linkageName: "?Func_BStruct@@YA?AUBStruct@@AEAU1@@Z", scope: !1, file: !1, line: 39, type: !85, scopeLine: 39, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !0, retainedNodes: !2)
629!85 = !DISubroutineType(types: !86)
630!86 = !{!87, !93}
631!87 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "BStruct", file: !1, line: 38, size: 8, flags: DIFlagTypePassByValue | DIFlagNonTrivial, elements: !88, identifier: ".?AUBStruct@@")
632!88 = !{!89}
633!89 = !DISubprogram(name: "BStruct", scope: !87, file: !1, line: 38, type: !90, scopeLine: 38, flags: DIFlagPrototyped, spFlags: 0)
634!90 = !DISubroutineType(types: !91)
635!91 = !{null, !92}
636!92 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !87, size: 64, flags: DIFlagArtificial | DIFlagObjectPointer)
637!93 = !DIDerivedType(tag: DW_TAG_reference_type, baseType: !87, size: 64)
638!94 = !DILocalVariable(name: "arg", arg: 1, scope: !84, file: !1, line: 39, type: !93)
639!95 = !DILocation(line: 39, scope: !84)
640!96 = distinct !DISubprogram(name: "Func_AUnion", linkageName: "?Func_AUnion@@YA?ATAUnion@@AEAT1@@Z", scope: !1, file: !1, line: 42, type: !97, scopeLine: 42, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !0, retainedNodes: !2)
641!97 = !DISubroutineType(types: !98)
642!98 = !{!99, !100}
643!99 = distinct !DICompositeType(tag: DW_TAG_union_type, name: "AUnion", file: !1, line: 41, size: 8, flags: DIFlagTypePassByValue, elements: !2, identifier: ".?ATAUnion@@")
644!100 = !DIDerivedType(tag: DW_TAG_reference_type, baseType: !99, size: 64)
645!101 = !DILocalVariable(name: "arg", arg: 1, scope: !96, file: !1, line: 42, type: !100)
646!102 = !DILocation(line: 42, scope: !96)
647!103 = distinct !DISubprogram(name: "Func_BUnion", linkageName: "?Func_BUnion@@YA?ATBUnion@@AEAT1@@Z", scope: !1, file: !1, line: 45, type: !104, scopeLine: 45, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !0, retainedNodes: !2)
648!104 = !DISubroutineType(types: !105)
649!105 = !{!106, !112}
650!106 = distinct !DICompositeType(tag: DW_TAG_union_type, name: "BUnion", file: !1, line: 44, size: 8, flags: DIFlagTypePassByValue, elements: !107, identifier: ".?ATBUnion@@")
651!107 = !{!108}
652!108 = !DISubprogram(name: "BUnion", scope: !106, file: !1, line: 44, type: !109, scopeLine: 44, flags: DIFlagPrototyped, spFlags: 0)
653!109 = !DISubroutineType(types: !110)
654!110 = !{null, !111}
655!111 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !106, size: 64, flags: DIFlagArtificial | DIFlagObjectPointer)
656!112 = !DIDerivedType(tag: DW_TAG_reference_type, baseType: !106, size: 64)
657!113 = !DILocalVariable(name: "arg", arg: 1, scope: !103, file: !1, line: 45, type: !112)
658!114 = !DILocation(line: 45, scope: !103)
659!115 = distinct !DISubprogram(name: "main", scope: !1, file: !1, line: 47, type: !116, scopeLine: 47, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !0, retainedNodes: !2)
660!116 = !DISubroutineType(types: !117)
661!117 = !{!66}
662!118 = !DILocation(line: 48, scope: !115)
663