|
| 1 | +// For the `CInlined` struct, where all member functions are inlined, we check the following cases: |
| 2 | +// - If the definition of its destructor is visible: |
| 3 | +// * The vtable is generated with a COMDAT specifier |
| 4 | +// * Its '_vtable$' is generated |
| 5 | +// - Otherwise: |
| 6 | +// * The vtable is declared |
| 7 | +// * Its '_vtable$' is NOT generated |
| 8 | +// |
| 9 | +// For the `CNoInline` strcut, where member functions are defined as non-inline, we check the following: |
| 10 | +// - Regardless of whether the definition of its destructor is visible or not: |
| 11 | +// * The vtable is generated |
| 12 | +// * Its '_vtable$' is generated |
| 13 | +// |
| 14 | +// For the `CNoFnDef` struct, where member functions are declared only, we check the following: |
| 15 | +// - Regardless of whether the definition of its destructor is visible or not: |
| 16 | +// # when non-optimized: |
| 17 | +// * The vtable is declared |
| 18 | +// * Its '_vtable$' is NOT generated |
| 19 | +// # when optimized even if no LLVM passes: |
| 20 | +// * The vtable is declared as `available_externally` (which is potentially turned into `external` by LLVM passes) |
| 21 | +// * Its '_vtable$' is generated |
| 22 | + |
| 23 | +struct CInlined { |
| 24 | + virtual void f1() noexcept {} |
| 25 | + virtual void f2() noexcept {} |
| 26 | + virtual ~CInlined() noexcept; |
| 27 | +}; |
| 28 | +#ifndef NO_DTOR_BODY |
| 29 | +inline CInlined::~CInlined() noexcept {} |
| 30 | +#endif |
| 31 | + |
| 32 | +struct CNoInline { |
| 33 | + virtual void g1() noexcept; |
| 34 | + virtual void g2() noexcept; |
| 35 | + virtual ~CNoInline() noexcept; |
| 36 | +}; |
| 37 | + |
| 38 | +void CNoInline::g1() noexcept {} |
| 39 | +void CNoInline::g2() noexcept {} |
| 40 | +#ifndef NO_DTOR_BODY |
| 41 | +CNoInline::~CNoInline() noexcept {} |
| 42 | +#endif |
| 43 | + |
| 44 | +struct CNoFnDef { |
| 45 | + virtual void h1() noexcept; |
| 46 | + virtual void h2() noexcept; |
| 47 | + virtual ~CNoFnDef() noexcept; |
| 48 | +}; |
| 49 | + |
| 50 | +#ifndef NO_DTOR_BODY |
| 51 | +CNoFnDef::~CNoFnDef() noexcept {} |
| 52 | +#endif |
| 53 | + |
| 54 | +int main() { |
| 55 | + CInlined Inlined; |
| 56 | + CNoInline NoInline; |
| 57 | + CNoFnDef NoFnDef; |
| 58 | + |
| 59 | + return 0; |
| 60 | +} |
| 61 | + |
| 62 | +// RUN: %clang_cc1 -triple x86_64-linux -emit-llvm -debug-info-kind=limited -dwarf-version=5 -O0 -disable-llvm-passes %s -o - | FileCheck %s -check-prefixes CHECK-HAS-DTOR,CHECK-HAS-DTOR-O0 |
| 63 | +// RUN: %clang_cc1 -triple x86_64-linux -emit-llvm -debug-info-kind=limited -dwarf-version=5 -O1 -disable-llvm-passes %s -o - | FileCheck %s -check-prefixes CHECK-HAS-DTOR,CHECK-HAS-DTOR-O1 |
| 64 | +// RUN: %clang_cc1 -triple x86_64-linux -emit-llvm -debug-info-kind=limited -dwarf-version=5 -O0 -disable-llvm-passes -DNO_DTOR_BODY %s -o - | FileCheck %s -check-prefixes CHECK-NO-DTOR,CHECK-NO-DTOR-O0 |
| 65 | +// RUN: %clang_cc1 -triple x86_64-linux -emit-llvm -debug-info-kind=limited -dwarf-version=5 -O1 -disable-llvm-passes -DNO_DTOR_BODY %s -o - | FileCheck %s -check-prefixes CHECK-NO-DTOR,CHECK-NO-DTOR-O1 |
| 66 | + |
| 67 | +// CHECK-HAS-DTOR: $_ZTV8CInlined = comdat any |
| 68 | +// CHECK-HAS-DTOR-NOT: $_ZTV9CNoInline |
| 69 | +// CHECK-HAS-DTOR-NOT: $_ZTV8CNoFnDef |
| 70 | + |
| 71 | +// CHECK-HAS-DTOR-DAG: @_ZTV8CInlined = linkonce_odr {{.*}}constant {{{ \[[^]]*\] } { \[[^]]*\] \[[^]]*\] }}}, comdat, align 8, !dbg [[INLINED_VTABLE_VAR:![0-9]+]] |
| 72 | +// CHECK-HAS-DTOR-DAG: @_ZTV9CNoInline = {{.*}}constant {{{ \[[^]]*\] } { \[[^]]*\] \[[^]]*\] }}}, align 8, !dbg [[NOINLINE_VTABLE_VAR:![0-9]+]] |
| 73 | +// CHECK-HAS-DTOR-O0-DAG: @_ZTV8CNoFnDef = external {{.*}}constant {{{ \[[^]]*\] }}}, align 8{{$}} |
| 74 | +// CHECK-HAS-DTOR-O1-DAG: @_ZTV8CNoFnDef = available_externally {{.*}}constant {{{ \[[^]]*\] } { \[[^]]*\] \[[^]]*\] }}}, align 8, !dbg [[NOFNDEF_VTABLE_VAR:![0-9]+]] |
| 75 | + |
| 76 | +// CHECK-HAS-DTOR: !llvm.dbg.cu |
| 77 | + |
| 78 | +// CHECK-HAS-DTOR-DAG: [[INLINED_VTABLE:![0-9]+]] = distinct !DIGlobalVariable(name: "_vtable$", linkageName: "_ZTV8CInlined" |
| 79 | +// CHECK-HAS-DTOR-DAG: [[INLINED_VTABLE_VAR]] = !DIGlobalVariableExpression(var: [[INLINED_VTABLE]], expr: !DIExpression()) |
| 80 | +// CHECK-HAS-DTOR-DAG: [[INLINED:![0-9]+]] = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "CInlined" |
| 81 | +// CHECK-HAS-DTOR-DAG: !DIDerivedType(tag: DW_TAG_variable, name: "_vtable$", scope: [[INLINED]], file: {{.*}}, baseType: {{![0-9]+}}, flags: DIFlagPrivate | DIFlagArtificial | DIFlagStaticMember) |
| 82 | + |
| 83 | +// CHECK-HAS-DTOR-DAG: [[NOINLINE_VTABLE:![0-9]+]] = distinct !DIGlobalVariable(name: "_vtable$", linkageName: "_ZTV9CNoInline" |
| 84 | +// CHECK-HAS-DTOR-DAG: [[NOINLINE_VTABLE_VAR]] = !DIGlobalVariableExpression(var: [[NOINLINE_VTABLE]], expr: !DIExpression()) |
| 85 | +// CHECK-HAS-DTOR-DAG: [[NOINLINE:![0-9]+]] = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "CNoInline" |
| 86 | +// CHECK-HAS-DTOR-DAG: !DIDerivedType(tag: DW_TAG_variable, name: "_vtable$", scope: [[NOINLINE]], file: {{.*}}, baseType: {{![0-9]+}}, flags: DIFlagPrivate | DIFlagArtificial | DIFlagStaticMember) |
| 87 | + |
| 88 | +// CHECK-HAS-DTOR-O1-DAG: [[NOFNDEF_VTABLE:![0-9]+]] = distinct !DIGlobalVariable(name: "_vtable$", linkageName: "_ZTV8CNoFnDef" |
| 89 | +// CHECK-HAS-DTOR-O1-DAG: [[NOFNDEF_VTABLE_VAR]] = !DIGlobalVariableExpression(var: [[NOFNDEF_VTABLE]], expr: !DIExpression()) |
| 90 | + |
| 91 | +// CHECK-NO-DTOR-NOT: $_ZTV8CInlined |
| 92 | +// CHECK-NO-DTOR-NOT: $_ZTV9CNoInline |
| 93 | +// CHECK-NO-DTOR-NOT: $_ZTV8CNoFnDef |
| 94 | + |
| 95 | +// CHECK-NO-DTOR-DAG: @_ZTV8CInlined = external {{.*}}constant {{.*}}, align 8{{$}} |
| 96 | +// CHECK-NO-DTOR-DAG: @_ZTV9CNoInline = {{.*}}constant {{{ \[[^]]*\] } { \[[^]]*\] \[[^]]*\] }}}, align 8, !dbg [[NOINLINE_VTABLE_VAR:![0-9]+]] |
| 97 | +// CHECK-NO-DTOR-O0-DAG: @_ZTV8CNoFnDef = external {{.*}}constant {{{ \[[^]]*\] }}}, align 8{{$}} |
| 98 | +// CHECK-NO-DTOR-O1-DAG: @_ZTV8CNoFnDef = available_externally {{.*}}constant {{{ \[[^]]*\] } { \[[^]]*\] \[[^]]*\] }}}, align 8, !dbg [[NOFNDEF_VTABLE_VAR:![0-9]+]] |
| 99 | + |
| 100 | +// CHECK-NO-DTOR: !llvm.dbg.cu |
| 101 | + |
| 102 | +// CHECK-NO-DTOR-DAG: [[NOINLINE_VTABLE:![0-9]+]] = distinct !DIGlobalVariable(name: "_vtable$", linkageName: "_ZTV9CNoInline" |
| 103 | +// CHECK-NO-DTOR-DAG: [[NOINLINE_VTABLE_VAR]] = !DIGlobalVariableExpression(var: [[NOINLINE_VTABLE]], expr: !DIExpression()) |
| 104 | +// CHECK-NO-DTOR-DAG: [[NOINLINE:![0-9]+]] = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "CNoInline" |
| 105 | +// CHECK-NO-DTOR-DAG: !DIDerivedType(tag: DW_TAG_variable, name: "_vtable$", scope: [[NOINLINE]], file: {{.*}}, baseType: {{![0-9]+}}, flags: DIFlagPrivate | DIFlagArtificial | DIFlagStaticMember) |
| 106 | + |
| 107 | +// CHECK-NO-DTOR-O1-DAG: [[NOFNDEF_VTABLE:![0-9]+]] = distinct !DIGlobalVariable(name: "_vtable$", linkageName: "_ZTV8CNoFnDef" |
| 108 | +// CHECK-NO-DTOR-O1-DAG: [[NOFNDEF_VTABLE_VAR]] = !DIGlobalVariableExpression(var: [[NOFNDEF_VTABLE]], expr: !DIExpression()) |
0 commit comments