Revert "Recommitted r263425 "Supporting all entities declared in lexical scope in LLVM debug info." After fixing PR26942 (the fix is included in this commit)."

This reverts commit r264281.

This change breaks building Chromium for iOS. We'll upload a reproducer
to the PR soon.

llvm-svn: 264333
This commit is contained in:
Reid Kleckner 2016-03-24 20:38:43 +00:00
parent fab31220fe
commit 00381aa142
5 changed files with 20 additions and 92 deletions

View File

@ -831,18 +831,15 @@ llvm::DIType *CGDebugInfo::CreateType(const TemplateSpecializationType *Ty,
llvm::DIType *CGDebugInfo::CreateType(const TypedefType *Ty, llvm::DIType *CGDebugInfo::CreateType(const TypedefType *Ty,
llvm::DIFile *Unit) { llvm::DIFile *Unit) {
TypedefNameDecl *TD = Ty->getDecl();
// We don't set size information, but do specify where the typedef was // We don't set size information, but do specify where the typedef was
// declared. // declared.
SourceLocation Loc = TD->getLocation(); SourceLocation Loc = Ty->getDecl()->getLocation();
llvm::DIScope *TDContext = getDeclarationLexicalScope(*TD, QualType(Ty, 0));
// Typedefs are derived from some other type. // Typedefs are derived from some other type.
return DBuilder.createTypedef( return DBuilder.createTypedef(
getOrCreateType(Ty->getDecl()->getUnderlyingType(), Unit), getOrCreateType(Ty->getDecl()->getUnderlyingType(), Unit),
Ty->getDecl()->getName(), getOrCreateFile(Loc), getLineNumber(Loc), Ty->getDecl()->getName(), getOrCreateFile(Loc), getLineNumber(Loc),
TDContext); getDeclContextDescriptor(Ty->getDecl()));
} }
llvm::DIType *CGDebugInfo::CreateType(const FunctionType *Ty, llvm::DIType *CGDebugInfo::CreateType(const FunctionType *Ty,
@ -1475,23 +1472,6 @@ llvm::DIType *CGDebugInfo::getOrCreateStandaloneType(QualType D,
return T; return T;
} }
void CGDebugInfo::recordDeclarationLexicalScope(const Decl &D) {
assert(LexicalBlockMap.find(&D) == LexicalBlockMap.end() &&
"D is already mapped to lexical block scope");
if (!LexicalBlockStack.empty())
LexicalBlockMap[&D] = LexicalBlockStack.back();
}
llvm::DIScope *CGDebugInfo::getDeclarationLexicalScope(const Decl &D,
QualType Ty) {
auto I = LexicalBlockMap.find(&D);
if (I != LexicalBlockMap.end()) {
RetainedTypes.push_back(Ty.getAsOpaquePtr());
return I->second;
}
return getDeclContextDescriptor(cast<Decl>(&D));
}
void CGDebugInfo::completeType(const EnumDecl *ED) { void CGDebugInfo::completeType(const EnumDecl *ED) {
if (DebugKind <= codegenoptions::DebugLineTablesOnly) if (DebugKind <= codegenoptions::DebugLineTablesOnly)
return; return;
@ -2077,7 +2057,7 @@ llvm::DIType *CGDebugInfo::CreateEnumType(const EnumType *Ty) {
// entered into the ReplaceMap: finalize() will replace the first // entered into the ReplaceMap: finalize() will replace the first
// FwdDecl with the second and then replace the second with // FwdDecl with the second and then replace the second with
// complete type. // complete type.
llvm::DIScope *EDContext = getDeclarationLexicalScope(*ED, QualType(Ty, 0)); llvm::DIScope *EDContext = getDeclContextDescriptor(ED);
llvm::DIFile *DefUnit = getOrCreateFile(ED->getLocation()); llvm::DIFile *DefUnit = getOrCreateFile(ED->getLocation());
llvm::TempDIScope TmpContext(DBuilder.createReplaceableCompositeType( llvm::TempDIScope TmpContext(DBuilder.createReplaceableCompositeType(
llvm::dwarf::DW_TAG_enumeration_type, "", TheCU, DefUnit, 0)); llvm::dwarf::DW_TAG_enumeration_type, "", TheCU, DefUnit, 0));
@ -2121,7 +2101,7 @@ llvm::DIType *CGDebugInfo::CreateTypeDefinition(const EnumType *Ty) {
llvm::DIFile *DefUnit = getOrCreateFile(ED->getLocation()); llvm::DIFile *DefUnit = getOrCreateFile(ED->getLocation());
unsigned Line = getLineNumber(ED->getLocation()); unsigned Line = getLineNumber(ED->getLocation());
llvm::DIScope *EnumContext = getDeclarationLexicalScope(*ED, QualType(Ty, 0)); llvm::DIScope *EnumContext = getDeclContextDescriptor(ED);
llvm::DIType *ClassTy = llvm::DIType *ClassTy =
ED->isFixed() ? getOrCreateType(ED->getIntegerType(), DefUnit) : nullptr; ED->isFixed() ? getOrCreateType(ED->getIntegerType(), DefUnit) : nullptr;
return DBuilder.createEnumerationType(EnumContext, ED->getName(), DefUnit, return DBuilder.createEnumerationType(EnumContext, ED->getName(), DefUnit,
@ -2382,7 +2362,7 @@ llvm::DICompositeType *CGDebugInfo::CreateLimitedType(const RecordType *Ty) {
unsigned Line = getLineNumber(RD->getLocation()); unsigned Line = getLineNumber(RD->getLocation());
StringRef RDName = getClassName(RD); StringRef RDName = getClassName(RD);
llvm::DIScope *RDContext = getDeclarationLexicalScope(*RD, QualType(Ty, 0)); llvm::DIScope *RDContext = getDeclContextDescriptor(RD);
// If we ended up creating the type during the context chain construction, // If we ended up creating the type during the context chain construction,
// just return that. // just return that.
@ -2529,15 +2509,8 @@ void CGDebugInfo::collectVarDeclProps(const VarDecl *VD, llvm::DIFile *&Unit,
if (DC->isRecord()) if (DC->isRecord())
DC = CGM.getContext().getTranslationUnitDecl(); DC = CGM.getContext().getTranslationUnitDecl();
if (VD->isStaticLocal()) { llvm::DIScope *Mod = getParentModuleOrNull(VD);
// Get context for static locals (that are technically globals) the same way VDContext = getContextDescriptor(cast<Decl>(DC), Mod ? Mod : TheCU);
// we do for "local" locals -- by using current lexical block.
assert(!LexicalBlockStack.empty() && "Region stack mismatch, stack empty!");
VDContext = LexicalBlockStack.back();
} else {
llvm::DIScope *Mod = getParentModuleOrNull(VD);
VDContext = getContextDescriptor(cast<Decl>(DC), Mod ? Mod : TheCU);
}
} }
llvm::DISubprogram * llvm::DISubprogram *

View File

@ -116,11 +116,6 @@ class CGDebugInfo {
/// Keep track of our current nested lexical block. /// Keep track of our current nested lexical block.
std::vector<llvm::TypedTrackingMDRef<llvm::DIScope>> LexicalBlockStack; std::vector<llvm::TypedTrackingMDRef<llvm::DIScope>> LexicalBlockStack;
/// Map of AST declaration to its lexical block scope.
llvm::DenseMap<const Decl *, llvm::TypedTrackingMDRef<llvm::DIScope>>
LexicalBlockMap;
llvm::DenseMap<const Decl *, llvm::TrackingMDRef> RegionMap; llvm::DenseMap<const Decl *, llvm::TrackingMDRef> RegionMap;
/// Keep track of LexicalBlockStack counter at the beginning of a /// Keep track of LexicalBlockStack counter at the beginning of a
/// function. This is used to pop unbalanced regions at the end of a /// function. This is used to pop unbalanced regions at the end of a
@ -383,12 +378,6 @@ public:
/// Emit an Objective-C interface type standalone debug info. /// Emit an Objective-C interface type standalone debug info.
llvm::DIType *getOrCreateInterfaceType(QualType Ty, SourceLocation Loc); llvm::DIType *getOrCreateInterfaceType(QualType Ty, SourceLocation Loc);
/// Map AST declaration to its lexical block scope if available.
void recordDeclarationLexicalScope(const Decl &D);
/// Get lexical scope of AST declaration.
llvm::DIScope *getDeclarationLexicalScope(const Decl &D, QualType Ty);
/// Emit standalone debug info for a type. /// Emit standalone debug info for a type.
llvm::DIType *getOrCreateStandaloneType(QualType Ty, SourceLocation Loc); llvm::DIType *getOrCreateStandaloneType(QualType Ty, SourceLocation Loc);

View File

@ -87,7 +87,11 @@ void CodeGenFunction::EmitDecl(const Decl &D) {
case Decl::UsingShadow: case Decl::UsingShadow:
case Decl::ObjCTypeParam: case Decl::ObjCTypeParam:
llvm_unreachable("Declaration should not be in declstmts!"); llvm_unreachable("Declaration should not be in declstmts!");
case Decl::Function: // void X(); case Decl::Function: // void X();
case Decl::Record: // struct/union/class X;
case Decl::Enum: // enum X;
case Decl::EnumConstant: // enum ? { X = ? }
case Decl::CXXRecord: // struct/union/class X; [C++]
case Decl::StaticAssert: // static_assert(X, ""); [C++0x] case Decl::StaticAssert: // static_assert(X, ""); [C++0x]
case Decl::Label: // __label__ x; case Decl::Label: // __label__ x;
case Decl::Import: case Decl::Import:
@ -97,21 +101,13 @@ void CodeGenFunction::EmitDecl(const Decl &D) {
// None of these decls require codegen support. // None of these decls require codegen support.
return; return;
case Decl::Record: // struct/union/class X;
case Decl::Enum: // enum X;
case Decl::EnumConstant: // enum ? { X = ? }
case Decl::CXXRecord: // struct/union/class X; [C++]
if (CGDebugInfo *DI = getDebugInfo())
DI->recordDeclarationLexicalScope(D);
return;
case Decl::NamespaceAlias: case Decl::NamespaceAlias:
if (CGDebugInfo *DI = getDebugInfo()) if (CGDebugInfo *DI = getDebugInfo())
DI->EmitNamespaceAlias(cast<NamespaceAliasDecl>(D)); DI->EmitNamespaceAlias(cast<NamespaceAliasDecl>(D));
return; return;
case Decl::Using: // using X; [C++] case Decl::Using: // using X; [C++]
if (CGDebugInfo *DI = getDebugInfo()) if (CGDebugInfo *DI = getDebugInfo())
DI->EmitUsingDecl(cast<UsingDecl>(D)); DI->EmitUsingDecl(cast<UsingDecl>(D));
return; return;
case Decl::UsingDirective: // using namespace X; [C++] case Decl::UsingDirective: // using namespace X; [C++]
if (CGDebugInfo *DI = getDebugInfo()) if (CGDebugInfo *DI = getDebugInfo())
@ -132,9 +128,6 @@ void CodeGenFunction::EmitDecl(const Decl &D) {
const TypedefNameDecl &TD = cast<TypedefNameDecl>(D); const TypedefNameDecl &TD = cast<TypedefNameDecl>(D);
QualType Ty = TD.getUnderlyingType(); QualType Ty = TD.getUnderlyingType();
if (CGDebugInfo *DI = getDebugInfo())
DI->recordDeclarationLexicalScope(D);
if (Ty->isVariablyModifiedType()) if (Ty->isVariablyModifiedType())
EmitVariablyModifiedType(Ty); EmitVariablyModifiedType(Ty);
} }

View File

@ -44,12 +44,7 @@ void instantiate(int x) {
buildBytes(x); buildBytes(x);
} }
// CHECK: ![[UNION:[0-9]+]] = !DICompositeType(tag: DW_TAG_union_type,
// CHECK-NOT: name:
// CHECK: elements
// CHECK: [[FILE:.*]] = !DIFile(filename: "{{.*}}debug-info-anon-union-vars.cpp", // CHECK: [[FILE:.*]] = !DIFile(filename: "{{.*}}debug-info-anon-union-vars.cpp",
// CHECK: !DIDerivedType(tag: DW_TAG_member, name: "i", scope: ![[UNION]],
// CHECK: !DIDerivedType(tag: DW_TAG_member, name: "c", scope: ![[UNION]],
// CHECK: !DIGlobalVariable(name: "c",{{.*}} file: [[FILE]], line: 6,{{.*}} isLocal: true, isDefinition: true // CHECK: !DIGlobalVariable(name: "c",{{.*}} file: [[FILE]], line: 6,{{.*}} isLocal: true, isDefinition: true
// CHECK: !DIGlobalVariable(name: "d",{{.*}} file: [[FILE]], line: 6,{{.*}} isLocal: true, isDefinition: true // CHECK: !DIGlobalVariable(name: "d",{{.*}} file: [[FILE]], line: 6,{{.*}} isLocal: true, isDefinition: true
// CHECK: !DIGlobalVariable(name: "a",{{.*}} file: [[FILE]], line: 6,{{.*}} isLocal: true, isDefinition: true // CHECK: !DIGlobalVariable(name: "a",{{.*}} file: [[FILE]], line: 6,{{.*}} isLocal: true, isDefinition: true
@ -60,4 +55,9 @@ void instantiate(int x) {
// CHECK: !DILocalVariable(name: "c", {{.*}}, flags: DIFlagArtificial // CHECK: !DILocalVariable(name: "c", {{.*}}, flags: DIFlagArtificial
// CHECK: !DILocalVariable( // CHECK: !DILocalVariable(
// CHECK-NOT: name: // CHECK-NOT: name:
// CHECK: type: ![[UNION]] // CHECK: type: ![[UNION:[0-9]+]]
// CHECK: ![[UNION]] = !DICompositeType(tag: DW_TAG_union_type,
// CHECK-NOT: name:
// CHECK: elements
// CHECK: !DIDerivedType(tag: DW_TAG_member, name: "i", scope: ![[UNION]],
// CHECK: !DIDerivedType(tag: DW_TAG_member, name: "c", scope: ![[UNION]],

View File

@ -1,27 +0,0 @@
// RUN: %clang_cc1 -triple x86_64-none-linux-gnu -emit-llvm -debug-info-kind=limited %s -o - | FileCheck %s
void foo() {
static int bar = 1;
{
struct X {};
typedef char Y;
static int bar = 0;
// The following basic block is intended, in order to check the case where
// types "X", "Y" are defined in a different scope than where they are used.
// They should have the scope they are defined at as their parent scope.
{
X a;
Y b;
}
}
}
// CHECK: !{{[0-9]+}} = !DICompositeType(tag: DW_TAG_structure_type, name: "X", scope: [[LBScope:![0-9]+]],
// CHECK: [[LBScope]] = distinct !DILexicalBlock(scope: !{{[0-9]+}}, file: !{{[0-9]+}}, line: 5)
// CHECK: [[FuncScope:![0-9]+]] = distinct !DISubprogram(name: "foo",
// CHECK: !{{[0-9]+}} = !DIDerivedType(tag: DW_TAG_typedef, name: "Y", scope: [[LBScope]],
// CHECK: !{{[0-9]+}} = !DIGlobalVariable(name: "bar", scope: [[FuncScope]], file: !{{[0-9]+}}, line: 4
// CHECK: !{{[0-9]+}} = !DIGlobalVariable(name: "bar", scope: [[LBScope]], file: !{{[0-9]+}}, line: 8