aboutsummaryrefslogtreecommitdiff
path: root/lib/Bitcode/Writer/ValueEnumerator.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
commit7d83ebcadd725d050cc58962e9b7c4312d676e7f (patch)
treeefdb3c359fa548ada932f522239be84ab602df20 /lib/Bitcode/Writer/ValueEnumerator.cpp
parente3246fc6ab4ae7599fa1b7aa1b37107a843b2032 (diff)
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
Diffstat (limited to 'lib/Bitcode/Writer/ValueEnumerator.cpp')
-rw-r--r--lib/Bitcode/Writer/ValueEnumerator.cpp8
1 files changed, 5 insertions, 3 deletions
diff --git a/lib/Bitcode/Writer/ValueEnumerator.cpp b/lib/Bitcode/Writer/ValueEnumerator.cpp
index d840d4ae9f..92a9bab4e7 100644
--- a/lib/Bitcode/Writer/ValueEnumerator.cpp
+++ b/lib/Bitcode/Writer/ValueEnumerator.cpp
@@ -265,6 +265,8 @@ 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
@@ -276,8 +278,7 @@ 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)
- if (!isa<BasicBlock>(*I)) // Don't enumerate BB operand to BlockAddress.
- EnumerateValue(*I);
+ EnumerateValue(*I);
// Finally, add the value. Doing this could make the ValueID reference be
// dangling, don't reuse it.
@@ -417,9 +418,10 @@ 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-1;
+ return Idx;
IncorporateFunctionInfoGlobalBBIDs(BB->getParent(), GlobalBasicBlockIDs);
return getGlobalBasicBlockID(BB);