From 7d83ebcadd725d050cc58962e9b7c4312d676e7f Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Sat, 31 Oct 2009 20:08:37 +0000 Subject: Make blockaddress(@func, null) be valid, and make 'deleting a basic block with a blockaddress still referring to it' replace the invalid blockaddress with a new blockaddress(@func, null) instead of a inttoptr(1). This changes the bitcode encoding format, and still needs codegen support (this should produce a non-zero value, referring to the entry block of the function would also be quite reasonable). git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@85678 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Bitcode/Reader/BitcodeReader.cpp | 5 +++-- 1 file changed, 3 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 68527e3d47..749f16f7f3 100644 --- a/lib/Bitcode/Reader/BitcodeReader.cpp +++ b/lib/Bitcode/Reader/BitcodeReader.cpp @@ -2274,11 +2274,12 @@ bool BitcodeReader::ParseFunctionBody(Function *F) { std::vector &RefList = BAFRI->second; for (unsigned i = 0, e = RefList.size(); i != e; ++i) { unsigned BlockIdx = RefList[i].first; - if (BlockIdx >= FunctionBBs.size()) + if (BlockIdx > FunctionBBs.size()) return Error("Invalid blockaddress block #"); GlobalVariable *FwdRef = RefList[i].second; - FwdRef->replaceAllUsesWith(BlockAddress::get(F, FunctionBBs[BlockIdx])); + BasicBlock *BB = BlockIdx == 0 ? 0 : FunctionBBs[BlockIdx-1]; + FwdRef->replaceAllUsesWith(BlockAddress::get(F, BB)); FwdRef->eraseFromParent(); } -- cgit v1.2.3-18-g5258