aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/CodeGen/CGDebugInfo.cpp
diff options
context:
space:
mode:
authorMichael Buch <michaelbuch12@gmail.com>2023-11-06 10:58:02 +0000
committerMichael Buch <michaelbuch12@gmail.com>2023-11-06 10:58:02 +0000
commit333124cfd6dfa413294e80f9be75460b9a9314f9 (patch)
treeb40b614750047ccc0b72b33e75356e1a757c2e66 /clang/lib/CodeGen/CGDebugInfo.cpp
parent5f86b49146902a37ea93470b5992206b20665128 (diff)
downloadllvm-333124cfd6dfa413294e80f9be75460b9a9314f9.zip
llvm-333124cfd6dfa413294e80f9be75460b9a9314f9.tar.gz
llvm-333124cfd6dfa413294e80f9be75460b9a9314f9.tar.bz2
Revert "[clang][DebugInfo] Emit global variable definitions for static data members with constant initializers (#70639)"
This reverts commit 4909814c08fdf4ec8bd9dad4f157d03de7c3c800. Following LLDB patch had to be reverted due to Linux test failures: ``` ef3febadf606c2fc4f1ad8d85a7ecdde16e4cbb3 ``` Since without that LLDB patch the LLDB tests would fail, revert this clang patch for now.
Diffstat (limited to 'clang/lib/CodeGen/CGDebugInfo.cpp')
-rw-r--r--clang/lib/CodeGen/CGDebugInfo.cpp58
1 files changed, 11 insertions, 47 deletions
diff --git a/clang/lib/CodeGen/CGDebugInfo.cpp b/clang/lib/CodeGen/CGDebugInfo.cpp
index 410c8f5..84a166d 100644
--- a/clang/lib/CodeGen/CGDebugInfo.cpp
+++ b/clang/lib/CodeGen/CGDebugInfo.cpp
@@ -1677,13 +1677,22 @@ CGDebugInfo::CreateRecordStaticField(const VarDecl *Var, llvm::DIType *RecordTy,
unsigned LineNumber = getLineNumber(Var->getLocation());
StringRef VName = Var->getName();
+ llvm::Constant *C = nullptr;
+ if (Var->getInit()) {
+ const APValue *Value = Var->evaluateValue();
+ if (Value) {
+ if (Value->isInt())
+ C = llvm::ConstantInt::get(CGM.getLLVMContext(), Value->getInt());
+ if (Value->isFloat())
+ C = llvm::ConstantFP::get(CGM.getLLVMContext(), Value->getFloat());
+ }
+ }
llvm::DINode::DIFlags Flags = getAccessFlag(Var->getAccess(), RD);
auto Align = getDeclAlignIfRequired(Var, CGM.getContext());
llvm::DIDerivedType *GV = DBuilder.createStaticMemberType(
- RecordTy, VName, VUnit, LineNumber, VTy, Flags, /* Val */ nullptr, Align);
+ RecordTy, VName, VUnit, LineNumber, VTy, Flags, C, Align);
StaticDataMemberCache[Var->getCanonicalDecl()].reset(GV);
- StaticDataMemberDefinitionsToEmit.push_back(Var->getCanonicalDecl());
return GV;
}
@@ -5587,39 +5596,6 @@ void CGDebugInfo::EmitGlobalVariable(const ValueDecl *VD, const APValue &Init) {
TemplateParameters, Align));
}
-void CGDebugInfo::EmitGlobalVariable(const VarDecl *VD) {
- assert(VD->hasInit());
- assert(CGM.getCodeGenOpts().hasReducedDebugInfo());
- if (VD->hasAttr<NoDebugAttr>())
- return;
-
- auto &GV = DeclCache[VD];
- if (GV)
- return;
-
- auto const *InitVal = VD->evaluateValue();
- if (!InitVal)
- return;
-
- llvm::DIFile *Unit = nullptr;
- llvm::DIScope *DContext = nullptr;
- unsigned LineNo;
- StringRef DeclName, LinkageName;
- QualType T;
- llvm::MDTuple *TemplateParameters = nullptr;
- collectVarDeclProps(VD, Unit, LineNo, T, DeclName, LinkageName,
- TemplateParameters, DContext);
-
- auto Align = getDeclAlignIfRequired(VD, CGM.getContext());
- llvm::DINodeArray Annotations = CollectBTFDeclTagAnnotations(VD);
- llvm::DIExpression *InitExpr = createConstantValueExpression(VD, *InitVal);
-
- GV.reset(DBuilder.createGlobalVariableExpression(
- TheCU, DeclName, LinkageName, Unit, LineNo, getOrCreateType(T, Unit),
- true, true, InitExpr, getOrCreateStaticDataMemberDeclarationOrNull(VD),
- TemplateParameters, Align, Annotations));
-}
-
void CGDebugInfo::EmitExternalVariable(llvm::GlobalVariable *Var,
const VarDecl *D) {
assert(CGM.getCodeGenOpts().hasReducedDebugInfo());
@@ -5890,18 +5866,6 @@ void CGDebugInfo::finalize() {
DBuilder.replaceTemporary(std::move(FwdDecl), cast<llvm::MDNode>(Repl));
}
- for (auto const *VD : StaticDataMemberDefinitionsToEmit) {
- assert(VD->isStaticDataMember());
-
- if (DeclCache.contains(VD))
- continue;
-
- if (!VD->hasInit())
- continue;
-
- EmitGlobalVariable(VD);
- }
-
// We keep our own list of retained types, because we need to look
// up the final type in the type cache.
for (auto &RT : RetainedTypes)