diff options
Diffstat (limited to 'llvm/lib/IR')
-rw-r--r-- | llvm/lib/IR/AsmWriter.cpp | 8 | ||||
-rw-r--r-- | llvm/lib/IR/DebugInfoMetadata.cpp | 2 | ||||
-rw-r--r-- | llvm/lib/IR/LLVMContextImpl.h | 8 | ||||
-rw-r--r-- | llvm/lib/IR/Verifier.cpp | 14 |
4 files changed, 22 insertions, 10 deletions
diff --git a/llvm/lib/IR/AsmWriter.cpp b/llvm/lib/IR/AsmWriter.cpp index c5782f5937f..e78bc5dcc4b 100644 --- a/llvm/lib/IR/AsmWriter.cpp +++ b/llvm/lib/IR/AsmWriter.cpp @@ -1654,8 +1654,8 @@ static void writeMDLexicalBlock(raw_ostream &Out, const MDLexicalBlock *N, const Module *Context) { Out << "!MDLexicalBlock("; MDFieldPrinter Printer(Out, TypePrinter, Machine, Context); - Printer.printMetadata("scope", N->getScope(), /* ShouldSkipNull */ false); - Printer.printMetadata("file", N->getFile()); + Printer.printMetadata("scope", N->getRawScope(), /* ShouldSkipNull */ false); + Printer.printMetadata("file", N->getRawFile()); Printer.printInt("line", N->getLine()); Printer.printInt("column", N->getColumn()); Out << ")"; @@ -1668,8 +1668,8 @@ static void writeMDLexicalBlockFile(raw_ostream &Out, const Module *Context) { Out << "!MDLexicalBlockFile("; MDFieldPrinter Printer(Out, TypePrinter, Machine, Context); - Printer.printMetadata("scope", N->getScope(), /* ShouldSkipNull */ false); - Printer.printMetadata("file", N->getFile()); + Printer.printMetadata("scope", N->getRawScope(), /* ShouldSkipNull */ false); + Printer.printMetadata("file", N->getRawFile()); Printer.printInt("discriminator", N->getDiscriminator(), /* ShouldSkipZero */ false); Out << ")"; diff --git a/llvm/lib/IR/DebugInfoMetadata.cpp b/llvm/lib/IR/DebugInfoMetadata.cpp index 63a0b59f7d5..754740a34ee 100644 --- a/llvm/lib/IR/DebugInfoMetadata.cpp +++ b/llvm/lib/IR/DebugInfoMetadata.cpp @@ -272,6 +272,7 @@ MDLexicalBlock *MDLexicalBlock::getImpl(LLVMContext &Context, Metadata *Scope, Metadata *File, unsigned Line, unsigned Column, StorageType Storage, bool ShouldCreate) { + assert(Scope && "Expected scope"); DEFINE_GETIMPL_LOOKUP(MDLexicalBlock, (Scope, File, Line, Column)); Metadata *Ops[] = {File, Scope}; DEFINE_GETIMPL_STORE(MDLexicalBlock, (Line, Column), Ops); @@ -282,6 +283,7 @@ MDLexicalBlockFile *MDLexicalBlockFile::getImpl(LLVMContext &Context, unsigned Discriminator, StorageType Storage, bool ShouldCreate) { + assert(Scope && "Expected scope"); DEFINE_GETIMPL_LOOKUP(MDLexicalBlockFile, (Scope, File, Discriminator)); Metadata *Ops[] = {File, Scope}; DEFINE_GETIMPL_STORE(MDLexicalBlockFile, (Discriminator), Ops); diff --git a/llvm/lib/IR/LLVMContextImpl.h b/llvm/lib/IR/LLVMContextImpl.h index efb741f13fd..70291b5aeaa 100644 --- a/llvm/lib/IR/LLVMContextImpl.h +++ b/llvm/lib/IR/LLVMContextImpl.h @@ -594,11 +594,11 @@ template <> struct MDNodeKeyImpl<MDLexicalBlock> { MDNodeKeyImpl(Metadata *Scope, Metadata *File, unsigned Line, unsigned Column) : Scope(Scope), File(File), Line(Line), Column(Column) {} MDNodeKeyImpl(const MDLexicalBlock *N) - : Scope(N->getScope()), File(N->getFile()), Line(N->getLine()), + : Scope(N->getRawScope()), File(N->getRawFile()), Line(N->getLine()), Column(N->getColumn()) {} bool isKeyOf(const MDLexicalBlock *RHS) const { - return Scope == RHS->getScope() && File == RHS->getFile() && + return Scope == RHS->getRawScope() && File == RHS->getRawFile() && Line == RHS->getLine() && Column == RHS->getColumn(); } unsigned getHashValue() const { @@ -614,11 +614,11 @@ template <> struct MDNodeKeyImpl<MDLexicalBlockFile> { MDNodeKeyImpl(Metadata *Scope, Metadata *File, unsigned Discriminator) : Scope(Scope), File(File), Discriminator(Discriminator) {} MDNodeKeyImpl(const MDLexicalBlockFile *N) - : Scope(N->getScope()), File(N->getFile()), + : Scope(N->getRawScope()), File(N->getRawFile()), Discriminator(N->getDiscriminator()) {} bool isKeyOf(const MDLexicalBlockFile *RHS) const { - return Scope == RHS->getScope() && File == RHS->getFile() && + return Scope == RHS->getRawScope() && File == RHS->getRawFile() && Discriminator == RHS->getDiscriminator(); } unsigned getHashValue() const { diff --git a/llvm/lib/IR/Verifier.cpp b/llvm/lib/IR/Verifier.cpp index e4aea237bfc..8d7040bad4d 100644 --- a/llvm/lib/IR/Verifier.cpp +++ b/llvm/lib/IR/Verifier.cpp @@ -302,6 +302,7 @@ private: void visitMDScope(const MDScope &N); void visitMDDerivedTypeBase(const MDDerivedTypeBase &N); void visitMDVariable(const MDVariable &N); + void visitMDLexicalBlockBase(const MDLexicalBlockBase &N); // InstVisitor overrides... using InstVisitor<Verifier>::visit; @@ -871,12 +872,21 @@ void Verifier::visitMDSubprogram(const MDSubprogram &N) { } } -void Verifier::visitMDLexicalBlock(const MDLexicalBlock &N) { +void Verifier::visitMDLexicalBlockBase(const MDLexicalBlockBase &N) { Assert(N.getTag() == dwarf::DW_TAG_lexical_block, "invalid tag", &N); + Assert(N.getRawScope() && isa<MDLocalScope>(N.getRawScope()), + "invalid local scope", &N, N.getRawScope()); +} + +void Verifier::visitMDLexicalBlock(const MDLexicalBlock &N) { + visitMDLexicalBlockBase(N); + + Assert(N.getLine() || !N.getColumn(), + "cannot have column info without line info", &N); } void Verifier::visitMDLexicalBlockFile(const MDLexicalBlockFile &N) { - Assert(N.getTag() == dwarf::DW_TAG_lexical_block, "invalid tag", &N); + visitMDLexicalBlockBase(N); } void Verifier::visitMDNamespace(const MDNamespace &N) { |