diff options
author | Dan Gohman <gohman@apple.com> | 2012-01-04 23:01:09 +0000 |
---|---|---|
committer | Dan Gohman <gohman@apple.com> | 2012-01-04 23:01:09 +0000 |
commit | 7ac046a2616d71a8a6c2c618fb3b2bcff92c3a7d (patch) | |
tree | dbfdea237115c408b43c420ea092455cb3c03770 | |
parent | 96c09687bce5e2dfb6f81eca705515a106d1c1a3 (diff) | |
download | bcm5719-llvm-7ac046a2616d71a8a6c2c618fb3b2bcff92c3a7d.tar.gz bcm5719-llvm-7ac046a2616d71a8a6c2c618fb3b2bcff92c3a7d.zip |
Generalize isSafeToSpeculativelyExecute to work on arbitrary
Values, rather than just Instructions, since it's interesting
for ConstantExprs too.
llvm-svn: 147560
-rw-r--r-- | llvm/include/llvm/Analysis/ValueTracking.h | 2 | ||||
-rw-r--r-- | llvm/lib/Analysis/ValueTracking.cpp | 6 |
2 files changed, 6 insertions, 2 deletions
diff --git a/llvm/include/llvm/Analysis/ValueTracking.h b/llvm/include/llvm/Analysis/ValueTracking.h index 85c659c631b..300f51df372 100644 --- a/llvm/include/llvm/Analysis/ValueTracking.h +++ b/llvm/include/llvm/Analysis/ValueTracking.h @@ -174,7 +174,7 @@ namespace llvm { /// the correct dominance relationships for the operands and users hold. /// However, this method can return true for instructions that read memory; /// for such instructions, moving them may change the resulting value. - bool isSafeToSpeculativelyExecute(const Instruction *Inst, + bool isSafeToSpeculativelyExecute(const Value *V, const TargetData *TD = 0); } // end namespace llvm diff --git a/llvm/lib/Analysis/ValueTracking.cpp b/llvm/lib/Analysis/ValueTracking.cpp index 6de4426ab82..6cef42df9a2 100644 --- a/llvm/lib/Analysis/ValueTracking.cpp +++ b/llvm/lib/Analysis/ValueTracking.cpp @@ -1879,8 +1879,12 @@ bool llvm::onlyUsedByLifetimeMarkers(const Value *V) { return true; } -bool llvm::isSafeToSpeculativelyExecute(const Instruction *Inst, +bool llvm::isSafeToSpeculativelyExecute(const Value *V, const TargetData *TD) { + const Operator *Inst = dyn_cast<Operator>(V); + if (!Inst) + return false; + for (unsigned i = 0, e = Inst->getNumOperands(); i != e; ++i) if (Constant *C = dyn_cast<Constant>(Inst->getOperand(i))) if (C->canTrap()) |