Skip to content

Commit cd826d6

Browse files
committed
Revert "[Clang,debuginfo] added vtt parameter in destructor DISubroutineType (llvm#130674)"
This reverts commit 27c1aa9. See comments on PR. After this change, Clang now asserts like this: clang: ../llvm/include/llvm/IR/Metadata.h:1435: const MDOperand &llvm::MDNode::getOperand(unsigned int) const: Assertion `I < getNumOperands() && "Out of range"' failed. ... #8 0x000055f345c4e4cb clang::CodeGen::CGDebugInfo::getOrCreateInstanceMethodType() #9 0x000055f345c5ba4f clang::CodeGen::CGDebugInfo::EmitFunctionDecl() #10 0x000055f345b52519 clang::CodeGen::CodeGenModule::EmitExternalFunctionDeclaration() This is due to pre-existing jankiness in the way BPF emits extra declarations for debug info, but we should rollback and then fix forward.
1 parent ee617f1 commit cd826d6

File tree

4 files changed

+16
-51
lines changed

4 files changed

+16
-51
lines changed

clang/lib/CodeGen/CGDebugInfo.cpp

+3-18
Original file line numberDiff line numberDiff line change
@@ -2018,17 +2018,8 @@ CGDebugInfo::getOrCreateMethodType(const CXXMethodDecl *Method,
20182018
return getOrCreateInstanceMethodType(ThisType, Func, Unit);
20192019
}
20202020

2021-
llvm::DISubroutineType *CGDebugInfo::getOrCreateMethodTypeForDestructor(
2022-
const CXXMethodDecl *Method, llvm::DIFile *Unit, QualType FNType) {
2023-
const FunctionProtoType *Func = FNType->getAs<FunctionProtoType>();
2024-
// skip the first param since it is also this
2025-
return getOrCreateInstanceMethodType(Method->getThisType(), Func, Unit, true);
2026-
}
2027-
2028-
llvm::DISubroutineType *
2029-
CGDebugInfo::getOrCreateInstanceMethodType(QualType ThisPtr,
2030-
const FunctionProtoType *Func,
2031-
llvm::DIFile *Unit, bool SkipFirst) {
2021+
llvm::DISubroutineType *CGDebugInfo::getOrCreateInstanceMethodType(
2022+
QualType ThisPtr, const FunctionProtoType *Func, llvm::DIFile *Unit) {
20322023
FunctionProtoType::ExtProtoInfo EPI = Func->getExtProtoInfo();
20332024
Qualifiers &Qc = EPI.TypeQuals;
20342025
Qc.removeConst();
@@ -2068,7 +2059,7 @@ CGDebugInfo::getOrCreateInstanceMethodType(QualType ThisPtr,
20682059
}
20692060

20702061
// Copy rest of the arguments.
2071-
for (unsigned i = (SkipFirst ? 2 : 1), e = Args.size(); i != e; ++i)
2062+
for (unsigned i = 1, e = Args.size(); i != e; ++i)
20722063
Elts.push_back(Args[i]);
20732064

20742065
// Attach FlagObjectPointer to the explicit "this" parameter.
@@ -4381,12 +4372,6 @@ llvm::DISubroutineType *CGDebugInfo::getOrCreateFunctionType(const Decl *D,
43814372
// subprogram DIE will miss DW_AT_decl_file and DW_AT_decl_line fields.
43824373
return DBuilder.createSubroutineType(DBuilder.getOrCreateTypeArray({}));
43834374

4384-
if (const auto *Method = dyn_cast<CXXDestructorDecl>(D)) {
4385-
// Read method type from 'FnType' because 'D.getType()' does not cover
4386-
// implicit arguments for destructors.
4387-
return getOrCreateMethodTypeForDestructor(Method, F, FnType);
4388-
}
4389-
43904375
if (const auto *Method = dyn_cast<CXXMethodDecl>(D))
43914376
return getOrCreateMethodType(Method, F);
43924377

clang/lib/CodeGen/CGDebugInfo.h

+1-6
Original file line numberDiff line numberDiff line change
@@ -249,14 +249,9 @@ class CGDebugInfo {
249249
/// to get a method type which includes \c this pointer.
250250
llvm::DISubroutineType *getOrCreateMethodType(const CXXMethodDecl *Method,
251251
llvm::DIFile *F);
252-
253-
llvm::DISubroutineType *
254-
getOrCreateMethodTypeForDestructor(const CXXMethodDecl *Method,
255-
llvm::DIFile *F, QualType FNType);
256-
257252
llvm::DISubroutineType *
258253
getOrCreateInstanceMethodType(QualType ThisPtr, const FunctionProtoType *Func,
259-
llvm::DIFile *Unit, bool SkipFirst = false);
254+
llvm::DIFile *Unit);
260255
llvm::DISubroutineType *
261256
getOrCreateFunctionType(const Decl *D, QualType FnType, llvm::DIFile *F);
262257
/// \return debug info descriptor for vtable.

clang/lib/CodeGen/CodeGenModule.cpp

+12-3
Original file line numberDiff line numberDiff line change
@@ -5837,15 +5837,24 @@ void CodeGenModule::EmitExternalVarDeclaration(const VarDecl *D) {
58375837
}
58385838
}
58395839

5840+
static GlobalDecl getBaseVariantGlobalDecl(const FunctionDecl *FD) {
5841+
if (auto const *CD = dyn_cast<const CXXConstructorDecl>(FD))
5842+
return GlobalDecl(CD, CXXCtorType::Ctor_Base);
5843+
else if (auto const *DD = dyn_cast<const CXXDestructorDecl>(FD))
5844+
return GlobalDecl(DD, CXXDtorType::Dtor_Base);
5845+
return GlobalDecl(FD);
5846+
}
5847+
58405848
void CodeGenModule::EmitExternalFunctionDeclaration(const FunctionDecl *FD) {
58415849
if (CGDebugInfo *DI = getModuleDebugInfo())
58425850
if (getCodeGenOpts().hasReducedDebugInfo()) {
5851+
GlobalDecl GD = getBaseVariantGlobalDecl(FD);
58435852
auto *Ty = getTypes().ConvertType(FD->getType());
5844-
StringRef MangledName = getMangledName(FD);
5853+
StringRef MangledName = getMangledName(GD);
58455854
auto *Fn = cast<llvm::Function>(
5846-
GetOrCreateLLVMFunction(MangledName, Ty, FD, /* ForVTable */ false));
5855+
GetOrCreateLLVMFunction(MangledName, Ty, GD, /* ForVTable */ false));
58475856
if (!Fn->getSubprogram())
5848-
DI->EmitFunctionDecl(FD, FD->getLocation(), FD->getType(), Fn);
5857+
DI->EmitFunctionDecl(GD, FD->getLocation(), FD->getType(), Fn);
58495858
}
58505859
}
58515860

clang/test/CodeGenCXX/debug-info-dtor-implicit-args.cpp

-24
This file was deleted.

0 commit comments

Comments
 (0)