From 52b5491a212a78e93e869b43ec325ddbd8832784 Mon Sep 17 00:00:00 2001 From: Jonas Devlieghere Date: Fri, 2 Jul 2021 15:45:15 -0700 Subject: Revert "[DebugInfo] Enforce implicit constraints on `distinct` MDNodes" MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This reverts commit 8cd35ad854ab4458fd509447359066ea3578b494. It breaks `TestMembersAndLocalsWithSameName.py` on GreenDragon and Mikael Holmén points out in D104827 that bitcode files created with the patch cannot be parsed with binaries built before it. --- llvm/lib/Bitcode/Writer/BitcodeWriter.cpp | 17 ++--------------- 1 file changed, 2 insertions(+), 15 deletions(-) (limited to 'llvm/lib/Bitcode/Writer/BitcodeWriter.cpp') diff --git a/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp b/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp index 1ad55e2..bdb973e 100644 --- a/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp +++ b/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp @@ -1758,6 +1758,7 @@ void ModuleBitcodeWriter::writeDIFile(const DIFile *N, void ModuleBitcodeWriter::writeDICompileUnit(const DICompileUnit *N, SmallVectorImpl &Record, unsigned Abbrev) { + assert(N->isDistinct() && "Expected distinct compile units"); Record.push_back(/* IsDistinct */ true); Record.push_back(N->getSourceLanguage()); Record.push_back(VE.getMetadataOrNullID(N->getFile())); @@ -2008,7 +2009,7 @@ void ModuleBitcodeWriter::writeDIExpression(const DIExpression *N, SmallVectorImpl &Record, unsigned Abbrev) { Record.reserve(N->getElements().size() + 1); - const uint64_t Version = 4 << 1; + const uint64_t Version = 3 << 1; Record.push_back((uint64_t)N->isDistinct() | Version); Record.append(N->elements_begin(), N->elements_end()); @@ -2153,20 +2154,6 @@ void ModuleBitcodeWriter::writeMetadataRecords( if (const MDNode *N = dyn_cast(MD)) { assert(N->isResolved() && "Expected forward references to be resolved"); -#ifndef NDEBUG - switch (N->getMetadataID()) { -#define HANDLE_MDNODE_LEAF_UNIQUED(CLASS) \ - case Metadata::CLASS##Kind: \ - assert(!N->isDistinct() && "Expected non-distinct " #CLASS); \ - break; -#define HANDLE_MDNODE_LEAF_DISTINCT(CLASS) \ - case Metadata::CLASS##Kind: \ - assert(N->isDistinct() && "Expected distinct " #CLASS); \ - break; -#include "llvm/IR/Metadata.def" - } -#endif - switch (N->getMetadataID()) { default: llvm_unreachable("Invalid MDNode subclass"); -- cgit v1.1