diff options
author | Chris Lattner <sabre@nondot.org> | 2008-12-02 07:16:45 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2008-12-02 07:16:45 +0000 |
commit | 5df6e59fd7f4bf985cc430a0a7e9b458e7340136 (patch) | |
tree | 3c3c3533894c244adec9ccfdaae3d8e990804d01 /lib/VMCore | |
parent | 8cbcc3a6e8e4e10e69e0ed7cd8b8b8d4b56450b2 (diff) | |
download | external_llvm-5df6e59fd7f4bf985cc430a0a7e9b458e7340136.zip external_llvm-5df6e59fd7f4bf985cc430a0a7e9b458e7340136.tar.gz external_llvm-5df6e59fd7f4bf985cc430a0a7e9b458e7340136.tar.bz2 |
add a little helper function that does PHI translation.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@60405 91177308-0d34-0410-b5e6-96231b3b80d8
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 //===----------------------------------------------------------------------===// |