diff options
author | Owen Anderson <resistor@mac.com> | 2009-08-25 17:26:32 +0000 |
---|---|---|
committer | Owen Anderson <resistor@mac.com> | 2009-08-25 17:26:32 +0000 |
commit | 5e39d1deecefde7c3b7bccdc2b28760657f629ea (patch) | |
tree | 5695ca516406493438fa99295b27dd32358f29e8 /llvm/lib/Transforms/Utils/CodeExtractor.cpp | |
parent | 1d5e9f9368b612c4a970b2b7d926ecb2d61baa1c (diff) | |
download | bcm5719-llvm-5e39d1deecefde7c3b7bccdc2b28760657f629ea.tar.gz bcm5719-llvm-5e39d1deecefde7c3b7bccdc2b28760657f629ea.zip |
Pull out this predicate loop into a helper function.
llvm-svn: 80006
Diffstat (limited to 'llvm/lib/Transforms/Utils/CodeExtractor.cpp')
-rw-r--r-- | llvm/lib/Transforms/Utils/CodeExtractor.cpp | 26 |
1 files changed, 15 insertions, 11 deletions
diff --git a/llvm/lib/Transforms/Utils/CodeExtractor.cpp b/llvm/lib/Transforms/Utils/CodeExtractor.cpp index ffd88da7bc8..a4f312a5ac0 100644 --- a/llvm/lib/Transforms/Utils/CodeExtractor.cpp +++ b/llvm/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) { |