From cd826d6e840ed33ad88458c862da5f9fcc6e908c Mon Sep 17 00:00:00 2001 From: Reid Kleckner Date: Wed, 23 Apr 2025 21:27:33 +0000 Subject: Revert "[Clang,debuginfo] added vtt parameter in destructor DISubroutineType (#130674)" This reverts commit 27c1aa9b9cf9e0b14211758ff8f7d3aaba24ffcf. 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. --- clang/lib/CodeGen/CodeGenModule.cpp | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) (limited to 'clang/lib/CodeGen/CodeGenModule.cpp') diff --git a/clang/lib/CodeGen/CodeGenModule.cpp b/clang/lib/CodeGen/CodeGenModule.cpp index 83d8d4f..a073c5d 100644 --- a/clang/lib/CodeGen/CodeGenModule.cpp +++ b/clang/lib/CodeGen/CodeGenModule.cpp @@ -5837,15 +5837,24 @@ void CodeGenModule::EmitExternalVarDeclaration(const VarDecl *D) { } } +static GlobalDecl getBaseVariantGlobalDecl(const FunctionDecl *FD) { + if (auto const *CD = dyn_cast(FD)) + return GlobalDecl(CD, CXXCtorType::Ctor_Base); + else if (auto const *DD = dyn_cast(FD)) + return GlobalDecl(DD, CXXDtorType::Dtor_Base); + return GlobalDecl(FD); +} + void CodeGenModule::EmitExternalFunctionDeclaration(const FunctionDecl *FD) { if (CGDebugInfo *DI = getModuleDebugInfo()) if (getCodeGenOpts().hasReducedDebugInfo()) { + GlobalDecl GD = getBaseVariantGlobalDecl(FD); auto *Ty = getTypes().ConvertType(FD->getType()); - StringRef MangledName = getMangledName(FD); + StringRef MangledName = getMangledName(GD); auto *Fn = cast( - GetOrCreateLLVMFunction(MangledName, Ty, FD, /* ForVTable */ false)); + GetOrCreateLLVMFunction(MangledName, Ty, GD, /* ForVTable */ false)); if (!Fn->getSubprogram()) - DI->EmitFunctionDecl(FD, FD->getLocation(), FD->getType(), Fn); + DI->EmitFunctionDecl(GD, FD->getLocation(), FD->getType(), Fn); } } -- cgit v1.1