diff --git a/lib/Bitcode/Writer/BitcodeWriter.cpp b/lib/Bitcode/Writer/BitcodeWriter.cpp index ff47cf436cb..e5fb50f5bc7 100644 --- a/lib/Bitcode/Writer/BitcodeWriter.cpp +++ b/lib/Bitcode/Writer/BitcodeWriter.cpp @@ -495,7 +495,6 @@ static void WriteModuleMetadata(const ValueEnumerator &VE, const ValueEnumerator::ValueList &Vals = VE.getValues(); bool StartedMetadataBlock = false; unsigned MDSAbbrev = 0; - unsigned String8Abbrev = 0; SmallVector Record; for (unsigned i = 0, e = Vals.size(); i != e; ++i) { @@ -530,18 +529,14 @@ static void WriteModuleMetadata(const ValueEnumerator &VE, if (!StartedMetadataBlock) { Stream.EnterSubblock(bitc::METADATA_BLOCK_ID, 3); StartedMetadataBlock = true; - BitCodeAbbrev *Abbv = new BitCodeAbbrev(); - Abbv->Add(BitCodeAbbrevOp(bitc::CST_CODE_STRING)); - Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Array)); - Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 8)); - String8Abbrev = Stream.EmitAbbrev(Abbv); } // Write name. - const char *StrBegin = NMD->getName().data(); - for (unsigned i = 0, e = NMD->getName().size(); i != e; ++i) + std::string Str = NMD->getNameStr(); + const char *StrBegin = Str.c_str(); + for (unsigned i = 0, e = Str.length(); i != e; ++i) Record.push_back(StrBegin[i]); - Stream.EmitRecord(bitc::METADATA_NAME, Record, String8Abbrev); + Stream.EmitRecord(bitc::METADATA_NAME, Record, 0/*TODO*/); Record.clear(); // Write named metadata elements. diff --git a/test/Feature/NamedMDNode2.ll b/test/Feature/NamedMDNode2.ll new file mode 100644 index 00000000000..b560772c797 --- /dev/null +++ b/test/Feature/NamedMDNode2.ll @@ -0,0 +1,7 @@ +; RUN: llvm-as < %s -f -o /dev/null +; PR4654 + + +@foo = constant i1 false +!0 = metadata !{i1 false} +!a = !{!0}