[llvm-commits] [llvm] r80006 - /llvm/trunk/lib/Transforms/Utils/CodeExtractor.cpp
Chris Lattner
clattner at apple.com
Tue Aug 25 10:36:42 PDT 2009
On Aug 25, 2009, at 10:26 AM, Owen Anderson wrote:
> Author: resistor
> Date: Tue Aug 25 12:26:32 2009
> New Revision: 80006
>
> URL: http://llvm.org/viewvc/llvm-project?rev=80006&view=rev
> Log:
> Pull out this predicate loop into a helper function.
Great, now the other loop too? How about some doxygen comments? :)
Thanks Owen,
-Chris
>
> Modified:
> llvm/trunk/lib/Transforms/Utils/CodeExtractor.cpp
>
> Modified: llvm/trunk/lib/Transforms/Utils/CodeExtractor.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/CodeExtractor.cpp?rev=80006&r1=80005&r2=80006&view=diff
>
> =
> =
> =
> =
> =
> =
> =
> =
> ======================================================================
> --- llvm/trunk/lib/Transforms/Utils/CodeExtractor.cpp (original)
> +++ llvm/trunk/lib/Transforms/Utils/CodeExtractor.cpp Tue Aug 25
> 12:26:32 2009
> @@ -361,6 +361,17 @@
> 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 @@
> // 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) {
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
More information about the llvm-commits
mailing list