Fix some nasty callgraph dangling pointer problems in
authorChris Lattner <sabre@nondot.org>
Mon, 31 Aug 2009 00:19:58 +0000 (00:19 +0000)
committerChris Lattner <sabre@nondot.org>
Mon, 31 Aug 2009 00:19:58 +0000 (00:19 +0000)
commit5095e3d1d1caef8d573534d369e37277c623064c
treef6801c8985931a1d161538b2daa7961923a4f15d
parent52248ff682e13315e5be08824bdd1d340e02d610
Fix some nasty callgraph dangling pointer problems in
argpromotion and structretpromote.  Basically, when replacing
a function, they used the 'changeFunction' api which changes
the entry in the function map (and steals/reuses the callgraph
node).

This has some interesting effects: first, the problem is that it doesn't
update the "callee" edges in any callees of the function in the call graph.
Second, this covers for a major problem in all the CGSCC pass stuff, which
is that it is completely broken when functions are deleted if they *don't*
reuse a CGN.  (there is a cute little fixme about this though :).

This patch changes the protocol that CGSCC passes must obey: now the CGSCC
pass manager copies the SCC and preincrements its iterator to avoid passes
invalidating it.  This allows CGSCC passes to mutate the current SCC.  However
multiple passes may be run on that SCC, so if passes do this, they are now
required to *update* the SCC to be current when they return.

Other less interesting parts of this patch are that it makes passes update
the CG more directly, eliminates changeFunction, and requires clients of
replaceCallSite to specify the new callee CGN if they are changing it.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@80527 91177308-0d34-0410-b5e6-96231b3b80d8
include/llvm/Analysis/CallGraph.h
include/llvm/CallGraphSCCPass.h
include/llvm/Transforms/IPO/InlinerPass.h
lib/Analysis/IPA/CallGraph.cpp
lib/Analysis/IPA/CallGraphSCCPass.cpp
lib/Transforms/IPO/ArgumentPromotion.cpp
lib/Transforms/IPO/FunctionAttrs.cpp
lib/Transforms/IPO/Inliner.cpp
lib/Transforms/IPO/PruneEH.cpp
lib/Transforms/IPO/StructRetPromotion.cpp
tools/opt/opt.cpp