[llvm-commits] [llvm] r85706 - in /llvm/trunk: include/llvm/BasicBlock.h lib/VMCore/Globals.cpp lib/VMCore/Verifier.cpp
Chris Lattner
sabre at nondot.org
Sat Oct 31 21:08:03 PDT 2009
Author: lattner
Date: Sat Oct 31 23:08:01 2009
New Revision: 85706
URL: http://llvm.org/viewvc/llvm-project?rev=85706&view=rev
Log:
fix an issue where the verifier would reject a function whose entry
block had its address taken even if the blockaddress was dead.
Modified:
llvm/trunk/include/llvm/BasicBlock.h
llvm/trunk/lib/VMCore/Globals.cpp
llvm/trunk/lib/VMCore/Verifier.cpp
Modified: llvm/trunk/include/llvm/BasicBlock.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/BasicBlock.h?rev=85706&r1=85705&r2=85706&view=diff
==============================================================================
--- llvm/trunk/include/llvm/BasicBlock.h (original)
+++ llvm/trunk/include/llvm/BasicBlock.h Sat Oct 31 23:08:01 2009
@@ -240,6 +240,10 @@
/// hasAddressTaken - returns true if there are any uses of this basic block
/// other than direct branches, switches, etc. to it.
bool hasAddressTaken() const { return SubclassData != 0; }
+
+ /// removeDeadBlockAddress - If there is a blockaddress node for this basic
+ /// block, try to remove it and any dead constant users of it.
+ void removeDeadBlockAddress();
private:
/// AdjustBlockAddressRefCount - BasicBlock stores the number of BlockAddress
/// objects using it. This is almost always 0, sometimes one, possibly but
Modified: llvm/trunk/lib/VMCore/Globals.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Globals.cpp?rev=85706&r1=85705&r2=85706&view=diff
==============================================================================
--- llvm/trunk/lib/VMCore/Globals.cpp (original)
+++ llvm/trunk/lib/VMCore/Globals.cpp Sat Oct 31 23:08:01 2009
@@ -75,6 +75,14 @@
}
}
+/// 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() {
Modified: llvm/trunk/lib/VMCore/Verifier.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Verifier.cpp?rev=85706&r1=85705&r2=85706&view=diff
==============================================================================
--- llvm/trunk/lib/VMCore/Verifier.cpp (original)
+++ llvm/trunk/lib/VMCore/Verifier.cpp Sat Oct 31 23:08:01 2009
@@ -658,8 +658,13 @@
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
More information about the llvm-commits
mailing list