summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Analysis/IPA/CallGraph.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* Change CallGraphNode to maintain it's Function as an AssertingVHChris Lattner2009-09-011-19/+4
| | | | | | | | | | | | for sanity. This didn't turn up any bugs. Change CallGraphNode to maintain its "callsite" information in the call edges list as a WeakVH instead of as an instruction*. This fixes a broad class of dangling pointer bugs, and makes CallGraph have a number of useful invariants again. This fixes the class of problem indicated by PR4029 and PR3601. llvm-svn: 80663
* Step #1 to giving Callgraph some sane invariants. The problems with callgraphChris Lattner2009-08-311-24/+34
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | stem from the fact that we have two types of passes that need to update it: 1. callgraphscc and module passes that are explicitly aware of it 2. Functionpasses (and loop passes etc) that are interlaced with CGSCC passes by the CGSCC Passmgr. In the case of #1, we can reasonably expect the passes to update the call graph just like any analysis. However, functionpasses are not and generally should not be CG aware. This has caused us no end of problems, so this takes a new approach. Logically, the CGSCC Pass manager can rescan every function after it runs a function pass over it to see if the functionpass made any updates to the IR that affect the callgraph. This allows it to catch new calls introduced by the functionpass. In practice, doing this would be slow. This implementation keeps track of whether or not the current scc is dirtied by a function pass, and, if so, delays updating the callgraph until it is actually needed again. This was we avoid extraneous rescans, but we still have good invariants when the callgraph is needed. Step #2 of the "give Callgraph some sane invariants" is to change CallGraphNode to use a CallBackVH for the callsite entry of the CallGraphNode. This way we can immediately remove entries from the callgraph when a FunctionPass is active instead of having dangling pointers. The current pass tries to tolerate these dangling pointers, but it is just an evil hack. This is related to PR3601/4835/4029. This also reverts r80541, a hack working around the sad lack of invariants. llvm-svn: 80566
* fix a crash building SPASS by tolerating a callsite that doesn't existChris Lattner2009-08-311-8/+13
| | | | | | in the callgraph, see the big comment at the top of the testcase. llvm-svn: 80541
* Fix PR4834, a tricky case where the inliner would resolve anChris Lattner2009-08-311-14/+23
| | | | | | | | | | | | | | | indirect function pointer, inline it, then go to delete the body. The problem is that the callgraph had other references to the function, though the inliner had no way to know it, so we got a dangling pointer and an invalid iterator out of the deal. The fix to this is pretty simple: stop the inliner from deleting the function by knowing that there are references to it. Do this by making CallGraphNodes contain a refcount. This requires moving deletion of available_externally functions to the module-level cleanup sweep where it belongs. llvm-svn: 80533
* use an accessor instead of poking internals of a node.Chris Lattner2009-08-311-1/+1
| | | | llvm-svn: 80532
* Fix some nasty callgraph dangling pointer problems in Chris Lattner2009-08-311-16/+9
| | | | | | | | | | | | | | | | | | | | | | | | | 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. llvm-svn: 80527
* add a dump() method on callgraph.Chris Lattner2009-08-301-0/+3
| | | | llvm-svn: 80524
* Change Pass::print to take a raw ostream instead of std::ostream,Chris Lattner2009-08-231-27/+13
| | | | | | update all code that this affects. llvm-svn: 79830
* More migration to raw_ostream, the water has dried up around the iostream hole.Daniel Dunbar2009-07-251-3/+3
| | | | | | | | | | - Some clients which used DOUT have moved to DEBUG. We are deprecating the "magic" DOUT behavior which avoided calling printing functions when the statement was disabled. In addition to being unnecessary magic, it had the downside of leaving code in -Asserts builds, and of hiding potentially unnecessary computations. llvm-svn: 77019
* Clear the cached cost when removing a function inDale Johannesen2009-03-191-1/+2
| | | | | | | | | the inliner; prevents nondeterministic behavior when the same address is reallocated. Don't build call graph nodes for debug intrinsic calls; they're useless, and there were typically a lot of them. llvm-svn: 67311
* introduce a useful abstraction to find out if a Use is in the call position ↵Gabor Greif2009-01-221-1/+2
| | | | | | of an instruction llvm-svn: 62788
* switch over some other methods from indices to iteratorsGabor Greif2009-01-171-8/+8
| | | | llvm-svn: 62430
* speed up iterative loop by using iterators. changes direction, but ↵Gabor Greif2009-01-171-4/+4
| | | | | | | | functionally equivalent if this works out, I'll change the others next. llvm-svn: 62385
* Add the private linkage.Rafael Espindola2009-01-151-1/+1
| | | | llvm-svn: 62279
* minor simplificationGabor Greif2009-01-141-2/+2
| | | | llvm-svn: 62232
* Teach internalize to preserve the callgraph.Duncan Sands2008-10-031-0/+13
| | | | | | Why? Because it was there! llvm-svn: 56996
* Simplify this some more. No functionality change.Duncan Sands2008-09-091-15/+8
| | | | llvm-svn: 56003
* Optimization suggested by Matthijs Kooijman.Duncan Sands2008-09-091-1/+2
| | | | llvm-svn: 55988
* Correct callgraph construction. It has two problems:Duncan Sands2008-09-091-34/+14
| | | | | | | | | | | | | | | | | | | (1) code left over from the days of ConstantPointerRef: if a use of a function is a GlobalValue then that is not considered a reason to add an edge from the external node, even though the use may be as an initializer for an externally visible global! There might be some point to this behaviour when the use is by an alias (though the code predated aliases by some centuries), but I think PR2782 is a better way of handling that. (2) If function F calls function G, and also G is a parameter to the call, then an F->G edge is not added to the callgraph. While this doesn't seem to matter much, adding such an edge makes the callgraph more regular. In addition, the new code should be faster as well as simpler. llvm-svn: 55987
* Didn't mean to commit this change to how theDuncan Sands2008-09-081-8/+4
| | | | | | callgraph is printed. llvm-svn: 55912
* Reapply 55859. This doesn't change anything asDuncan Sands2008-09-081-14/+8
| | | | | | | long as the callgraph is correct. It checks for wrong callgraphs more strictly. llvm-svn: 55894
* When PruneEH turned an invoke into an ordinaryDuncan Sands2008-09-061-1/+14
| | | | | | | | | | | | call (thus changing the call site) it didn't inform the callgraph about this. But the call site does matter - as shown by the testcase, the callgraph become invalid after the inliner ran (with an edge between two functions simply missing), resulting in wrong deductions by GlobalsModRef. llvm-svn: 55872
* Revert r55859. This is breaking the build in the abscence of its companion ↵Owen Anderson2008-09-051-0/+10
| | | | | | commit. llvm-svn: 55865
* Delete the removeCallEdgeTo callgraph method,Duncan Sands2008-09-051-10/+0
| | | | | | | | | | | | | | | because it does not maintain a correct list of callsites. I discovered (see following commit) that the inliner will create a wrong callgraph if it is fed a callgraph with correct edges but incorrect callsites. These were created by Prune-EH, and while it wasn't done via removeCallEdgeTo, it could have been done via removeCallEdgeTo, which is an accident waiting to happen. Use removeCallEdgeFor instead. llvm-svn: 55859
* Tidy up several unbeseeming casts from pointer to intptr_t.Dan Gohman2008-09-041-1/+1
| | | | llvm-svn: 55779
* Replace two manual loops with calls to CallSite::hasArguments (no functional ↵Matthijs Kooijman2008-06-041-3/+1
| | | | | | changes). llvm-svn: 51947
* Clean up the use of static and anonymous namespaces. This turned upDan Gohman2008-05-131-4/+5
| | | | | | | several things that were neither in an anonymous namespace nor static but not intended to be global. llvm-svn: 51017
* add a new CallGraphNode::removeCallEdgeFor method, tidy some comments.Chris Lattner2008-04-131-0/+14
| | | | llvm-svn: 49617
* PassInfo keep tracks whether a pass is an analysis pass or not.Devang Patel2008-03-191-1/+1
| | | | llvm-svn: 48554
* Remove attribution from file headers, per discussion on llvmdev.Chris Lattner2007-12-291-2/+2
| | | | llvm-svn: 45418
* Rather than having special rules like "intrinsics cannotDuncan Sands2007-12-031-1/+1
| | | | | | | | | throw exceptions", just mark intrinsics with the nounwind attribute. Likewise, mark intrinsics as readnone/readonly and get rid of special aliasing logic (which didn't use anything more than this anyway). llvm-svn: 44544
* Drop 'const'Devang Patel2007-05-031-3/+3
| | | | llvm-svn: 36662
* Use 'static const char' instead of 'static const int'.Devang Patel2007-05-021-4/+3
| | | | | | | Due to darwin gcc bug, one version of darwin linker coalesces static const int, which defauts PassID based pass identification. llvm-svn: 36652
* Fix build error.Lauro Ramos Venancio2007-05-021-2/+4
| | | | llvm-svn: 36648
* Do not use typeinfo to identify pass in pass manager.Devang Patel2007-05-011-1/+5
| | | | llvm-svn: 36632
* Make classes in anonymous namespaces use VISIBILITY_HIDDEN to help reduceReid Spencer2007-02-051-1/+2
| | | | | | LLVM's footprint and speed up linking. llvm-svn: 33941
* For PR1136: Rename GlobalVariable::isExternal as isDeclaration to avoidReid Spencer2007-01-301-1/+1
| | | | | | confusion with external linkage types. llvm-svn: 33663
* Added an automatic cast to "std::ostream*" etc. from OStream. We then canBill Wendling2006-12-171-2/+2
| | | | | | | rework the hacks that had us passing OStream in. We pass in std::ostream* instead, check for null, and then dispatch to the correct print() method. llvm-svn: 32636
* Changed llvm_ostream et all to OStream. llvm_cerr, llvm_cout, llvm_null, areBill Wendling2006-12-071-4/+4
| | | | | | now cerr, cout, and NullStream resp. llvm-svn: 32298
* straighten out various memory ownership issues in the callgraph stuff.Chris Lattner2006-12-051-3/+2
| | | | | | This fixes Regression/Other/2002-01-31-CallGraph.ll. llvm-svn: 32237
* Add a comment and fix a memory leak. Thanks to Vikram for pointing this out.Chris Lattner2006-12-041-4/+5
| | | | llvm-svn: 32196
* Replacing std::iostreams with llvm iostreams. Some of these changes involveBill Wendling2006-11-291-4/+9
| | | | | | | adding a temporary wrapper around the ostream to make it friendly to functions expecting an LLVM stream. This should be fixed in the future. llvm-svn: 31990
* Fix a bug pointed out by Zhongxing XuChris Lattner2006-10-091-1/+1
| | | | llvm-svn: 30831
* simplify AnalysisGroup registration, eliminating one typeid call.Chris Lattner2006-08-281-1/+1
| | | | llvm-svn: 29932
* eliminate RegisterOpt. It does the same thing as RegisterPass.Chris Lattner2006-08-271-1/+1
| | | | llvm-svn: 29925
* Change the callgraph representation to store the callsite along with theChris Lattner2006-07-121-17/+19
| | | | | | | | | | | target CG node. This allows the inliner to properly update the callgraph when using the pruning inliner. The pruning inliner may not copy over all call sites from a callee to a caller, so the edges corresponding to those call sites should not be copied over either. This fixes PR827 and Transforms/Inline/2006-07-12-InlinePruneCGUpdate.ll llvm-svn: 29120
* For PR780:Reid Spencer2006-06-071-6/+3
| | | | | | | | | | 1. Fix the macros in IncludeFile.h to put everything in the llvm namespace 2. Replace the previous explicit mechanism in all the .h and .cpp files with the macros in IncludeFile.h This gets us a consistent mechanism throughout LLVM for ensuring linkage. Next step is to make sure its used in enough places. llvm-svn: 28715
* Fix -pedantic warningChris Lattner2006-06-011-1/+1
| | | | llvm-svn: 28634
* Change from using a stub function to a stub variable for passing to theReid Spencer2006-06-011-1/+1
| | | | | | | IncludeFile hack to ensure linkage of analysis passes. This works around some -pedantic warnings about assigning an object to a function. llvm-svn: 28621
* Add a new CallGraph::getOrInsertFunction for clients to use when updatingChris Lattner2006-01-141-16/+19
| | | | | | the callgraph. llvm-svn: 25317
OpenPOWER on IntegriCloud