diff options
Diffstat (limited to 'llvm/lib/IR/Verifier.cpp')
-rw-r--r-- | llvm/lib/IR/Verifier.cpp | 26 |
1 files changed, 5 insertions, 21 deletions
diff --git a/llvm/lib/IR/Verifier.cpp b/llvm/lib/IR/Verifier.cpp index 2b9dfcea2fb..b0ba1c7a592 100644 --- a/llvm/lib/IR/Verifier.cpp +++ b/llvm/lib/IR/Verifier.cpp @@ -580,6 +580,7 @@ void Verifier::visitGlobalVariable(const GlobalVariable &GV) { "Global variable initializer type does not match global " "variable type!", &GV); + // If the global has common linkage, it must have a zero initializer and // cannot be constant. if (GV.hasCommonLinkage()) { @@ -645,16 +646,6 @@ void Verifier::visitGlobalVariable(const GlobalVariable &GV) { GV.hasAvailableExternallyLinkage(), "Global is marked as dllimport, but not external", &GV); - // Visit any debug info attachments. - SmallVector<MDNode *, 1> MDs; - GV.getMetadata(LLVMContext::MD_dbg, MDs); - for (auto *MD : MDs) { - if (auto *GVE = dyn_cast<DIGlobalVariableExpression>(MD)) - visitDIGlobalVariableExpression(*GVE); - else - AssertDI(false, "!dbg attachment of global variable must be a DIGlobalVariableExpression"); - } - if (!GV.hasInitializer()) { visitGlobalValue(GV); return; @@ -997,8 +988,8 @@ void Verifier::visitDICompileUnit(const DICompileUnit &N) { if (auto *Array = N.getRawGlobalVariables()) { AssertDI(isa<MDTuple>(Array), "invalid global variable list", &N, Array); for (Metadata *Op : N.getGlobalVariables()->operands()) { - AssertDI(Op && (isa<DIGlobalVariableExpression>(Op)), - "invalid global variable ref", &N, Op); + AssertDI(Op && isa<DIGlobalVariable>(Op), "invalid global variable ref", + &N, Op); } } if (auto *Array = N.getRawImportedEntities()) { @@ -1141,6 +1132,8 @@ void Verifier::visitDIGlobalVariable(const DIGlobalVariable &N) { AssertDI(N.getTag() == dwarf::DW_TAG_variable, "invalid tag", &N); AssertDI(!N.getName().empty(), "missing global variable name", &N); + if (auto *V = N.getRawExpr()) + AssertDI(isa<DIExpression>(V), "invalid expression location", &N, V); if (auto *Member = N.getRawStaticDataMemberDeclaration()) { AssertDI(isa<DIDerivedType>(Member), "invalid static data member declaration", &N, Member); @@ -1160,15 +1153,6 @@ void Verifier::visitDIExpression(const DIExpression &N) { AssertDI(N.isValid(), "invalid expression", &N); } -void Verifier::visitDIGlobalVariableExpression( - const DIGlobalVariableExpression &GVE) { - AssertDI(GVE.getVariable(), "missing variable"); - if (auto *Var = GVE.getVariable()) - visitDIGlobalVariable(*Var); - if (auto *Expr = GVE.getExpression()) - visitDIExpression(*Expr); -} - void Verifier::visitDIObjCProperty(const DIObjCProperty &N) { AssertDI(N.getTag() == dwarf::DW_TAG_APPLE_property, "invalid tag", &N); if (auto *T = N.getRawType()) |