From d7bb295d223e028aa9ba7fbeafc8928db4a74972 Mon Sep 17 00:00:00 2001 From: Bill Wendling Date: Sun, 10 Apr 2011 00:04:27 +0000 Subject: Beginning of the Great Exception Handling Rewrite. * Add a "landing pad" attribute to the BasicBlock. * Modify the bitcode reader and writer to handle said attribute. Later: The verifier will ensure that the landing pad attribute is used in the appropriate manner. I.e., not applied to the entry block, and applied only to basic blocks that are branched to via a `dispatch' instruction. (This is a work-in-progress.) git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@129235 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Bitcode/Reader/BitcodeReader.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'lib/Bitcode/Reader/BitcodeReader.cpp') diff --git a/lib/Bitcode/Reader/BitcodeReader.cpp b/lib/Bitcode/Reader/BitcodeReader.cpp index 8223f76..2355198 100644 --- a/lib/Bitcode/Reader/BitcodeReader.cpp +++ b/lib/Bitcode/Reader/BitcodeReader.cpp @@ -714,7 +714,8 @@ bool BitcodeReader::ParseValueSymbolTable() { // Read a record. Record.clear(); - switch (Stream.ReadRecord(Code, Record)) { + unsigned VSTCode = Stream.ReadRecord(Code, Record); + switch (VSTCode) { default: // Default behavior: unknown type. break; case bitc::VST_CODE_ENTRY: { // VST_ENTRY: [valueid, namechar x N] @@ -729,13 +730,17 @@ bool BitcodeReader::ParseValueSymbolTable() { ValueName.clear(); break; } - case bitc::VST_CODE_BBENTRY: { + case bitc::VST_CODE_BBENTRY: + case bitc::VST_CODE_LPADENTRY: { 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"); + if (VSTCode == bitc::VST_CODE_LPADENTRY) + BB->setIsLandingPad(true); + BB->setName(StringRef(ValueName.data(), ValueName.size())); ValueName.clear(); break; -- cgit v1.1 From 5d7a5a4f53304869ae5b76771ab67213447b65a5 Mon Sep 17 00:00:00 2001 From: Bill Wendling Date: Sun, 10 Apr 2011 23:18:04 +0000 Subject: Revert r129235 pending a vetting of the EH rewrite. --- Reverse-merging r129235 into '.': D test/Feature/bb_attrs.ll U include/llvm/BasicBlock.h U include/llvm/Bitcode/LLVMBitCodes.h U lib/VMCore/AsmWriter.cpp U lib/VMCore/BasicBlock.cpp U lib/AsmParser/LLParser.cpp U lib/AsmParser/LLLexer.cpp U lib/AsmParser/LLToken.h U lib/Bitcode/Reader/BitcodeReader.cpp U lib/Bitcode/Writer/BitcodeWriter.cpp git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@129259 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Bitcode/Reader/BitcodeReader.cpp | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) (limited to 'lib/Bitcode/Reader/BitcodeReader.cpp') diff --git a/lib/Bitcode/Reader/BitcodeReader.cpp b/lib/Bitcode/Reader/BitcodeReader.cpp index 2355198..8223f76 100644 --- a/lib/Bitcode/Reader/BitcodeReader.cpp +++ b/lib/Bitcode/Reader/BitcodeReader.cpp @@ -714,8 +714,7 @@ bool BitcodeReader::ParseValueSymbolTable() { // Read a record. Record.clear(); - unsigned VSTCode = Stream.ReadRecord(Code, Record); - switch (VSTCode) { + switch (Stream.ReadRecord(Code, Record)) { default: // Default behavior: unknown type. break; case bitc::VST_CODE_ENTRY: { // VST_ENTRY: [valueid, namechar x N] @@ -730,17 +729,13 @@ bool BitcodeReader::ParseValueSymbolTable() { ValueName.clear(); break; } - case bitc::VST_CODE_BBENTRY: - case bitc::VST_CODE_LPADENTRY: { + 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"); - if (VSTCode == bitc::VST_CODE_LPADENTRY) - BB->setIsLandingPad(true); - BB->setName(StringRef(ValueName.data(), ValueName.size())); ValueName.clear(); break; -- cgit v1.1 From b81e457eb02b67a9ef5fb9edc1604b177acb821d Mon Sep 17 00:00:00 2001 From: Jay Foad Date: Wed, 13 Apr 2011 13:46:01 +0000 Subject: PR9214: Convert ConstantExpr::getWithOperands() to use ArrayRef. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@129439 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Bitcode/Reader/BitcodeReader.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'lib/Bitcode/Reader/BitcodeReader.cpp') diff --git a/lib/Bitcode/Reader/BitcodeReader.cpp b/lib/Bitcode/Reader/BitcodeReader.cpp index 8223f76..d42fb92 100644 --- a/lib/Bitcode/Reader/BitcodeReader.cpp +++ b/lib/Bitcode/Reader/BitcodeReader.cpp @@ -301,8 +301,7 @@ void BitcodeReaderValueList::ResolveConstantForwardRefs() { NewC = ConstantVector::get(NewOps); } else { assert(isa(UserC) && "Must be a ConstantExpr."); - NewC = cast(UserC)->getWithOperands(&NewOps[0], - NewOps.size()); + NewC = cast(UserC)->getWithOperands(NewOps); } UserC->replaceAllUsesWith(NewC); -- cgit v1.1 From ec9186bcf975c9ffa3ec7ca97867f0ec6eb55115 Mon Sep 17 00:00:00 2001 From: Jay Foad Date: Thu, 21 Apr 2011 19:59:31 +0000 Subject: PR9214: Convert Metadata API to use ArrayRef. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@129932 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Bitcode/Reader/BitcodeReader.cpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'lib/Bitcode/Reader/BitcodeReader.cpp') diff --git a/lib/Bitcode/Reader/BitcodeReader.cpp b/lib/Bitcode/Reader/BitcodeReader.cpp index d42fb92..19f57cf 100644 --- a/lib/Bitcode/Reader/BitcodeReader.cpp +++ b/lib/Bitcode/Reader/BitcodeReader.cpp @@ -349,7 +349,7 @@ Value *BitcodeReaderMDValueList::getValueFwdRef(unsigned Idx) { } // Create and return a placeholder, which will later be RAUW'd. - Value *V = MDNode::getTemporary(Context, 0, 0); + Value *V = MDNode::getTemporary(Context, ArrayRef()); MDValuePtrs[Idx] = V; return V; } @@ -843,9 +843,7 @@ bool BitcodeReader::ParseMetadata() { else Elts.push_back(NULL); } - Value *V = MDNode::getWhenValsUnresolved(Context, - Elts.data(), Elts.size(), - IsFunctionLocal); + Value *V = MDNode::getWhenValsUnresolved(Context, Elts, IsFunctionLocal); IsFunctionLocal = false; MDValueList.AssignValue(V, NextMDValueNo++); break; -- cgit v1.1 From c9687b32fab6d6ec53ac95dccf61d598be26d5dc Mon Sep 17 00:00:00 2001 From: Rafael Espindola Date: Thu, 26 May 2011 18:59:54 +0000 Subject: Fix LTO builds with xcode 4. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@132132 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Bitcode/Reader/BitcodeReader.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'lib/Bitcode/Reader/BitcodeReader.cpp') diff --git a/lib/Bitcode/Reader/BitcodeReader.cpp b/lib/Bitcode/Reader/BitcodeReader.cpp index 19f57cf..c4ef57c 100644 --- a/lib/Bitcode/Reader/BitcodeReader.cpp +++ b/lib/Bitcode/Reader/BitcodeReader.cpp @@ -1588,8 +1588,18 @@ bool BitcodeReader::ParseBitcodeInto(Module *M) { while (!Stream.AtEndOfStream()) { unsigned Code = Stream.ReadCode(); - if (Code != bitc::ENTER_SUBBLOCK) + if (Code != bitc::ENTER_SUBBLOCK) { + + // The ranlib in xcode 4 will align archive members by appending newlines to the + // end of them. If this file size is a multiple of 4 but not 8, we have to read and + // ignore these final 4 bytes :-( + if (Stream.GetAbbrevIDWidth() == 2 && Code == 2 && + Stream.Read(6) == 2 && Stream.Read(24) == 0xa0a0a && + Stream.AtEndOfStream()) + return false; + return Error("Invalid record at top-level"); + } unsigned BlockID = Stream.ReadSubBlockID(); -- cgit v1.1 From 3d26f2333b320e04d405a4418f640f8b7e358a99 Mon Sep 17 00:00:00 2001 From: Chad Rosier Date: Fri, 3 Jun 2011 05:09:12 +0000 Subject: Whitespace and other cleanup. Functionallity unchanged. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@132533 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Bitcode/Reader/BitcodeReader.cpp | 1 - 1 file changed, 1 deletion(-) (limited to 'lib/Bitcode/Reader/BitcodeReader.cpp') diff --git a/lib/Bitcode/Reader/BitcodeReader.cpp b/lib/Bitcode/Reader/BitcodeReader.cpp index c4ef57c..bc995ae 100644 --- a/lib/Bitcode/Reader/BitcodeReader.cpp +++ b/lib/Bitcode/Reader/BitcodeReader.cpp @@ -1852,7 +1852,6 @@ bool BitcodeReader::ParseFunctionBody(Function *F) { FunctionBBs[i] = BasicBlock::Create(Context, "", F); CurBB = FunctionBBs[0]; continue; - case bitc::FUNC_CODE_DEBUG_LOC_AGAIN: // DEBUG_LOC_AGAIN // This record indicates that the last instruction is at the same -- cgit v1.1