diff options
Diffstat (limited to 'lib/VMCore')
-rw-r--r-- | lib/VMCore/Value.cpp | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/lib/VMCore/Value.cpp b/lib/VMCore/Value.cpp index 0976a74..1b023e2 100644 --- a/lib/VMCore/Value.cpp +++ b/lib/VMCore/Value.cpp @@ -358,6 +358,19 @@ Value *Value::getUnderlyingObject() { return this; } +/// DoPHITranslation - If this value is a PHI node with CurBB as a its parent, +/// return the value in the PHI node corresponding to PredBB. If not, return +/// ourself. This is useful if you want to know the value something has in a +/// predecessor block. +Value *Value::DoPHITranslation(const BasicBlock *CurBB, + const BasicBlock *PredBB) { + PHINode *PN = dyn_cast<PHINode>(this); + if (PN && PN->getParent() == CurBB) + return PN->getIncomingValueForBlock(PredBB); + return this; +} + + //===----------------------------------------------------------------------===// // User Class //===----------------------------------------------------------------------===// |