[llvm-commits] [llvm] r168525 - /llvm/trunk/lib/Transforms/Scalar/CodeGenPrepare.cpp
Evan Cheng
evan.cheng at apple.com
Sun Nov 25 11:32:46 PST 2012
Should this be merged into 3.2?
Thanks,
Evan
On Nov 23, 2012, at 11:17 AM, Benjamin Kramer <benny.kra at googlemail.com> wrote:
> Author: d0k
> Date: Fri Nov 23 13:17:06 2012
> New Revision: 168525
>
> URL: http://llvm.org/viewvc/llvm-project?rev=168525&view=rev
> Log:
> CodeGenPrepare: Move ret duplication out of the instruction iteration loop.
>
> It can delete the block, and the loop continues on free'd memory.
> No change in output. Found by valgrind.
>
> Modified:
> llvm/trunk/lib/Transforms/Scalar/CodeGenPrepare.cpp
>
> Modified: llvm/trunk/lib/Transforms/Scalar/CodeGenPrepare.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/CodeGenPrepare.cpp?rev=168525&r1=168524&r2=168525&view=diff
> ==============================================================================
> --- llvm/trunk/lib/Transforms/Scalar/CodeGenPrepare.cpp (original)
> +++ llvm/trunk/lib/Transforms/Scalar/CodeGenPrepare.cpp Fri Nov 23 13:17:06 2012
> @@ -125,7 +125,7 @@
> bool MoveExtToFormExtLoad(Instruction *I);
> bool OptimizeExtUses(Instruction *I);
> bool OptimizeSelectInst(SelectInst *SI);
> - bool DupRetToEnableTailCallOpts(ReturnInst *RI);
> + bool DupRetToEnableTailCallOpts(BasicBlock *BB);
> bool PlaceDbgValues(Function &F);
> };
> }
> @@ -689,10 +689,14 @@
> /// %tmp2 = tail call i32 @f2()
> /// ret i32 %tmp2
> /// @endcode
> -bool CodeGenPrepare::DupRetToEnableTailCallOpts(ReturnInst *RI) {
> +bool CodeGenPrepare::DupRetToEnableTailCallOpts(BasicBlock *BB) {
> if (!TLI)
> return false;
>
> + ReturnInst *RI = dyn_cast<ReturnInst>(BB->getTerminator());
> + if (!RI)
> + return false;
> +
> PHINode *PN = 0;
> BitCastInst *BCI = 0;
> Value *V = RI->getReturnValue();
> @@ -706,7 +710,6 @@
> return false;
> }
>
> - BasicBlock *BB = RI->getParent();
> if (PN && PN->getParent() != BB)
> return false;
>
> @@ -1319,9 +1322,6 @@
> if (CallInst *CI = dyn_cast<CallInst>(I))
> return OptimizeCallInst(CI);
>
> - if (ReturnInst *RI = dyn_cast<ReturnInst>(I))
> - return DupRetToEnableTailCallOpts(RI);
> -
> if (SelectInst *SI = dyn_cast<SelectInst>(I))
> return OptimizeSelectInst(SI);
>
> @@ -1339,6 +1339,8 @@
> while (CurInstIterator != BB.end())
> MadeChange |= OptimizeInst(CurInstIterator++);
>
> + MadeChange |= DupRetToEnableTailCallOpts(&BB);
> +
> return MadeChange;
> }
>
>
>
> _______________________________________________
> 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