[llvm] r242641 - De-duplicate CS.getCalledFunction() expression.

David Blaikie dblaikie at gmail.com
Sun Jul 19 08:17:15 PDT 2015


On Sun, Jul 19, 2015 at 4:52 AM, Yaron Keren <yaron.keren at gmail.com> wrote:

> Author: yrnkrn
> Date: Sun Jul 19 06:52:02 2015
> New Revision: 242641
>
> URL: http://llvm.org/viewvc/llvm-project?rev=242641&view=rev
> Log:
> De-duplicate CS.getCalledFunction() expression.
>
> Not sure if the optimizer will save the call as getCalledFunction()
> is not a trivial access function but the code is clearer this way.
>
>
> Modified:
>     llvm/trunk/lib/Transforms/IPO/Inliner.cpp
>
> Modified: llvm/trunk/lib/Transforms/IPO/Inliner.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/IPO/Inliner.cpp?rev=242641&r1=242640&r2=242641&view=diff
>
> ==============================================================================
> --- llvm/trunk/lib/Transforms/IPO/Inliner.cpp (original)
> +++ llvm/trunk/lib/Transforms/IPO/Inliner.cpp Sun Jul 19 06:52:02 2015
> @@ -469,7 +469,8 @@ bool Inliner::runOnSCC(CallGraphSCC &SCC
>          // If this is a direct call to an external function, we can never
> inline
>          // it.  If it is an indirect call, inlining may resolve it to be a
>          // direct call, so we keep it.
> -        if (CS.getCalledFunction() &&
> CS.getCalledFunction()->isDeclaration())
> +        Function *Callee = CS.getCalledFunction();
> +        if (Callee && Callee->isDeclaration())
>

Could use the same number of lines (and, granted, more indentation) and
keep the Callee variable more narrowly scoped by doing it this way:

  if (Function *Callee = CS.getCalledFunction())
    if (Callee->isDeclaration())
      continue;


>            continue;
>
>          CallSites.push_back(std::make_pair(CS, -1));
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150719/12b8954e/attachment.html>


More information about the llvm-commits mailing list