aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/llvm/BasicBlock.h3
-rw-r--r--include/llvm/Constant.h4
-rw-r--r--lib/VMCore/Constants.cpp15
-rw-r--r--lib/VMCore/Globals.cpp7
-rw-r--r--lib/VMCore/Verifier.cpp3
5 files changed, 20 insertions, 12 deletions
diff --git a/include/llvm/BasicBlock.h b/include/llvm/BasicBlock.h
index 11afa40..ba4caeb 100644
--- a/include/llvm/BasicBlock.h
+++ b/include/llvm/BasicBlock.h
@@ -241,9 +241,6 @@ public:
/// 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
diff --git a/include/llvm/Constant.h b/include/llvm/Constant.h
index bcaa56e..8072fd9 100644
--- a/include/llvm/Constant.h
+++ b/include/llvm/Constant.h
@@ -65,6 +65,10 @@ public:
/// true for things like constant expressions that could divide by zero.
bool canTrap() const;
+ /// isConstantUsed - Return true if the constant has users other than constant
+ /// exprs and other dangling things.
+ bool isConstantUsed() const;
+
enum PossibleRelocationsTy {
NoRelocation = 0,
LocalRelocation = 1,
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);
}
}