aboutsummaryrefslogtreecommitdiffstats
path: root/lib/Transforms/Utils/CodeExtractor.cpp
diff options
context:
space:
mode:
authorOwen Anderson <resistor@mac.com>2009-08-25 17:26:32 +0000
committerOwen Anderson <resistor@mac.com>2009-08-25 17:26:32 +0000
commit60fd8be183f7cf17dd07c0b8ce8a4e5332d20765 (patch)
tree655ff8e9b83ccf15866f5f0d3e8f1e429f230adf /lib/Transforms/Utils/CodeExtractor.cpp
parent88a589c4b39830bbeed23654521ef2f77bb87abe (diff)
downloadexternal_llvm-60fd8be183f7cf17dd07c0b8ce8a4e5332d20765.zip
external_llvm-60fd8be183f7cf17dd07c0b8ce8a4e5332d20765.tar.gz
external_llvm-60fd8be183f7cf17dd07c0b8ce8a4e5332d20765.tar.bz2
Pull out this predicate loop into a helper function.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@80006 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms/Utils/CodeExtractor.cpp')
-rw-r--r--lib/Transforms/Utils/CodeExtractor.cpp26
1 files changed, 15 insertions, 11 deletions
diff --git a/lib/Transforms/Utils/CodeExtractor.cpp b/lib/Transforms/Utils/CodeExtractor.cpp
index ffd88da..a4f312a 100644
--- a/lib/Transforms/Utils/CodeExtractor.cpp
+++ b/lib/Transforms/Utils/CodeExtractor.cpp
@@ -361,6 +361,17 @@ Function *CodeExtractor::constructFunction(const Values &inputs,
return newFunction;
}
+static BasicBlock* FindPhiPredForUseInBlock(Value* Used, BasicBlock* BB) {
+ for (Value::use_iterator UI = Used->use_begin(),
+ UE = Used->use_end(); UI != UE; ++UI) {
+ PHINode *P = dyn_cast<PHINode>(*UI);
+ if (P && P->getParent() == BB)
+ return P->getIncomingBlock(UI);
+ }
+
+ return 0;
+}
+
/// emitCallAndSwitchStatement - This method sets up the caller side by adding
/// the call instruction, splitting any PHI nodes in the header block as
/// necessary.
@@ -540,17 +551,10 @@ emitCallAndSwitchStatement(Function *newFunction, BasicBlock *codeReplacer,
// then we need to test for dominance of the phi's predecessor
// instead. Unfortunately, this a little complicated since we
// have already rewritten uses of the value to uses of the reload.
- for (Value::use_iterator UI = Reloads[out]->use_begin(),
- UE = Reloads[out]->use_end(); UI != UE; ++UI) {
- PHINode *P = dyn_cast<PHINode>(*UI);
- if (!P || P->getParent() != OldTarget) continue;
-
- BasicBlock* pred = P->getIncomingBlock(UI);
- if (DT->dominates(DefBlock, pred)) {
- DominatesDef = true;
- break;
- }
- }
+ BasicBlock* pred = FindPhiPredForUseInBlock(Reloads[out],
+ OldTarget);
+ if (pred && DT && DT->dominates(DefBlock, pred))
+ DominatesDef = true;
}
if (DominatesDef) {