aboutsummaryrefslogtreecommitdiffstats
path: root/lib/VMCore
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2009-11-01 18:11:50 +0000
committerChris Lattner <sabre@nondot.org>2009-11-01 18:11:50 +0000
commitb8b101895463b01ac2c4044f2d49c2d624ea2e1a (patch)
treef363990ceb57c9d4f1282fb1c3595fa9e155209e /lib/VMCore
parent67127294f701ddec34ccb7a5dc324817be4645e7 (diff)
downloadexternal_llvm-b8b101895463b01ac2c4044f2d49c2d624ea2e1a.zip
external_llvm-b8b101895463b01ac2c4044f2d49c2d624ea2e1a.tar.gz
external_llvm-b8b101895463b01ac2c4044f2d49c2d624ea2e1a.tar.bz2
the verifier shouldn't modify the IR.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@85722 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/VMCore')
-rw-r--r--lib/VMCore/Constants.cpp15
-rw-r--r--lib/VMCore/Globals.cpp7
-rw-r--r--lib/VMCore/Verifier.cpp3
3 files changed, 16 insertions, 9 deletions
diff --git a/lib/VMCore/Constants.cpp b/lib/VMCore/Constants.cpp
index fe4f90a..e2e5396 100644
--- a/lib/VMCore/Constants.cpp
+++ b/lib/VMCore/Constants.cpp
@@ -160,6 +160,21 @@ bool Constant::canTrap() const {
}
}
+/// isConstantUsed - Return true if the constant has users other than constant
+/// exprs and other dangling things.
+bool Constant::isConstantUsed() const {
+ for (use_const_iterator UI = use_begin(), E = use_end(); UI != E; ++UI) {
+ const Constant *UC = dyn_cast<Constant>(*UI);
+ if (UC == 0 || isa<GlobalValue>(UC))
+ return true;
+
+ if (UC->isConstantUsed())
+ return true;
+ }
+ return false;
+}
+
+
/// getRelocationInfo - This method classifies the entry according to
/// whether or not it may generate a relocation entry. This must be
diff --git a/lib/VMCore/Globals.cpp b/lib/VMCore/Globals.cpp
index 763fc72..03ceecb 100644
--- a/lib/VMCore/Globals.cpp
+++ b/lib/VMCore/Globals.cpp
@@ -75,13 +75,6 @@ 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.
diff --git a/lib/VMCore/Verifier.cpp b/lib/VMCore/Verifier.cpp
index 6b10d69..5990e48 100644
--- a/lib/VMCore/Verifier.cpp
+++ b/lib/VMCore/Verifier.cpp
@@ -661,8 +661,7 @@ void Verifier::visitFunction(Function &F) {
// The address of the entry block cannot be taken, unless it is dead.
if (Entry->hasAddressTaken()) {
- Entry->removeDeadBlockAddress();
- Assert1(!Entry->hasAddressTaken(),
+ Assert1(!BlockAddress::get(Entry)->isConstantUsed(),
"blockaddress may not be used with the entry block!", Entry);
}
}