[llvm-commits] [llvm] r127974 - /llvm/trunk/lib/Transforms/IPO/GlobalOpt.cpp

Frits van Bommel fvbommel at gmail.com
Sun Mar 20 13:09:12 PDT 2011


On Sun, Mar 20, 2011 at 8:51 PM, Anders Carlsson <andersca at mac.com> wrote:
> +      // Don't treat recursive functions as empty.
> +      if (CalledFn == &Fn)
> +        return false;

That only works for directly-recursive functions, not
mutually-recursive functions.
There could be an arbitrarily long call chain before the same function
is called again. Simplest destructor that should fail now:
  X::~X() { foo(); }
  void foo() { bar(); }
  void bar() { foo(); }

This is a problem solved in several places in LLVM already by using
something like a SmallSet<Function*>& parameter, containing the
functions currently in the call stack. They tend to use RAII to clean
up (to allow multiple successive calls to the same function).




More information about the llvm-commits mailing list