summaryrefslogtreecommitdiffstats
path: root/llvm/lib/IR/Verifier.cpp
diff options
context:
space:
mode:
authorAdrian Prantl <aprantl@apple.com>2016-04-15 15:57:41 +0000
committerAdrian Prantl <aprantl@apple.com>2016-04-15 15:57:41 +0000
commit75819aedf6d774a424e35793b266442708e57050 (patch)
treee4eabf3bd19e9dee6ed3aefc8f4e2cb16d6bb285 /llvm/lib/IR/Verifier.cpp
parente76bda544bbf52d9ff3b55e6018b494a1e6bbc00 (diff)
downloadbcm5719-llvm-75819aedf6d774a424e35793b266442708e57050.tar.gz
bcm5719-llvm-75819aedf6d774a424e35793b266442708e57050.zip
[PR27284] Reverse the ownership between DICompileUnit and DISubprogram.
Currently each Function points to a DISubprogram and DISubprogram has a scope field. For member functions the scope is a DICompositeType. DIScopes point to the DICompileUnit to facilitate type uniquing. Distinct DISubprograms (with isDefinition: true) are not part of the type hierarchy and cannot be uniqued. This change removes the subprograms list from DICompileUnit and instead adds a pointer to the owning compile unit to distinct DISubprograms. This would make it easy for ThinLTO to strip unneeded DISubprograms and their transitively referenced debug info. Motivation ---------- Materializing DISubprograms is currently the most expensive operation when doing a ThinLTO build of clang. We want the DISubprogram to be stored in a separate Bitcode block (or the same block as the function body) so we can avoid having to expensively deserialize all DISubprograms together with the global metadata. If a function has been inlined into another subprogram we need to store a reference the block containing the inlined subprogram. Attached to https://llvm.org/bugs/show_bug.cgi?id=27284 is a python script that updates LLVM IR testcases to the new format. http://reviews.llvm.org/D19034 <rdar://problem/25256815> llvm-svn: 266446
Diffstat (limited to 'llvm/lib/IR/Verifier.cpp')
-rw-r--r--llvm/lib/IR/Verifier.cpp28
1 files changed, 17 insertions, 11 deletions
diff --git a/llvm/lib/IR/Verifier.cpp b/llvm/lib/IR/Verifier.cpp
index 8f055886efe..e480e4e9c69 100644
--- a/llvm/lib/IR/Verifier.cpp
+++ b/llvm/lib/IR/Verifier.cpp
@@ -951,13 +951,10 @@ void Verifier::visitDICompileUnit(const DICompileUnit &N) {
if (auto *Array = N.getRawRetainedTypes()) {
Assert(isa<MDTuple>(Array), "invalid retained type list", &N, Array);
for (Metadata *Op : N.getRetainedTypes()->operands()) {
- Assert(Op && isa<DIType>(Op), "invalid retained type", &N, Op);
- }
- }
- if (auto *Array = N.getRawSubprograms()) {
- Assert(isa<MDTuple>(Array), "invalid subprogram list", &N, Array);
- for (Metadata *Op : N.getSubprograms()->operands()) {
- Assert(Op && isa<DISubprogram>(Op), "invalid subprogram ref", &N, Op);
+ Assert(Op && (isa<DIType>(Op) ||
+ (isa<DISubprogram>(Op) &&
+ cast<DISubprogram>(Op)->isDefinition() == false)),
+ "invalid retained type", &N, Op);
}
}
if (auto *Array = N.getRawGlobalVariables()) {
@@ -994,10 +991,9 @@ void Verifier::visitDISubprogram(const DISubprogram &N) {
N.getRawContainingType());
if (auto *Params = N.getRawTemplateParams())
visitTemplateParams(N, *Params);
- if (auto *S = N.getRawDeclaration()) {
+ if (auto *S = N.getRawDeclaration())
Assert(isa<DISubprogram>(S) && !cast<DISubprogram>(S)->isDefinition(),
"invalid subprogram declaration", &N, S);
- }
if (auto *RawVars = N.getRawVariables()) {
auto *Vars = dyn_cast<MDTuple>(RawVars);
Assert(Vars, "invalid variable list", &N, RawVars);
@@ -1009,8 +1005,16 @@ void Verifier::visitDISubprogram(const DISubprogram &N) {
Assert(!hasConflictingReferenceFlags(N.getFlags()), "invalid reference flags",
&N);
- if (N.isDefinition())
+ auto *Unit = N.getRawUnit();
+ if (N.isDefinition()) {
+ // Subprogram definitions (not part of the type hierarchy).
Assert(N.isDistinct(), "subprogram definitions must be distinct", &N);
+ Assert(Unit, "subprogram definitions must have a compile unit", &N);
+ Assert(isa<DICompileUnit>(Unit), "invalid unit type", &N, Unit);
+ } else {
+ // Subprogram declarations (part of the type hierarchy).
+ Assert(!Unit, "subprogram declarations must not have a compile unit", &N);
+ }
}
void Verifier::visitDILexicalBlockBase(const DILexicalBlockBase &N) {
@@ -2023,6 +2027,8 @@ void Verifier::visitFunction(const Function &F) {
if (!N)
return;
+ visitDISubprogram(*N);
+
// Check that all !dbg attachments lead to back to N (or, at least, another
// subprogram that describes the same function).
//
@@ -4419,7 +4425,7 @@ void Verifier::verifyTypeRefs() {
auto *Array = CU->getRawRetainedTypes();
if (!Array || !isa<MDTuple>(Array))
continue;
- for (DIType *Op : CU->getRetainedTypes())
+ for (DIScope *Op : CU->getRetainedTypes())
if (auto *T = dyn_cast_or_null<DICompositeType>(Op))
if (auto *S = T->getRawIdentifier()) {
UnresolvedTypeRefs.erase(S);
OpenPOWER on IntegriCloud