summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms/Scalar/RewriteStatepointsForGC.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* [Statepoint] Clean up Statepoint.h: accessor names.Sanjoy Das2015-05-061-1/+2
| | | | | | Use getFoo() as accessors consistently and some other naming changes. llvm-svn: 236564
* [RewriteStatepointsForGC] Exclude constant values from being considered live ↵Philip Reames2015-04-261-14/+13
| | | | | | | | | | | | at a safepoint There can be various constant pointers in the IR which do not get relocated at a safepoint. One example is the address of a global variable. Another example is a pointer created via inttoptr. Note that the optimizer itself likes to create such inttoptrs when locally propagating constants through dynamically dead code. To deal with this, we need to exclude uses of constants from contributing to the liveness of a safepoint which might reach that use. At some later date, it might be worth exploring what could be done to support the relocation of various special types of "constants", but that's future work. Differential Revision: http://reviews.llvm.org/D9236 llvm-svn: 235821
* [RewriteStatepointsForGC] Delete dead code [NFC]Philip Reames2015-04-141-26/+4
| | | | | | | | | Before we had real liveness, we needed to track every value that base pointer insertion code created because these now might be live. We now just rerun the data flow liveness algorithm (which is actually faster!) and no longer need the associated code. llvm-svn: 234827
* [RwriteStatepointsForGC] Minor indentation and naming [NFC]Philip Reames2015-04-131-39/+30
| | | | | | Use early-return style that's preferred in LLVM and updating the naming in places I touched with other changes in the last few days. Hopefully, NFC. llvm-svn: 234785
* [RewriteStatepointsForGC] Avoid inserting empty holderPhilip Reames2015-04-131-0/+4
| | | | | | We use dummy calls to adjust the liveness of values over statepoints in the midst of the insertion. If there are no values which need held live, there's no point in actually inserting the holder. llvm-svn: 234779
* [RewriteStatepointsForGC] Fix a latent bug in normalization for invoke ↵Philip Reames2015-04-131-37/+40
| | | | | | | | | | statepoint [NFC] Since we're restructuring the CFG, we also need to make sure to update the analsis passes. While I'm touching the code, I dedicided to restructure it a bit. The code involved here was very confusing. This change moves the normalization to essentially being a pre-pass before the main insertion work and updates a few comments to actually say what is happening and *why*. The restructuring should be covered by existing tests. I couldn't easily see how to create a test for the invalidation bug. Suggestions welcome. llvm-svn: 234769
* [RewriteStatepointsForGC] Strengthen assertions around livenessPhilip Reames2015-04-131-0/+18
| | | | | | This is related to the issues addressed in 234651. These assertions check the properties ensured by that change at the place of use. Note that a similiar property is checked in checkBasicSSA, but without the reachability constraint. Technically, the liveness would be correct to include unreachable values, but this would be problematic for actual relocation. llvm-svn: 234766
* [RewriteStatepointsForGC] Move an expensive debugging check to XDEBUGPhilip Reames2015-04-131-33/+44
| | | | | | | | | | The check in question is attempting to help find cases where we haven't relocated a pointer at a safepoint we should have. It does this by coercing the value to null at any safepoint which doesn't relocate it. Unfortunately, this turns out to be rather expensive in terms of memory usage and time. The number of stores inserted can grow with O(number of values x number of statepoints). On at least one example I looked at, over half of peak memory usage was coming from this check. With this change, the check is no longer enabled by default in Asserts builds. It is enabled for expensive asserts builds and has a command line option to enable it in both Asserts and non-Asserts builds. llvm-svn: 234761
* [Statepoints] Fix a release only build failurePhilip Reames2015-04-111-2/+2
| | | | | | A function which is used only in Asserts builds needs to be defined only in Asserts builds. llvm-svn: 234667
* [RewriteStatepointsForGC] Use a SetVector for a worklist [NFC]Philip Reames2015-04-101-6/+4
| | | | | | Using a SetVector to replace equivelent but more verbose functionality. llvm-svn: 234662
* [RewriteStatepointsForGC] Use an actual liveness algorithmPhilip Reames2015-04-101-204/+294
| | | | | | | | When rewriting statepoints to make relocations explicit, we need to have a conservative but consistent notion of where a particular pointer is live at a particular site. The old code just used dominance, which is correct, but decidedly more conservative then it needed to be. This patch implements a simple dataflow algorithm that's run one per function (well, twice counting fixup after base pointer insertion). There's still lots of room to make this faster, but it's fast enough for all practical purposes today. Differential Revision: http://reviews.llvm.org/D8674 llvm-svn: 234657
* [RewriteStatepointsForGC] clang-format filePhilip Reames2015-04-101-58/+57
| | | | | | Format the entire file to reduce diff of change to follow. llvm-svn: 234656
* [RewriteStatepointsForGC] Missed review comment from 234651 & build fixPhilip Reames2015-04-101-3/+4
| | | | | | After submitting 234651, I noticed I hadn't responded to a review comment by mjacob. This patch addresses that comment and fixes a Release only build problem due to an unused variable. llvm-svn: 234653
* [RewriteStatepointsForGC] Preprocess the IR to remove unreachable blocks and ↵Philip Reames2015-04-101-6/+34
| | | | | | | | | | | | | | | single entry phis Two related small changes: Various dominance based queries about liveness can get confused if we're talking about unreachable blocks. To avoid reasoning about such cases, just remove them before rewriting statepoints. Remove single entry phis (likely left behind by LCSSA) to reduce the number of live values. Both of these are motivated by http://reviews.llvm.org/D8674 which will be submitted shortly. Differential Revision: http://reviews.llvm.org/D8675 llvm-svn: 234651
* [RewriteStatepointsForGC] Limited support for vectors of pointersPhilip Reames2015-04-101-25/+224
| | | | | | | | | | | | This patch adds limited support for inserting explicit relocations when there's a vector of pointers live over the statepoint. This doesn't handle the case where the vector contains a mix of base and non-base pointers; that's future work. The current implementation just scalarizes the vector over the gc.statepoint before doing the explicit rewrite. An alternate approach would be to plumb the vector all the way though the backend lowering, but doing that appears challenging. In particular, the size of the indirect spill slot is currently assumed to be sizeof(pointer) throughout the backend. In practice, this is enough to allow running the SLP and Loop vectorizers before RewriteStatepointsForGC. Differential Revision: http://reviews.llvm.org/D8671 llvm-svn: 234647
* Code cleanup [NFC]Philip Reames2015-03-271-14/+12
| | | | | | The assertion here was more expensive then it needed to be. We're only inserting allocas in the entry block, so we only need to consider ones in the entry block. llvm-svn: 233362
* More code cleanup [NFC]Philip Reames2015-03-271-14/+7
| | | | llvm-svn: 233361
* More code cleanup [NFC]Philip Reames2015-03-271-12/+13
| | | | | | Minor naming, one potentially unsafe cast llvm-svn: 233359
* Code simplification and style cleanupPhilip Reames2015-03-271-97/+36
| | | | | | All the removed assertions are either implied locally by the assert at the top of the function or properties of the verifier. llvm-svn: 233358
* Make helper functions static.Benjamin Kramer2015-03-091-5/+5
| | | | | | Found by -Wmissing-prototypes. NFC. llvm-svn: 231664
* [RewriteStatepointsForGC] Fix a relocation bug w.r.t values defined by ↵Philip Reames2015-03-041-2/+12
| | | | | | | | | | | | | | | invoke instructions RewriteStatepointsForGC pass emits an alloca for each GC pointer which will be relocated. It then inserts stores after def and all relocations, and inserts loads before each use as well. In the end, mem2reg is used to update IR with relocations in SSA form. However, there is a problem with inserting stores for values defined by invoke instructions. The code didn't expect a def was a terminator instruction, and inserting instructions after these terminators resulted in malformed IR. This patch fixes this problem by handling invoke instructions as a special case. If the def is an invoke instruction, the store will be inserted at the beginning of the normal destination block. Since return value from invoke instruction does not dominate the unwind destination block, no action is needed there. Patch by: Chen Li Differential Revision: http://reviews.llvm.org/D7923 llvm-svn: 231183
* RewriteStatepointsForGC::PhiState: Remove explicit copy ctor in favor of the ↵David Blaikie2015-03-031-3/+0
| | | | | | | | | | | | Rule of Zero The assertion was just checking a class invariant that's pretty easy to verify by inspection (no mutating operations, and the two non-copy ctors already ensure the state is maintained) so remove the explicit copy ctor in favor of the default, thus allowing the use of the default copy assignment operator without hitting the C++11 deprecation here. llvm-svn: 231143
* Revert "Remove the explicit SDNodeIterator::operator= in favor of the ↵David Blaikie2015-03-031-1/+0
| | | | | | | | | | | implicit default" Accidentally committed a few more of these cleanup changes than intended. Still breaking these out & tidying them up. This reverts commit r231135. llvm-svn: 231136
* Remove the explicit SDNodeIterator::operator= in favor of the implicit defaultDavid Blaikie2015-03-031-0/+1
| | | | | | | | | | There doesn't seem to be any need to assert that iterator assignment is between iterators over the same node - if you want to reuse an iterator variable to iterate another node, that's perfectly acceptable. Just don't mix comparisons between iterators into disjoint sequences, as usual. llvm-svn: 231135
* Silence variable set but not used warning, NFC.Yaron Keren2015-02-281-2/+3
| | | | llvm-svn: 230848
* [RewriteStatepointsForGC] Reduce indentation via early continue [NFC]Philip Reames2015-02-281-81/+82
| | | | llvm-svn: 230836
* [RewriteStatepointsForGC] Fix another order of iteration bugPhilip Reames2015-02-281-4/+20
| | | | | | | | | | | | It turns out the naming of inserted phis and selects is sensative to the order in which two sets are iterated. We need to nail this down to avoid non-deterministic output and possible test failures. The modified test is the one I first noticed something odd in. The change is making it more strict to report the error. With the test change, but without the code change, the test fails roughly 1 in 5. With the code change, I've run ~30 runs without error. Long term, the right fix here is to adjust the naming scheme. I'm checking in this hack to avoid any possible non-determinism in the tests over the weekend. HJust because I only noticed one case doesn't mean it's actually the only case. I hope to get to the right change Monday. std->llvm data structure changes bugfix change #3 llvm-svn: 230835
* [RewriteStatepointsForGC] Reduce indentation via early continue [NFC]Philip Reames2015-02-281-35/+36
| | | | llvm-svn: 230829
* [RewriteStatepointsForGC] Fix iterator invalidation bugPhilip Reames2015-02-281-2/+11
| | | | | | | | Inserting into a DenseMap you're iterating over is not well defined. This is unfortunate since this is well defined on a std::map. "cleanup per llvm code style standards" bug #2 llvm-svn: 230827
* [RewriteStatepointsForGC] Add tests for the base pointer identification ↵Philip Reames2015-02-281-2/+11
| | | | | | | | | | | | algorithm These tests cover the 'base object' identification and rewritting portion of RewriteStatepointsForGC. These aren't completely exhaustive, but they've proven to be reasonable effective over time at finding regressions. In the process of porting these tests over, I found my first "cleanup per llvm code style standards" bug. We were relying on the order of iteration when testing the base pointers found for a derived pointer. When we switched from std::set to DenseSet, this stopped being a safe assumption. I'm suspecting I'm going to find more of those. In particular, I'm now really wondering about the main iteration loop for this algorithm. I need to go take a closer look at the assumptions there. I'm not really happy with the fact these are testing what is essentially debug output (i.e. enabled via command line flags). Suggestions for how to structure this better are very welcome. llvm-svn: 230818
* Roll condition into an assert then wrap it 'ifndef NDEBUG' to protect from ↵David Blaikie2015-02-221-8/+7
| | | | | | the inevitable "unused variable" warning in a non-asserts build. llvm-svn: 230181
* RewriteStatepointsForGC.cpp: Fix for -Asserts to mark isNullConstant() as ↵NAKAMURA Takumi2015-02-221-1/+1
| | | | | | LLVM_ATTRIBUTE_UNUSED. [-Wunused-function] llvm-svn: 230169
* RewriteStatepointsForGC.cpp: Fix for -Asserts. [-Wunused-variable]NAKAMURA Takumi2015-02-221-2/+1
| | | | llvm-svn: 230168
* Remove some unnecessary unreachables in favor of (sometimes implicit) assertionsDavid Blaikie2015-02-201-53/+34
| | | | | | | Also simplify some else-after-return cases including some standard algorithm convenience/use. llvm-svn: 230094
* [RewriteStatepointsForGC] Use DenseSet in place of std::set [NFC]Philip Reames2015-02-201-8/+8
| | | | | | This should be the last cleanup on non-llvm preferred data structures. I left one use of std::set in an assertion; DenseSet didn't seem to have a tombstone for CallSite defined. That might be worth fixing, but wasn't worth it for a debug only use. llvm-svn: 230084
* [RewriteStatepointsForGC] Replace std::map with DenseMapPhilip Reames2015-02-201-2/+2
| | | | | | I'd done the work of extracting the typedef in a previous commit, but didn't actually change it. Hopefully this will make any subtle changes easier to isolate. llvm-svn: 230081
* [RewriteStatepointsForGC] Cleanup - replace std::vector usage [NFC]Philip Reames2015-02-201-40/+38
| | | | | | Migrate std::vector usage to a combination of SmallVector and ArrayRef. llvm-svn: 230079
* [RewriteStatepointsForGC] More style cleanup [NFC]Philip Reames2015-02-201-15/+14
| | | | | | Use llvm_unreachable where appropriate, use SmallVector where easy to do so, introduce typedefs for planned type migrations. llvm-svn: 230068
* [RewriteStatepointsForGC] Remove notion of SafepointBounds [NFC]Philip Reames2015-02-201-49/+11
| | | | | | The notion of a range of inserted safepoint related code is no longer really applicable. This survived over from an earlier implementation. Just saving the inserted gc.statepoint and working from that is far clearer given the current code structure. Particularly when invokable statepoints get involved. llvm-svn: 230063
* [GC, RewriteStatepointsForGC] Style cleanup and bug fixPhilip Reames2015-02-201-9/+29
| | | | | | | | When doing style cleanup, I noticed a minor bug in this code. If we have a pointer that we think is unused after a statepoint and thus doesn't need relocation, we store a null pointer into the alloca we're about to promote. This helps turn a mistake in liveness analysis into an easily debuggable crash. It turned out this code had never been updated to handle invoke statepoints. There's no test for this. Without a bug in liveness, it appears impossible to make this trigger in a way which is visible in the resulting IR. We might store the null, but when promoting the alloca, there will be no uses and thus nothing to test against. Suggestions on how to test are very welcome. llvm-svn: 230047
* Use unreachable instead of assert(false) to silence MSVC warningReid Kleckner2015-02-201-1/+1
| | | | llvm-svn: 230045
* [GC] Style cleanup for RewriteStatepointForGC (1 of many) [NFC]Philip Reames2015-02-201-62/+55
| | | | | | Starting to update variable naming and types to match LLVM style. This will be an incremental process to minimize the chance of breakage as I work. Step one, rename member variables to LLVM CamelCase and use llvm's ADT. Much more to come. llvm-svn: 230042
* Bugfix for 229954Philip Reames2015-02-201-2/+5
| | | | | | Before calling Function::getGC to test for enablement, we need to make sure there's actually a GC at all via Function::hasGC. Otherwise, we'd crash on functions without a GC. Thankfully, this only mattered if you manually scheduled the pass, but still, oops. :( llvm-svn: 230040
* RewriteStatepointsForGC: Move details into anonymous namespaces. NFC.Benjamin Kramer2015-02-201-10/+12
| | | | | | While there reduce the number of duplicated std::map lookups. llvm-svn: 230012
* Wrap recursive function only used in assert in #ifndef NDEBUG.Benjamin Kramer2015-02-201-1/+5
| | | | | | Avoids unused function warnings in Release builds. llvm-svn: 230009
* Fix build in release mode, four cases of -Wunused-variable.Nick Lewycky2015-02-201-0/+5
| | | | llvm-svn: 229976
* Adjust enablement of RewriteStatepointsForGCPhilip Reames2015-02-201-1/+2
| | | | | | | | When back merging the changes in 229945 I noticed that I forgot to mark the test cases with the appropriate GC. We want the rewriting to be off by default (even when manually added to the pass order), not on-by default. To keep the current test working, mark them as using the statepoint-example GC and whitelist that GC. Longer term, we need a better selection mechanism here for both actual usage and testing. As I migrate more tests to the in tree version of this pass, I will probably need to update the enable/disable logic as well. llvm-svn: 229954
* Add a pass for constructing gc.statepoint sequences w/explicit relocationsPhilip Reames2015-02-201-0/+1931
This patch consists of a single pass whose only purpose is to visit previous inserted gc.statepoints which do not have gc.relocates inserted yet, and insert them. This can be used either immediately after IR generation to perform 'early safepoint insertion' or late in the pass order to perform 'late insertion'. This patch is setting the stage for work to continue in tree. In particular, there are known naming and style violations in the current patch. I'll try to get those resolved over the next week or so. As I touch each area to make style changes, I need to make sure we have adequate testing in place. As part of the cleanup, I will be cleaning up a collection of test cases we have out of tree and submitting them upstream. The tests included in this change are very basic and mostly to provide examples of usage. The pass has several main subproblems it needs to address: - First, it has identify any live pointers. In the current code, the use of address spaces to distinguish pointers to GC managed objects is hard coded, but this will become parametrizable in the near future. Note that the current change doesn't actually contain a useful liveness analysis. It was seperated into a followup change as the code wasn't ready to be shared. Instead, the current implementation just considers any dominating def of appropriate pointer type to be live. - Second, it has to identify base pointers for each live pointer. This is a fairly straight forward data flow algorithm. - Third, the information in the previous steps is used to actually introduce rewrites. Rather than trying to do this by hand, we simply re-purpose the code behind Mem2Reg to do this for us. llvm-svn: 229945
OpenPOWER on IntegriCloud