summaryrefslogtreecommitdiffstats
path: root/llvm/lib/VMCore/Value.cpp
diff options
context:
space:
mode:
authorEvan Cheng <evan.cheng@apple.com>2008-06-12 21:15:59 +0000
committerEvan Cheng <evan.cheng@apple.com>2008-06-12 21:15:59 +0000
commit89553cc42e34479408e1e0b6adaffdc73b35ed09 (patch)
tree4ff9642901d1904a9edbd2acde22439bb413635c /llvm/lib/VMCore/Value.cpp
parent70fe16353a8a13b6aaa0c6f27264bfc495768bb3 (diff)
downloadbcm5719-llvm-89553cc42e34479408e1e0b6adaffdc73b35ed09.tar.gz
bcm5719-llvm-89553cc42e34479408e1e0b6adaffdc73b35ed09.zip
Do not speculatively execute an instruction by hoisting it to its predecessor BB if any of its operands are defined but not used in BB. The transformation will prevent the operand from being sunk into the use block.
llvm-svn: 52244
Diffstat (limited to 'llvm/lib/VMCore/Value.cpp')
-rw-r--r--llvm/lib/VMCore/Value.cpp11
1 files changed, 11 insertions, 0 deletions
diff --git a/llvm/lib/VMCore/Value.cpp b/llvm/lib/VMCore/Value.cpp
index 919f4b00e87..e581fe83807 100644
--- a/llvm/lib/VMCore/Value.cpp
+++ b/llvm/lib/VMCore/Value.cpp
@@ -93,6 +93,17 @@ bool Value::hasNUsesOrMore(unsigned N) const {
return true;
}
+/// isUsedInBasicBlock - Return true if this value is used in the specified
+/// basic block.
+bool Value::isUsedInBasicBlock(BasicBlock *BB) const {
+ for (use_const_iterator I = use_begin(), E = use_end(); I != E; ++I) {
+ const Instruction *User = dyn_cast<Instruction>(*I);
+ if (User && User->getParent() == BB)
+ return true;
+ }
+ return false;
+}
+
/// getNumUses - This method computes the number of uses of this Value. This
/// is a linear time operation. Use hasOneUse or hasNUses to check for specific
OpenPOWER on IntegriCloud