aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Bitcode/Reader/BitcodeReader.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2009-10-31 20:08:37 +0000
committerChris Lattner <sabre@nondot.org>2009-10-31 20:08:37 +0000
commitb2c0e243c54574485a146a0eb96bb38883a6dc27 (patch)
tree56d41454d4e0adc0e2b304b60200b8e1fb33f1d4 /llvm/lib/Bitcode/Reader/BitcodeReader.cpp
parent75ce573815262082666cc90bd87575557d588c01 (diff)
downloadllvm-b2c0e243c54574485a146a0eb96bb38883a6dc27.zip
llvm-b2c0e243c54574485a146a0eb96bb38883a6dc27.tar.gz
llvm-b2c0e243c54574485a146a0eb96bb38883a6dc27.tar.bz2
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). llvm-svn: 85678
Diffstat (limited to 'llvm/lib/Bitcode/Reader/BitcodeReader.cpp')
-rw-r--r--llvm/lib/Bitcode/Reader/BitcodeReader.cpp5
1 files changed, 3 insertions, 2 deletions
diff --git a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp
index 68527e3..749f16f 100644
--- a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp
+++ b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp
@@ -2274,11 +2274,12 @@ bool BitcodeReader::ParseFunctionBody(Function *F) {
std::vector<BlockAddrRefTy> &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();
}