[llvm-commits] [llvm] r73338 - in /llvm/trunk: include/llvm/LinkAllPasses.h include/llvm/Transforms/IPO.h lib/Transforms/IPO/PartialInlining.cpp

Devang Patel devang.patel at gmail.com
Mon Jun 15 15:40:07 PDT 2009


Hi Owen,

Is there any reason to not walk call graph?

On Sun, Jun 14, 2009 at 1:26 AM, Owen Anderson<resistor at mac.com> wrote:
> Author: resistor
> Date: Sun Jun 14 03:26:32 2009
> New Revision: 73338
>
> URL: http://llvm.org/viewvc/llvm-project?rev=73338&view=rev
> Log:
> Add an early implementation of a partial inlining pass. The idea behind this
> is that, for functions whose bodies are entirely guarded by an if-statement, it
> can be profitable to pull the test out of the callee and into the caller.
>
> This code has had some cursory testing, but still has a number of known issues
> on the LLVM test suite.

Make sure it handles recursive functions properly :)

> +  // Inline the top-level if test into all callers.
> +  std::vector<User*> Users(duplicateFunction->use_begin(),
> +                           duplicateFunction->use_end());
> +  for (std::vector<User*>::iterator UI = Users.begin(), UE = Users.end();
> +       UI != UE; ++UI)
> +    if (CallInst* CI = dyn_cast<CallInst>(*UI))
> +      InlineFunction(CI);
> +    else if (InvokeInst* II = dyn_cast<InvokeInst>(*UI))
> +      InlineFunction(II);
> +

What if InlineFunction() does not inline the call/invoke ?

> +  // Ditch the duplicate, since we're done with it, and rewrite all remaining
> +  // users (function pointers, etc.) back to the original function.
> +  duplicateFunction->replaceAllUsesWith(F);
> +  duplicateFunction->eraseFromParent();
> +

-
Devang




More information about the llvm-commits mailing list