summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Analysis/IPA/CallGraphSCCPass.cpp
Commit message (Collapse)AuthorAgeFilesLines
* use Value* constructor of CallSite to create potentially improper site, and ↵Gabor Greif2010-07-281-3/+3
| | | | | | test that llvm-svn: 109580
* fix PR5009 by making CGSCCPM realize that a call was devirtualizedChris Lattner2010-05-011-5/+36
| | | | | | | if an indirect call site was removed and a direct one was added, not just if an indirect call site was modified to be direct. llvm-svn: 102830
* Implement rdar://6295824 and PR6724 with two tiny changesChris Lattner2010-05-011-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | that can have a big effect :). The first is to enable the iterative SCC passmanager juice that kicks in when the scc passmgr detects that a function pass has devirtualized a call. In this case, it will rerun all the passes it manages on the SCC, up to the iteration count limit (4). This is useful because a function pass may devirualize a call, and we want the inliner to inline it, or pruneeh to infer stuff about it, etc. The second patch is to add *all* call sites to the DevirtualizedCalls list the inliner uses. This list is about to get renamed, but the jist of this is that the inliner now reconsiders *all* inlined call sites as candidates for further inlining. The intuition is this that in cases like this: f() { g(1); } g(int x) { h(x); } We analyze this bottom up, and may decide that it isn't profitable to inline H into G. Next step, we decide that it is profitable to inline G into F, and do so, which means that F now calls H. Even though the call from G -> H may not have been profitable to inline, the call from F -> H may be (in this case because a constant allows folding etc). In my spot checks, this doesn't have a big impact on code. For example, the LLC output for 252.eon grew from 0.02% (from 317252 to 317308) and 176.gcc actually shrunk by .3% (from 1525612 to 1520964 bytes). 252.eon never iterated in the SCC Passmgr, 176.gcc iterated at most 1 time. llvm-svn: 102823
* add a DEBUG call so that -debug lists when CGSCCPM iterates.Chris Lattner2010-04-221-7/+4
| | | | | | | | | Fix RefreshCallGraph to use CGN->replaceCallEdge instead of hand rolling its own loop. replaceCallEdge properly maintains the reference counts of the nodes, fixing a crash exposed by the iterative callgraph stuff. llvm-svn: 102120
* Implement (but don't enable) PR6724 and rdar://6295824. In short,Chris Lattner2010-04-211-56/+122
| | | | | | | | | | | | | | | we have RefreshCallGraph detect when a function pass devirtualizes a call, and have CGSCCPassMgr iterate (up to a count) when this happens. This allows (in the example) GVN to devirtualize the call in foo, then the inliner to inline it away. This is not currently enabled because I haven't done any analysis on the (potentially substantial) code size or performance impact of doing this, and guess what, it exposes callgraph updating bugs in various passes. This is progress though, and you can play with it by passing -max-cg-scc-iterations=5 to opt. llvm-svn: 101973
* reenable r101565, removing a problematic assertion.Chris Lattner2010-04-171-2/+0
| | | | | | | | | | | CGSCC can delete nodes in regions of the callgraph that have already been visited. If new CG nodes are allocated to the same pointer, we shouldn't abort, just handle it correctly by assigning a new number. This should restore stability by removing invalidated pointers that *will* be reused from the densemap in the iterator. llvm-svn: 101628
* disable r101565: an assert is getting triggered. More lurking badness no doubt.Chris Lattner2010-04-171-0/+2
| | | | llvm-svn: 101583
* building on the new CallGraphSCC abstraction, teach CallGraphSCCPassManager Chris Lattner2010-04-161-0/+5
| | | | | | | | | | | | to keep the node entries in scc_iterator up to date instead of dangling as the SCC mutates. This is a really terrible problem which was causing -g to affect codegen because it would permute the memory image of the compiler process. Thanks to Dale for expertly hunting it down. llvm-svn: 101565
* move ReplaceNode out of line, rename scc_iterator::fini -> isAtEnd().Chris Lattner2010-04-161-5/+15
| | | | | | No functionality change. llvm-svn: 101562
* introduce a new CallGraphSCC class, and pass it aroundChris Lattner2010-04-161-21/+34
| | | | | | | | to CallGraphSCCPass's instead of passing around a std::vector<CallGraphNode*>. No functionality change, but now we have a much tidier interface. llvm-svn: 101558
* move PrintCallGraphPass out of the middle of CGPassManager.Chris Lattner2010-04-161-33/+43
| | | | llvm-svn: 101543
* Ok, third time's the charm. No changes from last time except the CMakeDavid Greene2010-04-021-0/+35
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | source addition. Apparently the buildbots were wrong about failures. --- Add some switches helpful for debugging: -print-before=<Pass Name> Dump IR before running pass <Pass Name>. -print-before-all Dump IR before running each pass. -print-after-all Dump IR after running each pass. These are helpful when tracking down a miscompilation. It is easy to get IR dumps and do diffs on them, etc. To make this work well, add a new getPrinterPass API to Pass so that each kind of pass (ModulePass, FunctionPass, etc.) can create a Pass suitable for dumping out the kind of object the Pass works on. llvm-svn: 100249
* Revert 100204. It broke a bunch of tests and apparently changed what passes ↵Evan Cheng2010-04-021-35/+0
| | | | | | are run during codegen. llvm-svn: 100207
* Let's try this again. Re-apply 100143 including an apparent missingDavid Greene2010-04-021-0/+35
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | <string> include. For some reason the buildbot choked on this while my builds did not. It's probably due to a difference in system headers. --- Add some switches helpful for debugging: -print-before=<Pass Name> Dump IR before running pass <Pass Name>. -print-before-all Dump IR before running each pass. -print-after-all Dump IR after running each pass. These are helpful when tracking down a miscompilation. It is easy to get IR dumps and do diffs on them, etc. To make this work well, add a new getPrinterPass API to Pass so that each kind of pass (ModulePass, FunctionPass, etc.) can create a Pass suitable for dumping out the kind of object the Pass works on. llvm-svn: 100204
* Revert r100143.Eric Christopher2010-04-011-35/+0
| | | | llvm-svn: 100146
* Add some switches helpful for debugging:David Greene2010-04-011-0/+35
| | | | | | | | | | | | | | | | | | | | | | | -print-before=<Pass Name> Dump IR before running pass <Pass Name>. -print-before-all Dump IR before running each pass. -print-after-all Dump IR after running each pass. These are helpful when tracking down a miscompilation. It is easy to get IR dumps and do diffs on them, etc. To make this work well, add a new getPrinterPass API to Pass so that each kind of pass (ModulePass, FunctionPass, etc.) can create a Pass suitable for dumping out the kind of object the Pass works on. llvm-svn: 100143
* reapply my timer rewrite with a change for PassManager to store Chris Lattner2010-03-301-8/+9
| | | | | | timers by pointer instead of by-value. llvm-svn: 99871
* revert r99862 which is causing FNT failures.Chris Lattner2010-03-301-9/+8
| | | | llvm-svn: 99870
* fairly major rewrite of various timing related stuff.Chris Lattner2010-03-301-8/+9
| | | | llvm-svn: 99862
* eliminate dynamic_cast from this file.Chris Lattner2010-01-221-17/+20
| | | | llvm-svn: 94157
* eliminate a bunch more unneeded dynamic_cast's.Chris Lattner2010-01-221-8/+9
| | | | llvm-svn: 94156
* eliminate a bunch of dynamic_cast's.Chris Lattner2010-01-221-0/+3
| | | | llvm-svn: 94155
* Change dbgs() back to errs() for assert messages as Chris requested.David Greene2009-12-231-1/+1
| | | | llvm-svn: 92080
* Convert debug messages to use dbgs(). Generally this meansDavid Greene2009-12-231-5/+5
| | | | | | s/errs/dbgs/g except for certain special cases. llvm-svn: 92035
* Extend the StartPassTimer and StopPassTimer functions so that theDan Gohman2009-09-281-4/+4
| | | | | | | | code that stops the timer doesn't have to search to find the timer object before it stops the timer. This avoids a lock acquisition and a few other things done with the timer running. llvm-svn: 82949
* make -debug-pass=Executions show information about what call graph nodesChris Lattner2009-09-151-1/+14
| | | | | | are in the SCC for each execution of a CGSCC pass. llvm-svn: 81838
* Fix uppercaseo.Dale Johannesen2009-09-101-1/+1
| | | | llvm-svn: 81463
* revert my patch, duncan points out what is wrong with my logic. AddChris Lattner2009-09-021-4/+8
| | | | | | a comment so that I don't change this in the future :) llvm-svn: 80760
* one more try at making this simpler, hopefully it won't break everything :)Chris Lattner2009-09-021-4/+4
| | | | llvm-svn: 80759
* Complicate Chris's simplification, avoiding complaintsDuncan Sands2009-09-021-1/+5
| | | | | | | about singular iterators when building with expensive checks turned on. llvm-svn: 80757
* debug intrinsics do not go in the callgraph, this fixes a coupleChris Lattner2009-09-011-1/+2
| | | | | | clang regtest failures. llvm-svn: 80724
* Fix a regression I introduced in r80708, found by llvm-test.Chris Lattner2009-09-011-5/+12
| | | | llvm-svn: 80718
* remove CallGraphNode::replaceCallSite, it is redundant with other APIs.Chris Lattner2009-09-011-1/+1
| | | | llvm-svn: 80708
* doxygenate RefreshCallGraph, add a new 'verification mode', and run it after Chris Lattner2009-09-011-4/+37
| | | | | | | CGSCC passes make change to ensure they are updating the callgraph correctly (when assertions are enabled). llvm-svn: 80698
* simpler solution to iterator invalidation "problem" foundChris Lattner2009-09-011-11/+6
| | | | | | by expensive checking. llvm-svn: 80695
* Do not manipulate invalid iterators. This fixes theDuncan Sands2009-09-011-6/+11
| | | | | | llvm-gcc build when expensive checking is turned on. llvm-svn: 80671
* Change CallGraphNode to maintain it's Function as an AssertingVHChris Lattner2009-09-011-18/+30
| | | | | | | | | | | | 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
* cleanups pointed out by duncanChris Lattner2009-08-311-2/+1
| | | | llvm-svn: 80595
* Step #1 to giving Callgraph some sane invariants. The problems with callgraphChris Lattner2009-08-311-3/+136
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* cleanups, factor some code out to a helper functionChris Lattner2009-08-311-22/+39
| | | | llvm-svn: 80542
* Fix some nasty callgraph dangling pointer problems in Chris Lattner2009-08-311-8/+12
| | | | | | | | | | | | | | | | | | | | | | | | | 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
* Change Pass::print to take a raw ostream instead of std::ostream,Chris Lattner2009-08-231-4/+4
| | | | | | update all code that this affects. llvm-svn: 79830
* Remove Value::getName{Start,End}, the last of the old Name APIs.Daniel Dunbar2009-07-261-1/+1
| | | | llvm-svn: 77152
* Reapply r64300:Nick Lewycky2009-02-131-2/+12
| | | | | | | | | Make sure the SCC pass manager initializes any contained function pass managers. Without this, simplify-libcalls would add nocapture attributes when run on its own, but not when run as part of -std-compile-opts or similar. llvm-svn: 64443
* Revert r64300 and r64301. These were causing the following errors respectively:Bill Wendling2009-02-111-18/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | During llvm-gcc bootstrap: Undefined symbols: "llvm::FPPassManager::doFinalization(llvm::Module&)", referenced from: (anonymous namespace)::CGPassManager::doFinalization(llvm::CallGraph&, llvm::Module&) in libLLVMipa.a(CallGraphSCCPass.o) "llvm::FPPassManager::doInitialization(llvm::Module&)", referenced from: (anonymous namespace)::CGPassManager::doInitialization(llvm::CallGraph&, llvm::Module&) in libLLVMipa.a(CallGraphSCCPass.o) ld: symbol(s) not found collect2: ld returned 1 exit status make[3]: *** [/Volumes/Sandbox/Buildbot/llvm/full-llvm/build/llvmCore.roots/llvmCore~obj/obj-llvm/Release/bin/opt] Error 1 During an LLVM release build: /Volumes/Sandbox/Buildbot/llvm/full-llvm/build/llvm.sh.build/Release/bin/tblgen -I /Volumes/Sandbox/Buildbot/llvm/full-llvm/build/llvmCore/lib/Target/X86 -I /Volumes/Sandbox/Buildbot/llvm/full-llvm/build/llvmCore/include -I /Volumes/Sandbox/Buildbot/llvm/full-llvm/build/llvmCore/include -I /Volumes/Sandbox/Buildbot/llvm/full-llvm/build/llvmCore/lib/Target -gen-register-desc -o /Volumes/Sandbox/Buildbot/llvm/full-llvm/build/llvm.sh.build/lib/Target/X86/Release/X86GenRegisterInfo.inc.tmp /Volumes/Sandbox/Buildbot/llvm/full-llvm/build/llvmCore/lib/Target/X86/X86.td llvm[3]: Building X86.td instruction names with tblgen /Volumes/Sandbox/Buildbot/llvm/full-llvm/build/llvm.sh.build/Release/bin/tblgen -I /Volumes/Sandbox/Buildbot/llvm/full-llvm/build/llvmCore/lib/Target/X86 -I /Volumes/Sandbox/Buildbot/llvm/full-llvm/build/llvmCore/include -I /Volumes/Sandbox/Buildbot/llvm/full-llvm/build/llvmCore/include -I /Volumes/Sandbox/Buildbot/llvm/full-llvm/build/llvmCore/lib/Target -gen-instr-enums -o /Volumes/Sandbox/Buildbot/llvm/full-llvm/build/llvm.sh.build/lib/Target/X86/Release/X86GenInstrNames.inc.tmp /Volumes/Sandbox/Buildbot/llvm/full-llvm/build/llvmCore/lib/Target/X86/X86.td llvm[3]: Building X86.td instruction information with tblgen /Volumes/Sandbox/Buildbot/llvm/full-llvm/build/llvm.sh.build/Release/bin/tblgen -I /Volumes/Sandbox/Buildbot/llvm/full-llvm/build/llvmCore/lib/Target/X86 -I /Volumes/Sandbox/Buildbot/llvm/full-llvm/build/llvmCore/include -I /Volumes/Sandbox/Buildbot/llvm/full-llvm/build/llvmCore/include -I /Volumes/Sandbox/Buildbot/llvm/full-llvm/build/llvmCore/lib/Target -gen-instr-desc -o /Volumes/Sandbox/Buildbot/llvm/full-llvm/build/llvm.sh.build/lib/Target/X86/Release/X86GenInstrInfo.inc.tmp /Volumes/Sandbox/Buildbot/llvm/full-llvm/build/llvmCore/lib/Target/X86/X86.td llvm[3]: Building X86.td assembly writer with tblgen /Volumes/Sandbox/Buildbot/llvm/full-llvm/build/llvm.sh.build/Release/bin/tblgen -I /Volumes/Sandbox/Buildbot/llvm/full-llvm/build/llvmCore/lib/Target/X86 -I /Volumes/Sandbox/Buildbot/llvm/full-llvm/build/llvmCore/include -I /Volumes/Sandbox/Buildbot/llvm/full-llvm/build/llvmCore/include -I /Volumes/Sandbox/Buildbot/llvm/full-llvm/build/llvmCore/lib/Target -gen-asm-writer -o /Volumes/Sandbox/Buildbot/llvm/full-llvm/build/llvm.sh.build/lib/Target/X86/Release/X86GenAsmWriter.inc.tmp /Volumes/Sandbox/Buildbot/llvm/full-llvm/build/llvmCore/lib/Target/X86/X86.td llvm[3]: Compiling InstructionCombining.cpp for Release build if /Volumes/Sandbox/Buildbot/llvm/full-llvm/build/llvmgcc42.roots/llvmgcc42~dst/Developer/usr/bin/llvm-g++-4.2 -I/Volumes/Sandbox/Buildbot/llvm/full-llvm/build/llvm.sh.build/include -I/Volumes/Sandbox/Buildbot/llvm/full-llvm/build/llvm.sh.build/lib/Transforms/Scalar -I/Volumes/Sandbox/Buildbot/llvm/full-llvm/build/llvmCore/include -I/Volumes/Sandbox/Buildbot/llvm/full-llvm/build/llvmCore/lib/Transforms/Scalar -D_DEBUG -D_GNU_SOURCE -D__STDC_LIMIT_MACROS -D__STDC_CONSTANT_MACROS -O3 -fno-exceptions -Woverloaded-virtual -pedantic -Wall -W -Wwrite-strings -Wno-long-long -Wunused -Wno-unused-parameter -fstrict-aliasing -Wstrict-aliasing -c -MMD -MP -MF "/Volumes/Sandbox/Buildbot/llvm/full-llvm/build/llvm.sh.build/lib/Transforms/Scalar/Release/InstructionCombining.d.tmp" -MT "/Volumes/Sandbox/Buildbot/llvm/full-llvm/build/llvm.sh.build/lib/Transforms/Scalar/Release/InstructionCombining.lo" -MT "/Volumes/Sandbox/Buildbot/llvm/full-llvm/build/llvm.sh.build/lib/Transforms/Scalar/Release/InstructionCombining.o" -MT "/Volumes/Sandbox/Buildbot/llvm/full-llvm/build/llvm.sh.build/lib/Transforms/Scalar/Release/InstructionCombining.d" /Volumes/Sandbox/Buildbot/llvm/full-llvm/build/llvmCore/lib/Transforms/Scalar/InstructionCombining.cpp -o /Volumes/Sandbox/Buildbot/llvm/full-llvm/build/llvm.sh.build/lib/Transforms/Scalar/Release/InstructionCombining.o ; \ then /bin/mv -f "/Volumes/Sandbox/Buildbot/llvm/full-llvm/build/llvm.sh.build/lib/Transforms/Scalar/Release/InstructionCombining.d.tmp" "/Volumes/Sandbox/Buildbot/llvm/full-llvm/build/llvm.sh.build/lib/Trans llvm-svn: 64311
* Make sure the SCC pass manager initializes any containedDuncan Sands2009-02-111-8/+18
| | | | | | | | function pass managers. Without this, simplify-libcalls would add nocapture attributes when run on its own, but not when run as part of -std-compile-opts or similar. llvm-svn: 64300
* Tidy up several unbeseeming casts from pointer to intptr_t.Dan Gohman2008-09-041-1/+1
| | | | llvm-svn: 55779
* Don't call getAnalysisUsage unless -debug-pass is enabled. This speedsChris Lattner2008-08-081-4/+2
| | | | | | up the passmgr by avoiding useless work. llvm-svn: 54528
* Clean up the use of static and anonymous namespaces. This turned upDan Gohman2008-05-131-0/+4
| | | | | | | several things that were neither in an anonymous namespace nor static but not intended to be global. llvm-svn: 51017
* Add assert.Devang Patel2008-05-021-0/+1
| | | | llvm-svn: 50596
OpenPOWER on IntegriCloud