Skip to content

Commit 4cc5f4e

Browse files
committed
[clang][DebugInfo] Disable VTable debug info (#130255) on COFF platforms
On COFF platform, d1b0cbf generates a debug info linked with VTable even if that is dllimport-ed. That causes an access violation while performing runtime pseudo-relocation if the debug section is stripped. For the release branch, we simply disable VTable debug info on COFF platform to avoid this problem. Fixes #149639
1 parent ece4440 commit 4cc5f4e

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

clang/lib/CodeGen/CGDebugInfo.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2645,7 +2645,8 @@ StringRef CGDebugInfo::getVTableName(const CXXRecordDecl *RD) {
26452645
// existing information in the DWARF. The type is assumed to be 'void *'.
26462646
void CGDebugInfo::emitVTableSymbol(llvm::GlobalVariable *VTable,
26472647
const CXXRecordDecl *RD) {
2648-
if (!CGM.getTarget().getCXXABI().isItaniumFamily())
2648+
if (!CGM.getTarget().getCXXABI().isItaniumFamily() ||
2649+
CGM.getTarget().getTriple().isOSBinFormatCOFF())
26492650
return;
26502651

26512652
ASTContext &Context = CGM.getContext();

clang/test/CodeGenCXX/vtable-debug-info-inheritance-simple.cpp

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
// REQUIRES: target={{x86_64.*-linux.*}}
2-
31
// Simple inheritance case:
42
// For CBase and CDerived we check:
53
// - Generation of their vtables (including attributes).
@@ -30,13 +28,20 @@ int main() {
3028
return 0;
3129
}
3230

33-
// RUN: %clang --target=x86_64-linux -Xclang -disable-O0-optnone -Xclang -disable-llvm-passes -emit-llvm -S -g %s -o - | FileCheck %s
31+
// RUN: %clang_cc1 -triple x86_64-linux -emit-llvm -mrelocation-model pic -pic-is-pie -debug-info-kind=limited -dwarf-version=5 -disable-O0-optnone -disable-llvm-passes %s -o - | FileCheck %s
32+
// RUN: %clang_cc1 -triple x86_64-windows-gnu -emit-llvm -mrelocation-model pic -pic-is-pie -debug-info-kind=limited -dwarf-version=5 -disable-O0-optnone -disable-llvm-passes %s -o - | FileCheck %s --check-prefix=COFF
3433

3534
// CHECK: $_ZTVN3NSP5CBaseE = comdat any
3635
// CHECK: $_ZTV8CDerived = comdat any
3736

3837
// CHECK: @_ZTVN3NSP5CBaseE = linkonce_odr {{dso_local|hidden}} unnamed_addr constant {{.*}}, comdat, align 8, !dbg [[BASE_VTABLE_VAR:![0-9]*]]
3938
// CHECK: @_ZTV8CDerived = linkonce_odr {{dso_local|hidden}} unnamed_addr constant {{.*}}, comdat, align 8, !dbg [[DERIVED_VTABLE_VAR:![0-9]*]]
39+
// COFF: @_ZTVN3NSP5CBaseE = linkonce_odr {{dso_local|hidden}} unnamed_addr constant {{.*}}, comdat, align 8
40+
// COFF-NOT: !dbg
41+
// COFF-SAME: {{$}}
42+
// COFF: @_ZTV8CDerived = linkonce_odr {{dso_local|hidden}} unnamed_addr constant {{.*}}, comdat, align 8
43+
// COFF-NOT: !dbg
44+
// COFF-SAME: {{$}}
4045

4146
// CHECK: [[BASE_VTABLE_VAR]] = !DIGlobalVariableExpression(var: [[BASE_VTABLE:![0-9]*]], expr: !DIExpression())
4247
// CHECK-NEXT: [[BASE_VTABLE]] = distinct !DIGlobalVariable(name: "_vtable$", linkageName: "_ZTVN3NSP5CBaseE"

0 commit comments

Comments
 (0)