From e825ed5a031937ad27d83bca12acf5533d7e0fae Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Thu, 3 May 2007 22:18:21 +0000 Subject: [PATCH] fix encoding of BB names in the symtab git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@36704 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Bitcode/Reader/BitcodeReader.cpp | 10 ++++++++++ lib/Bitcode/Writer/BitcodeWriter.cpp | 14 ++++++++++---- lib/Bitcode/Writer/ValueEnumerator.cpp | 2 +- 3 files changed, 21 insertions(+), 5 deletions(-) diff --git a/lib/Bitcode/Reader/BitcodeReader.cpp b/lib/Bitcode/Reader/BitcodeReader.cpp index 7de1662b38d..1ab9f54d5bf 100644 --- a/lib/Bitcode/Reader/BitcodeReader.cpp +++ b/lib/Bitcode/Reader/BitcodeReader.cpp @@ -411,6 +411,16 @@ bool BitcodeReader::ParseValueSymbolTable() { V->setName(&ValueName[0], ValueName.size()); ValueName.clear(); break; + case bitc::VST_CODE_BBENTRY: + if (ConvertToString(Record, 1, ValueName)) + return Error("Invalid VST_BBENTRY record"); + BasicBlock *BB = getBasicBlock(Record[0]); + if (BB == 0) + return Error("Invalid BB ID in VST_BBENTRY record"); + + BB->setName(&ValueName[0], ValueName.size()); + ValueName.clear(); + break; } } } diff --git a/lib/Bitcode/Writer/BitcodeWriter.cpp b/lib/Bitcode/Writer/BitcodeWriter.cpp index fbad7ff1255..68f0a0d1637 100644 --- a/lib/Bitcode/Writer/BitcodeWriter.cpp +++ b/lib/Bitcode/Writer/BitcodeWriter.cpp @@ -669,7 +669,6 @@ static void WriteInstruction(const Instruction &I, ValueEnumerator &VE, } break; } - case Instruction::VAArg: Code = bitc::FUNC_CODE_INST_VAARG; Vals.push_back(VE.getTypeID(I.getOperand(0)->getType())); // valistty @@ -697,16 +696,23 @@ static void WriteValueSymbolTable(const ValueSymbolTable &VST, SI != SE; ++SI) { unsigned AbbrevToUse = 0; - // VST_ENTRY: [valueid, namelen, namechar x N] - NameVals.push_back(VE.getValueID(SI->getValue())); + // VST_ENTRY: [valueid, namelen, namechar x N] + // VST_BBENTRY: [bbid, namelen, namechar x N] + unsigned Code; + if (isa(SI->getValue())) { + Code = bitc::VST_CODE_BBENTRY; + } else { + Code = bitc::VST_CODE_ENTRY; + } + NameVals.push_back(VE.getValueID(SI->getValue())); NameVals.push_back(SI->getKeyLength()); for (const char *P = SI->getKeyData(), *E = SI->getKeyData()+SI->getKeyLength(); P != E; ++P) NameVals.push_back((unsigned char)*P); // Emit the finished record. - Stream.EmitRecord(bitc::VST_CODE_ENTRY, NameVals, AbbrevToUse); + Stream.EmitRecord(Code, NameVals, AbbrevToUse); NameVals.clear(); } Stream.ExitBlock(); diff --git a/lib/Bitcode/Writer/ValueEnumerator.cpp b/lib/Bitcode/Writer/ValueEnumerator.cpp index fab1d9c684d..4d3f0fd792a 100644 --- a/lib/Bitcode/Writer/ValueEnumerator.cpp +++ b/lib/Bitcode/Writer/ValueEnumerator.cpp @@ -180,8 +180,8 @@ void ValueEnumerator::incorporateFunction(const Function &F) { isa(*OI)) EnumerateValue(*OI); } - ValueMap[BB] = BasicBlocks.size(); BasicBlocks.push_back(BB); + ValueMap[BB] = BasicBlocks.size(); } FirstInstID = Values.size(); -- 2.34.1