diff options
author | Chris Lattner <sabre@nondot.org> | 2009-11-01 01:27:45 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2009-11-01 01:27:45 +0000 |
commit | aa99c94e2a75e86381bcc45de61c11725a1484d6 (patch) | |
tree | 5ebc881e76d6c5d15bc2a8240caa9c274da1a3ce /llvm/lib/Bitcode | |
parent | 6f29ad917051349b99d566ddf57add7c60489094 (diff) | |
download | bcm5719-llvm-aa99c94e2a75e86381bcc45de61c11725a1484d6.tar.gz bcm5719-llvm-aa99c94e2a75e86381bcc45de61c11725a1484d6.zip |
Revert 85678/85680. The decision is to stay with the current form of
indirectbr, thus we don't need "blockaddr(@func, null)". Eliminate it
for simplicity.
llvm-svn: 85699
Diffstat (limited to 'llvm/lib/Bitcode')
-rw-r--r-- | llvm/lib/Bitcode/Reader/BitcodeReader.cpp | 5 | ||||
-rw-r--r-- | llvm/lib/Bitcode/Writer/BitcodeWriter.cpp | 3 | ||||
-rw-r--r-- | llvm/lib/Bitcode/Writer/ValueEnumerator.cpp | 8 |
3 files changed, 6 insertions, 10 deletions
diff --git a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp index 749f16f7f3b..68527e3d474 100644 --- a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp +++ b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp @@ -2274,12 +2274,11 @@ 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; - BasicBlock *BB = BlockIdx == 0 ? 0 : FunctionBBs[BlockIdx-1]; - FwdRef->replaceAllUsesWith(BlockAddress::get(F, BB)); + FwdRef->replaceAllUsesWith(BlockAddress::get(F, FunctionBBs[BlockIdx])); FwdRef->eraseFromParent(); } diff --git a/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp b/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp index e32977db414..af0b8acd44c 100644 --- a/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp +++ b/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp @@ -854,8 +854,7 @@ static void WriteConstants(unsigned FirstVal, unsigned LastVal, break; } } else if (const BlockAddress *BA = dyn_cast<BlockAddress>(C)) { - assert((!BA->getBasicBlock() || - BA->getFunction() == BA->getBasicBlock()->getParent()) && + assert(BA->getFunction() == BA->getBasicBlock()->getParent() && "Malformed blockaddress"); Code = bitc::CST_CODE_BLOCKADDRESS; Record.push_back(VE.getTypeID(BA->getFunction()->getType())); diff --git a/llvm/lib/Bitcode/Writer/ValueEnumerator.cpp b/llvm/lib/Bitcode/Writer/ValueEnumerator.cpp index 92a9bab4e76..d840d4ae9fe 100644 --- a/llvm/lib/Bitcode/Writer/ValueEnumerator.cpp +++ b/llvm/lib/Bitcode/Writer/ValueEnumerator.cpp @@ -265,8 +265,6 @@ void ValueEnumerator::EnumerateValue(const Value *V) { // Do not enumerate the initializers for an array of simple characters. // The initializers just polute the value table, and we emit the strings // specially. - } else if (isa<BlockAddress>(C)) { - // Don't enumerate function or block. } else if (C->getNumOperands()) { // If a constant has operands, enumerate them. This makes sure that if a // constant has uses (for example an array of const ints), that they are @@ -278,7 +276,8 @@ void ValueEnumerator::EnumerateValue(const Value *V) { // graph that don't go through a global variable. for (User::const_op_iterator I = C->op_begin(), E = C->op_end(); I != E; ++I) - EnumerateValue(*I); + if (!isa<BasicBlock>(*I)) // Don't enumerate BB operand to BlockAddress. + EnumerateValue(*I); // Finally, add the value. Doing this could make the ValueID reference be // dangling, don't reuse it. @@ -418,10 +417,9 @@ static void IncorporateFunctionInfoGlobalBBIDs(const Function *F, /// specified basic block. This is relatively expensive information, so it /// should only be used by rare constructs such as address-of-label. unsigned ValueEnumerator::getGlobalBasicBlockID(const BasicBlock *BB) const { - if (BB == 0) return 0; unsigned &Idx = GlobalBasicBlockIDs[BB]; if (Idx != 0) - return Idx; + return Idx-1; IncorporateFunctionInfoGlobalBBIDs(BB->getParent(), GlobalBasicBlockIDs); return getGlobalBasicBlockID(BB); |