Skip to content

Commit 891e25b

Browse files
committed
Revert "[DebugInfo] Support to emit debugInfo for extern variables"
This reverts commit d77ae15. The tests committed along with this change do not pass, and should be changed to use %clang_cc1.
1 parent 79cc9e9 commit 891e25b

File tree

20 files changed

+7
-170
lines changed

20 files changed

+7
-170
lines changed

clang/include/clang/AST/ASTConsumer.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -102,11 +102,6 @@ class ASTConsumer {
102102
/// modified by the introduction of an implicit zero initializer.
103103
virtual void CompleteTentativeDefinition(VarDecl *D) {}
104104

105-
/// CompleteExternalDeclaration - Callback invoked at the end of a translation
106-
/// unit to notify the consumer that the given external declaration should be
107-
/// completed.
108-
virtual void CompleteExternalDeclaration(VarDecl *D) {}
109-
110105
/// Callback invoked when an MSInheritanceAttr has been attached to a
111106
/// CXXRecordDecl.
112107
virtual void AssignInheritanceModel(CXXRecordDecl *RD) {}

clang/include/clang/Basic/TargetInfo.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1389,9 +1389,6 @@ class TargetInfo : public virtual TransferrableTargetInfo,
13891389

13901390
virtual void setAuxTarget(const TargetInfo *Aux) {}
13911391

1392-
/// Whether target allows debuginfo types for decl only variables.
1393-
virtual bool allowDebugInfoForExternalVar() const { return false; }
1394-
13951392
protected:
13961393
/// Copy type and layout related info.
13971394
void copyAuxTarget(const TargetInfo *Aux);

clang/include/clang/Sema/Sema.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -668,9 +668,6 @@ class Sema final {
668668
/// All the tentative definitions encountered in the TU.
669669
TentativeDefinitionsType TentativeDefinitions;
670670

671-
/// All the external declarations encoutered and used in the TU.
672-
SmallVector<VarDecl *, 4> ExternalDeclarations;
673-
674671
typedef LazyVector<const DeclaratorDecl *, ExternalSemaSource,
675672
&ExternalSemaSource::ReadUnusedFileScopedDecls, 2, 2>
676673
UnusedFileScopedDeclsType;

clang/lib/Basic/Targets/BPF.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,6 @@ class LLVM_LIBRARY_VISIBILITY BPFTargetInfo : public TargetInfo {
7676
return None;
7777
}
7878

79-
bool allowDebugInfoForExternalVar() const override { return true; }
80-
8179
CallingConvCheckResult checkCallingConvention(CallingConv CC) const override {
8280
switch (CC) {
8381
default:

clang/lib/CodeGen/CGDebugInfo.cpp

Lines changed: 2 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -4485,7 +4485,7 @@ void CGDebugInfo::EmitGlobalVariable(llvm::GlobalVariable *Var,
44854485

44864486
GVE = DBuilder.createGlobalVariableExpression(
44874487
DContext, DeclName, LinkageName, Unit, LineNo, getOrCreateType(T, Unit),
4488-
Var->hasLocalLinkage(), true,
4488+
Var->hasLocalLinkage(),
44894489
Expr.empty() ? nullptr : DBuilder.createExpression(Expr),
44904490
getOrCreateStaticDataMemberDeclarationOrNull(D), TemplateParameters,
44914491
Align);
@@ -4588,29 +4588,10 @@ void CGDebugInfo::EmitGlobalVariable(const ValueDecl *VD, const APValue &Init) {
45884588

45894589
GV.reset(DBuilder.createGlobalVariableExpression(
45904590
DContext, Name, StringRef(), Unit, getLineNumber(VD->getLocation()), Ty,
4591-
true, true, InitExpr, getOrCreateStaticDataMemberDeclarationOrNull(VarD),
4591+
true, InitExpr, getOrCreateStaticDataMemberDeclarationOrNull(VarD),
45924592
TemplateParameters, Align));
45934593
}
45944594

4595-
void CGDebugInfo::EmitExternalVariable(llvm::GlobalVariable *Var,
4596-
const VarDecl *D) {
4597-
assert(DebugKind >= codegenoptions::LimitedDebugInfo);
4598-
if (D->hasAttr<NoDebugAttr>())
4599-
return;
4600-
4601-
auto Align = getDeclAlignIfRequired(D, CGM.getContext());
4602-
llvm::DIFile *Unit = getOrCreateFile(D->getLocation());
4603-
StringRef Name = D->getName();
4604-
llvm::DIType *Ty = getOrCreateType(D->getType(), Unit);
4605-
4606-
llvm::DIScope *DContext = getDeclContextDescriptor(D);
4607-
llvm::DIGlobalVariableExpression *GVE =
4608-
DBuilder.createGlobalVariableExpression(
4609-
DContext, Name, StringRef(), Unit, getLineNumber(D->getLocation()),
4610-
Ty, false, false, nullptr, nullptr, nullptr, Align);
4611-
Var->addDebugInfo(GVE);
4612-
}
4613-
46144595
llvm::DIScope *CGDebugInfo::getCurrentContextDescriptor(const Decl *D) {
46154596
if (!LexicalBlockStack.empty())
46164597
return LexicalBlockStack.back();

clang/lib/CodeGen/CGDebugInfo.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -478,9 +478,6 @@ class CGDebugInfo {
478478
/// Emit a constant global variable's debug info.
479479
void EmitGlobalVariable(const ValueDecl *VD, const APValue &Init);
480480

481-
/// Emit information about an external variable.
482-
void EmitExternalVariable(llvm::GlobalVariable *GV, const VarDecl *Decl);
483-
484481
/// Emit C++ using directive.
485482
void EmitUsingDirective(const UsingDirectiveDecl &UD);
486483

clang/lib/CodeGen/CodeGenAction.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -336,10 +336,6 @@ namespace clang {
336336
Gen->CompleteTentativeDefinition(D);
337337
}
338338

339-
void CompleteExternalDeclaration(VarDecl *D) override {
340-
Gen->CompleteExternalDeclaration(D);
341-
}
342-
343339
void AssignInheritanceModel(CXXRecordDecl *RD) override {
344340
Gen->AssignInheritanceModel(RD);
345341
}

clang/lib/CodeGen/CodeGenModule.cpp

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3730,10 +3730,6 @@ void CodeGenModule::EmitTentativeDefinition(const VarDecl *D) {
37303730
EmitGlobalVarDefinition(D);
37313731
}
37323732

3733-
void CodeGenModule::EmitExternalDeclaration(const VarDecl *D) {
3734-
EmitExternalVarDeclaration(D);
3735-
}
3736-
37373733
CharUnits CodeGenModule::GetTargetTypeStoreSize(llvm::Type *Ty) const {
37383734
return Context.toCharUnitsFromBits(
37393735
getDataLayout().getTypeStoreSizeInBits(Ty));
@@ -4117,19 +4113,6 @@ void CodeGenModule::EmitGlobalVarDefinition(const VarDecl *D,
41174113
DI->EmitGlobalVariable(GV, D);
41184114
}
41194115

4120-
void CodeGenModule::EmitExternalVarDeclaration(const VarDecl *D) {
4121-
if (CGDebugInfo *DI = getModuleDebugInfo())
4122-
if (getCodeGenOpts().getDebugInfo() >= codegenoptions::LimitedDebugInfo) {
4123-
QualType ASTTy = D->getType();
4124-
llvm::Type *Ty = getTypes().ConvertTypeForMem(D->getType());
4125-
llvm::PointerType *PTy =
4126-
llvm::PointerType::get(Ty, getContext().getTargetAddressSpace(ASTTy));
4127-
llvm::Constant *GV = GetOrCreateLLVMGlobal(D->getName(), PTy, D);
4128-
DI->EmitExternalVariable(
4129-
cast<llvm::GlobalVariable>(GV->stripPointerCasts()), D);
4130-
}
4131-
}
4132-
41334116
static bool isVarDeclStrongDefinition(const ASTContext &Context,
41344117
CodeGenModule &CGM, const VarDecl *D,
41354118
bool NoCommon) {

clang/lib/CodeGen/CodeGenModule.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1170,8 +1170,6 @@ class CodeGenModule : public CodeGenTypeCache {
11701170

11711171
void EmitTentativeDefinition(const VarDecl *D);
11721172

1173-
void EmitExternalDeclaration(const VarDecl *D);
1174-
11751173
void EmitVTable(CXXRecordDecl *Class);
11761174

11771175
void RefreshTypeCacheForClass(const CXXRecordDecl *Class);
@@ -1407,7 +1405,6 @@ class CodeGenModule : public CodeGenTypeCache {
14071405
void EmitMultiVersionFunctionDefinition(GlobalDecl GD, llvm::GlobalValue *GV);
14081406

14091407
void EmitGlobalVarDefinition(const VarDecl *D, bool IsTentative = false);
1410-
void EmitExternalVarDeclaration(const VarDecl *D);
14111408
void EmitAliasDefinition(GlobalDecl GD);
14121409
void emitIFuncDefinition(GlobalDecl GD);
14131410
void emitCPUDispatchDefinition(GlobalDecl GD);

clang/lib/CodeGen/ModuleBuilder.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -290,10 +290,6 @@ namespace {
290290
Builder->EmitTentativeDefinition(D);
291291
}
292292

293-
void CompleteExternalDeclaration(VarDecl *D) override {
294-
Builder->EmitExternalDeclaration(D);
295-
}
296-
297293
void HandleVTable(CXXRecordDecl *RD) override {
298294
if (Diags.hasErrorOccurred())
299295
return;

0 commit comments

Comments
 (0)