diff options
| author | Chris Lattner <sabre@nondot.org> | 2009-11-01 04:08:01 +0000 |
|---|---|---|
| committer | Chris Lattner <sabre@nondot.org> | 2009-11-01 04:08:01 +0000 |
| commit | 660a4f389c84c196c983c7bae1f0a02957dc70af (patch) | |
| tree | 2eae57b9a72b6f2f93f40770d5d3eed468771500 /lib/VMCore | |
| parent | da9c281121537d9823ddeecf7bb15095d95b2722 (diff) | |
| download | external_llvm-660a4f389c84c196c983c7bae1f0a02957dc70af.zip external_llvm-660a4f389c84c196c983c7bae1f0a02957dc70af.tar.gz external_llvm-660a4f389c84c196c983c7bae1f0a02957dc70af.tar.bz2 | |
fix an issue where the verifier would reject a function whose entry
block had its address taken even if the blockaddress was dead.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@85706 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/VMCore')
| -rw-r--r-- | lib/VMCore/Globals.cpp | 8 | ||||
| -rw-r--r-- | lib/VMCore/Verifier.cpp | 9 |
2 files changed, 15 insertions, 2 deletions
diff --git a/lib/VMCore/Globals.cpp b/lib/VMCore/Globals.cpp index d18a201..763fc72 100644 --- a/lib/VMCore/Globals.cpp +++ b/lib/VMCore/Globals.cpp @@ -75,6 +75,14 @@ void GlobalValue::removeDeadConstantUsers() const { } } +/// removeDeadBlockAddress - If there is a blockaddress node for this basic +/// block, try to remove it and any dead constant users of it. +void BasicBlock::removeDeadBlockAddress() { + if (!hasAddressTaken()) return; + removeDeadUsersOfConstant(BlockAddress::get(this)); +} + + /// Override destroyConstant to make sure it doesn't get called on /// GlobalValue's because they shouldn't be treated like other constants. void GlobalValue::destroyConstant() { diff --git a/lib/VMCore/Verifier.cpp b/lib/VMCore/Verifier.cpp index fc90148..6b10d69 100644 --- a/lib/VMCore/Verifier.cpp +++ b/lib/VMCore/Verifier.cpp @@ -658,8 +658,13 @@ void Verifier::visitFunction(Function &F) { BasicBlock *Entry = &F.getEntryBlock(); Assert1(pred_begin(Entry) == pred_end(Entry), "Entry block to function must not have predecessors!", Entry); - Assert1(!Entry->hasAddressTaken(), - "blockaddress may not be used with the entry block!", Entry); + + // The address of the entry block cannot be taken, unless it is dead. + if (Entry->hasAddressTaken()) { + Entry->removeDeadBlockAddress(); + Assert1(!Entry->hasAddressTaken(), + "blockaddress may not be used with the entry block!", Entry); + } } // If this function is actually an intrinsic, verify that it is only used in |
