84 Commits

Author SHA1 Message Date
Alina Sbirlea
831fe3501a [MemorySSA] Update MSSA for non-conventional AA.
Summary:
Regularly when moving an instruction that may not read or write memory,
the instruction is not modelled in MSSA, so not action is necessary.
For a non-conventional AA pipeline, MSSA needs to explicitly check when
creating accesses, so as to not model instructions that may not read and
write memory.

Reviewers: george.burgess.iv

Subscribers: Prazek, sanjoy.google, llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D67562

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@372137 91177308-0d34-0410-b5e6-96231b3b80d8
2019-09-17 16:31:37 +00:00
Alina Sbirlea
ad040616ee [MemorySSA] Do not create memoryaccesses for debug info intrinsics.
Summary:
Do not model debuginfo intrinsics in MemorySSA.
Regularly these are non-memory modifying instructions. With -disable-basicaa, they were being modelled as Defs.

Reviewers: george.burgess.iv

Subscribers: aprantl, Prazek, sanjoy.google, llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D67307

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@371565 91177308-0d34-0410-b5e6-96231b3b80d8
2019-09-10 22:35:27 +00:00
Alina Sbirlea
a80dd84fa7 [MemorySSA] Re-enable MemorySSA use.
Differential Revision: https://reviews.llvm.org/D58311

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@370957 91177308-0d34-0410-b5e6-96231b3b80d8
2019-09-04 19:16:04 +00:00
Philip Reames
8c4f5a3e13 [NFC] Switch last couple of invariant_load checks to use hasMetadata
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@370948 91177308-0d34-0410-b5e6-96231b3b80d8
2019-09-04 18:27:31 +00:00
Alina Sbirlea
cfef9f7696 [MemorySSA] Move two verify calls under expensive checks.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@370831 91177308-0d34-0410-b5e6-96231b3b80d8
2019-09-04 00:44:54 +00:00
Alina Sbirlea
1107a9c994 [MemorySSA] Disable MemorySSA use.
Differential Revision: https://reviews.llvm.org/D58311

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@370821 91177308-0d34-0410-b5e6-96231b3b80d8
2019-09-03 21:20:46 +00:00
Alina Sbirlea
2d29c4b651 [MemorySSA] Re-enable MemorySSA use.
Differential Revision: https://reviews.llvm.org/D58311

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@370811 91177308-0d34-0410-b5e6-96231b3b80d8
2019-09-03 19:28:37 +00:00
Alina Sbirlea
07dc5eb5e1 [MemorySSA] Rename all phi entries.
When renaming Phis incoming values, there may be multiple edges incoming
from the same block (switch). Rename all.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@370548 91177308-0d34-0410-b5e6-96231b3b80d8
2019-08-30 23:02:53 +00:00
Alina Sbirlea
5f29c3f582 Revert enabling MemorySSA.
Breaks sanitizers bots.

Differential Revision: https://reviews.llvm.org/D58311

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@370397 91177308-0d34-0410-b5e6-96231b3b80d8
2019-08-29 19:01:23 +00:00
Alina Sbirlea
419c1269a6 [MemorySSA & LoopPassManager] Enable MemorySSA as loop dependency. Update tests.
Summary:
I'm not planning to check this in at the moment, but feedback is very welcome, in particular how this affects performance.
The feedback obtains here will guide the next steps towards enabling this.

This patch enables the use of MemorySSA in the loop pass manager.

Passes that currently use MemorySSA:
 - EarlyCSE
Passes that use MemorySSA after this patch:
 - EarlyCSE
 - LICM
 - SimpleLoopUnswitch
Loop passes that update MemorySSA (and do not use it yet, but could use it after this patch):
 - LoopInstSimplify
 - LoopSimplifyCFG
 - LoopUnswitch
 - LoopRotate
 - LoopSimplify
 - LCSSA
Loop passes that do *not* update MemorySSA:
 - IndVarSimplify
 - LoopDelete
 - LoopIdiom
 - LoopSink
 - LoopUnroll
 - LoopInterchange
 - LoopUnrollAndJam
 - LoopVectorize
 - LoopReroll
 - IRCE

Reviewers: chandlerc, george.burgess.iv, davide, sanjoy, gberry

Subscribers: jlebar, Prazek, dmgreen, jdoerfert, llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D58311

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@370384 91177308-0d34-0410-b5e6-96231b3b80d8
2019-08-29 17:08:13 +00:00
Alina Sbirlea
40282b9a13 [MemorySSA] Rename uses when inserting memory uses.
Summary:
When inserting uses from outside the MemorySSA creation, we don't
normally need to rename uses, based on the assumption that there will be
no inserted Phis (if  Def existed that required a Phi, that Phi already
exists). However, when dealing with unreachable blocks, MemorySSA will
optimize away Phis whose incoming blocks are unreachable, and these Phis end
up being re-added when inserting a Use.
There are two potential solutions here:
1. Analyze the inserted Phis and clean them up if they are unneeded
(current method for cleaning up trivial phis does not cover this)
2. Leave the Phi in place and rename uses, the same way as whe inserting
defs.
This patch use approach 2.

Resolves first test in PR42940.

Reviewers: george.burgess.iv

Subscribers: Prazek, sanjoy.google, llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D66033

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@369291 91177308-0d34-0410-b5e6-96231b3b80d8
2019-08-19 18:57:40 +00:00
Alina Sbirlea
88ca570919 [MemorySSA] Remove restrictive asserts.
The verification I added has overly restrictive asserts.
Unreachable blocks can have any incoming value in practice, after an
update due to a "replaceAllUses" call when the repalced entry is
LiveOnEntry.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@369050 91177308-0d34-0410-b5e6-96231b3b80d8
2019-08-15 21:20:08 +00:00
Jonas Devlieghere
114087caa6 [llvm] Migrate llvm::make_unique to std::make_unique
Now that we've moved to C++14, we no longer need the llvm::make_unique
implementation from STLExtras.h. This patch is a mechanical replacement
of (hopefully) all the llvm::make_unique instances across the monorepo.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@369013 91177308-0d34-0410-b5e6-96231b3b80d8
2019-08-15 15:54:37 +00:00
Alina Sbirlea
d44a8316ba [MemorySSA] Add additional verification for phis.
Summary:
Verify that the incoming defs into phis are the last defs from the
respective incoming blocks.
When moving blocks, insertDef must RenameUses. Adding this verification
makes GVNHoist tests fail that uncovered this issue.

Reviewers: george.burgess.iv

Subscribers: jlebar, Prazek, llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D63147

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@367451 91177308-0d34-0410-b5e6-96231b3b80d8
2019-07-31 17:41:04 +00:00
Alina Sbirlea
803bdc7051 [MemorySSA] Extend allowed behavior for simplified instructions.
Summary:
LoopRotate may simplify instructions, leading to the new instructions not having memory accesses created for them.
Allow this behavior, by allowing the new access to be null when the template is null, and looking upwards for the proper defined access when dealing with simplified instructions.

Reviewers: george.burgess.iv

Subscribers: jlebar, Prazek, llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D65338

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@367352 91177308-0d34-0410-b5e6-96231b3b80d8
2019-07-30 20:10:33 +00:00
Alina Sbirlea
15bfdc5aa5 [MemorySSA] Check that block is reachable when adding phis.
Summary:
Originally the insertDef method was only used when building MemorySSA, and was limiting the number of Phi nodes that it created.
Now it's used for updates as well, and it can create additional Phis needed for correctness.
Make sure no Phis are created in unreachable blocks (condition met during MSSA build), otherwise the renamePass will find a null DTNode.

Resolves PR41640.

Reviewers: george.burgess.iv

Subscribers: jlebar, Prazek, llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D61410

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@359845 91177308-0d34-0410-b5e6-96231b3b80d8
2019-05-02 23:41:58 +00:00
Alina Sbirlea
c049743f98 [MemorySSA] Invalidate MemorySSA if AA or DT are invalidated.
Summary:
MemorySSA keeps internal pointers of AA and DT.
If these get invalidated, so should MemorySSA.

Reviewers: george.burgess.iv, chandlerc

Subscribers: jlebar, Prazek, llvm-commits

Tags: LLVM

Differential Revision: https://reviews.llvm.org/D61043

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@359627 91177308-0d34-0410-b5e6-96231b3b80d8
2019-04-30 22:43:55 +00:00
Simon Pilgrim
883da93f67 Revert rL359519 : [MemorySSA] Invalidate MemorySSA if AA or DT are invalidated.
Summary:
MemorySSA keeps internal pointers of AA and DT.
If these get invalidated, so should MemorySSA.

Reviewers: george.burgess.iv, chandlerc

Subscribers: jlebar, Prazek, llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D61043
........
This was causing windows build bot failures

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@359555 91177308-0d34-0410-b5e6-96231b3b80d8
2019-04-30 12:34:21 +00:00
Alina Sbirlea
a47aa18633 [MemorySSA] Invalidate MemorySSA if AA or DT are invalidated.
Summary:
MemorySSA keeps internal pointers of AA and DT.
If these get invalidated, so should MemorySSA.

Reviewers: george.burgess.iv, chandlerc

Subscribers: jlebar, Prazek, llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D61043

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@359519 91177308-0d34-0410-b5e6-96231b3b80d8
2019-04-29 23:53:04 +00:00
Alina Sbirlea
a7a3e6435d [MemorySSA] LCSSA preserves MemorySSA.
Summary:
Enabling MemorySSA in the old pass manager leads to MemorySSA being run
twice due to the fact that LCSSA and LoopSimplify do not preserve
MemorySSA. This is the first step to address that: target LCSSA.

LCSSA does not make any changes that invalidate MemorySSA, so it
preserves it by design. It must preserve AA as well, for this to hold.

After this patch, MemorySSA is still run twice in the old pass manager.
Step two follows: target LoopSimplify.

Subscribers: mehdi_amini, jlebar, Prazek, llvm-commits, george.burgess.iv, chandlerc

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D60832

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@359032 91177308-0d34-0410-b5e6-96231b3b80d8
2019-04-23 20:59:44 +00:00
Alina Sbirlea
509313a401 [MemorySSA] Small fix for the clobber limit.
Summary:
After introducing the limit for clobber walking, `walkToPhiOrClobber` would assert that the limit is at least 1 on entry.
The test included triggered that assert.

The callsite in `tryOptimizePhi` making the calls to `walkToPhiOrClobber` is structured like this:
```
while (true) {
   if (getBlockingAccess()) { // calls walkToPhiOrClobber
   }
   for (...) {
     walkToPhiOrClobber();
   }
}
```

The cleanest fix is to check if the limit was reached inside `walkToPhiOrClobber`, and give an allowence of 1.
This approach not make any alias() calls (no calls to instructionClobbersQuery), so the performance condition is enforced.
The limit is set back to 0 if not used, as this provides info on the fact that we stopped before reaching a true clobber.

Reviewers: george.burgess.iv

Subscribers: jlebar, Prazek, llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D60479

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@358303 91177308-0d34-0410-b5e6-96231b3b80d8
2019-04-12 18:48:46 +00:00
Alina Sbirlea
d266d2b04f [MemorySSA] Temporary fix assert when reaching 0 limit.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@357327 91177308-0d34-0410-b5e6-96231b3b80d8
2019-03-29 22:55:59 +00:00
Alina Sbirlea
714da7944c [MemorySSA] Limit clobber walks.
Summary: This patch limits all getClobberingMemoryAccess() walks to MaxCheckLimit.

Reviewers: george.burgess.iv

Subscribers: sanjoy, jlebar, Prazek, llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D59569

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@357319 91177308-0d34-0410-b5e6-96231b3b80d8
2019-03-29 21:56:09 +00:00
Hans Wennborg
6e821f0151 Fix the build with GCC 4.8 after r356783
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@356875 91177308-0d34-0410-b5e6-96231b3b80d8
2019-03-25 09:27:42 +00:00
Alina Sbirlea
5bfa50e0ac [AliasAnalysis] Second prototype to cache BasicAA / anyAA state.
Summary:
Adding contained caching to AliasAnalysis. BasicAA is currently the only one using it.

AA changes:
- This patch is pulling the caches from BasicAAResults to AAResults, meaning the getModRefInfo call benefits from the IsCapturedCache as well when in "batch mode".
- All AAResultBase implementations add the QueryInfo member to all APIs. AAResults APIs maintain wrapper APIs such that all alias()/getModRefInfo call sites are unchanged.
- AA now provides a BatchAAResults type as a wrapper to AAResults. It keeps the AAResults instance and a QueryInfo instantiated to batch mode. It delegates all work to the AAResults instance with the batched QueryInfo. More API wrappers may be needed in BatchAAResults; only the minimum needed is currently added.

MemorySSA changes:
- All walkers are now templated on the AA used (AliasAnalysis=AAResults or BatchAAResults).
- At build time, we optimize uses; now we create a local walker (lives only as long as OptimizeUses does) using BatchAAResults.
- All Walkers have an internal AA and only use that now, never the AA in MemorySSA. The Walkers receive the AA they will use when built.

- The walker we use for queries after the build is instantiated on AliasAnalysis and is built after building MemorySSA and setting AA.
- All static methods doing walking are now templated on AliasAnalysisType if they are used both during build and after. If used only during build, the method now only takes a BatchAAResults. If used only after build, the method now takes an AliasAnalysis.

Subscribers: sanjoy, arsenm, jvesely, nhaehnle, jlebar, george.burgess.iv, llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D59315

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@356783 91177308-0d34-0410-b5e6-96231b3b80d8
2019-03-22 17:22:19 +00:00
George Burgess IV
75a7ab03dc [MSSA] Delete move ctor; remove dynamic never-moved verification
Code archaeology in D59315 revealed that MSSA should never be moved.
Rather than trying to check dynamically that this hasn't happened in the
verify() functions of Walkers, it's likely best to just delete its move
constructor.

Since all these verify() functions did is check that MSSA hasn't moved,
this allows us to remove these verify functions.

I can readd the verification checks if someone's super concerned about
us trying to `memcpy` MemorySSA or something somewhere, but I imagine we
have other problems if we're trying anything like that...


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@356641 91177308-0d34-0410-b5e6-96231b3b80d8
2019-03-21 03:11:34 +00:00
Alina Sbirlea
f63ee9026b [MemorySSA] Remove redundant walker assignment [NFC].
Subscribers: llvm-commits

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@356189 91177308-0d34-0410-b5e6-96231b3b80d8
2019-03-14 18:45:17 +00:00
Alina Sbirlea
e15e0ec30e [MemorySSA] Remove verifyClobberSanity.
Summary:
This verification may fail after certain transformations due to
BasicAA's fragility. Added a small explanation and a testcase that
triggers the assert in checkClobberSanity (before its removal).
Addresses PR40509.

Reviewers: george.burgess.iv

Subscribers: sanjoy, jlebar, llvm-commits, Prazek

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D57973

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@353739 91177308-0d34-0410-b5e6-96231b3b80d8
2019-02-11 19:51:21 +00:00
Chandler Carruth
6b547686c5 Update the file headers across all of the LLVM projects in the monorepo
to reflect the new license.

We understand that people may be surprised that we're moving the header
entirely to discuss the new license. We checked this carefully with the
Foundation's lawyer and we believe this is the correct approach.

Essentially, all code in the project is now made available by the LLVM
project under our new license, so you will see that the license headers
include that license only. Some of our contributors have contributed
code under our old license, and accordingly, we have retained a copy of
our old license notice in the top-level files in each project and
repository.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@351636 91177308-0d34-0410-b5e6-96231b3b80d8
2019-01-19 08:50:56 +00:00
Alina Sbirlea
3c10eaa3db [MemorySSA] Disable checkClobberSanity for SkipSelfWalker.
Sanity will fail for this, since we're exploring getting a clobber
further than the sanity check expects.
Ideally we need to teach the sanity check to differentiate between the
two walkers based on the SkipSelf bool in the query.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@350895 91177308-0d34-0410-b5e6-96231b3b80d8
2019-01-10 21:47:15 +00:00
Alina Sbirlea
2c6b4b6760 [MemorySSA] Add SkipSelfWalker.
Summary: Add implementation of SkipSelfWalker.

Reviewers: george.burgess.iv

Subscribers: sanjoy, jlebar, Prazek, llvm-commits

Differential Revision: https://reviews.llvm.org/D56285

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@350561 91177308-0d34-0410-b5e6-96231b3b80d8
2019-01-07 19:38:47 +00:00
Alina Sbirlea
8ed7a6f257 [MemorySSA] Refactor CachingWalker.
Summary:
Refactor caching walker to make creating a walker that skips the
starting access strightforward.

Reviewers: george.burgess.iv

Subscribers: sanjoy, jlebar, Prazek, llvm-commits, jfb

Differential Revision: https://reviews.llvm.org/D55957

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@350558 91177308-0d34-0410-b5e6-96231b3b80d8
2019-01-07 19:22:37 +00:00
Alina Sbirlea
aed2d64e3d [MemorySSA] Extend the clobber walker with the option to skip the starting access.
Summary:
The option enables loop transformations to hoist accesses that do not
have clobbers in the loop. If the clobber queries skips the starting
access, the result may be outside the loop instead of the header Phi.

Adding the walker that uses this option in a separate patch.

Reviewers: george.burgess.iv

Subscribers: sanjoy, jlebar, Prazek, llvm-commits

Differential Revision: https://reviews.llvm.org/D55944

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@350551 91177308-0d34-0410-b5e6-96231b3b80d8
2019-01-07 18:40:27 +00:00
Chandler Carruth
81aa712273 [CallSite removal] Migrate all Alias Analysis APIs to use the newly
minted `CallBase` class instead of the `CallSite` wrapper.

This moves the largest interwoven collection of APIs that traffic in
`CallSite`s. While a handful of these could have been migrated with
a minorly more shallow migration by converting from a `CallSite` to
a `CallBase`, it hardly seemed worth it. Most of the APIs needed to
migrate together because of the complex interplay of AA APIs and the
fact that converting from a `CallBase` to a `CallSite` isn't free in its
current implementation.

Out of tree users of these APIs can fairly reliably migrate with some
combination of `.getInstruction()` on the `CallSite` instance and
casting the resulting pointer. The most generic form will look like `CS`
-> `cast_or_null<CallBase>(CS.getInstruction())` but in most cases there
is a more elegant migration. Hopefully, this migrates enough APIs for
users to fully move from `CallSite` to the base class. All of the
in-tree users were easily migrated in that fashion.

Thanks for the review from Saleem!

Differential Revision: https://reviews.llvm.org/D55641

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@350503 91177308-0d34-0410-b5e6-96231b3b80d8
2019-01-07 05:42:51 +00:00
Alina Sbirlea
39400df207 [MemorySSA] Create query after checking if instruction is a fence.
The alternative is checking if I is a fence in the Query constructor, so
as to not attempt to get a non-existent MemoryLocation.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@346798 91177308-0d34-0410-b5e6-96231b3b80d8
2018-11-13 21:12:49 +00:00
Vitaly Buka
05252670a6 [cxx2a] Fix warning triggered by r343285
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@343369 91177308-0d34-0410-b5e6-96231b3b80d8
2018-09-29 02:17:12 +00:00
Alina Sbirlea
bcb266e40d API to update MemorySSA for cloned blocks and added CFG edges.
Summary:
End goal is to update MemorySSA in all loop passes. LoopUnswitch clones all blocks in a loop. SimpleLoopUnswitch clones some blocks. LoopRotate clones some instructions.
Some of these loop passes also make CFG changes.
This is an API based on what I found needed in LoopUnswitch, SimpleLoopUnswitch, LoopRotate, LoopInstSimplify, LoopSimplifyCFG.
Adding dependent patches using this API for context.

Reviewers: george.burgess.iv, dberlin

Subscribers: sanjoy, jlebar, Prazek, llvm-commits

Differential Revision: https://reviews.llvm.org/D45299

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@341855 91177308-0d34-0410-b5e6-96231b3b80d8
2018-09-10 20:13:01 +00:00
Alina Sbirlea
68a9873346 [MemorySSA] Relax verification of clobbering accesses.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@341733 91177308-0d34-0410-b5e6-96231b3b80d8
2018-09-07 23:51:41 +00:00
Alina Sbirlea
04e389a200 [MemorySSA] Silence warning.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@340995 91177308-0d34-0410-b5e6-96231b3b80d8
2018-08-29 23:20:29 +00:00
Alina Sbirlea
0bac46f10e [MemorySSA] Fix checkClobberSanity to skip Start only for Defs and Uses.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@340981 91177308-0d34-0410-b5e6-96231b3b80d8
2018-08-29 22:38:51 +00:00
Alina Sbirlea
19135aee74 [MemorySSA] Add expesive check for validating clobber accesses.
Summary: Add validation of clobber accesses as expensive check.

Reviewers: george.burgess.iv

Subscribers: sanjoy, jlebar, Prazek, llvm-commits

Differential Revision: https://reviews.llvm.org/D51327

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@340951 91177308-0d34-0410-b5e6-96231b3b80d8
2018-08-29 18:26:04 +00:00
George Burgess IV
4fcbd6367b [MemorySSA] Add NDEBUG checks to verifiers; NFC
verify*() methods are intended to have no side-effects (unless we detect
broken MSSA, in which case they assert()), and all of the other verify
methods are wrapped by `#ifndef NDEBUG`.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@340793 91177308-0d34-0410-b5e6-96231b3b80d8
2018-08-28 00:32:32 +00:00
George Burgess IV
9e027f8824 [MemorySSA] Invalidate optimized Defs upon moving them; NFC
We're currently getting this behavior implicitly, since we determine if
a Def's optimization is valid based on the ID of its defining access.
This is incorrect, though I wouldn't be surprised if this was masked in
part by that we're using a WeakVH to track what Defs are optimized to.
(Not to mention that we don't move Defs super often, AFAICT). I'll
submit a patch to fix this shortly.

This also includes a minor refactor to reduce duplication a bit.

No test is included, since like said, this already happens to be our
behavior. I'll add a test for this with my fix to the other bug
mentioned above.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@340461 91177308-0d34-0410-b5e6-96231b3b80d8
2018-08-22 22:34:38 +00:00
George Burgess IV
2bd592d05d [MemorySSA] Move two simple getters; NFC
We're calling these functions quite a bit from outside of MemorySSA.cpp
now. Given that they're relatively simple one-liners, I think the style
preference is to have them inline.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@340430 91177308-0d34-0410-b5e6-96231b3b80d8
2018-08-22 18:02:46 +00:00
Alina Sbirlea
41df26a4e5 [MemorySSA] Expose the verify as a debug option.
Summary: Expose VerifyMemorySSA as a debug option. If set, passes will call the MSSA->verifyMemorySSA() after calling into the updater's APIs when MemorySSA should be valid.

Reviewers: george.burgess.iv

Subscribers: sanjoy, jlebar, Prazek, llvm-commits

Differential Revision: https://reviews.llvm.org/D50749

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@339795 91177308-0d34-0410-b5e6-96231b3b80d8
2018-08-15 17:34:55 +00:00
George Burgess IV
3e5777f3b9 [MemorySSA] "Fix" lifetime intrinsic handling
MemorySSA currently creates MemoryAccesses for lifetime intrinsics, and
sometimes treats them as clobbers. This may/may not be the best way
forward, but while we're doing it, we should consider
MayAlias/PartialAlias to be clobbers.

The ideal fix here is probably to remove all of this reasoning about
lifetimes from MemorySSA + put it into the passes that need to care. But
that's a wayyy broader fix that needs some consensus, and we have
miscompiles + a release branch today, and this should solve the
miscompiles just as well.

differential revision is D43269. Landing without an explicit LGTM (and
without using the special please-autoclose-this syntax) so we can still
use that revision as a place to decide what the right fix here is.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@339411 91177308-0d34-0410-b5e6-96231b3b80d8
2018-08-10 05:14:43 +00:00
Alina Sbirlea
9c94a76f7a [MemorySSA] Add APIs to move memory accesses between blocks, following CFG changes.
Summary:
The move APIs added in this patch will be used to update MemorySSA when CFG changes merge or split blocks, by moving memory accesses accordingly in MemorySSA's internal data structures.
[Split from D45299 for easier review]

Reviewers: george.burgess.iv

Subscribers: sanjoy, jlebar, Prazek, llvm-commits

Differential Revision: https://reviews.llvm.org/D48897

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@336860 91177308-0d34-0410-b5e6-96231b3b80d8
2018-07-11 22:11:46 +00:00
Alina Sbirlea
d1ed9d650d [MemorySSA] Add APIs to MemoryPhis to delete incoming blocks/values, and an updater API to remove blocks.
Summary:
MemoryPhis now have APIs analogous to BB Phis to remove an incoming value/block.
The MemorySSAUpdater uses the above APIs when updating MemorySSA given a set of dead blocks about to be deleted.

Reviewers: george.burgess.iv

Subscribers: sanjoy, jlebar, Prazek, llvm-commits

Differential Revision: https://reviews.llvm.org/D48396

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@336015 91177308-0d34-0410-b5e6-96231b3b80d8
2018-06-29 20:46:16 +00:00
George Burgess IV
5804675605 [MSSA] Add domination number verifier; NFC
It's easy for domination numbers to get out-of-date, and this is no more
costly than any of the other verifiers we already have, so it seems nice
to have.

A stage3 build with this Works On My Machine, so this hasn't caught any
bugs... yet. :)


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@335444 91177308-0d34-0410-b5e6-96231b3b80d8
2018-06-25 05:30:36 +00:00
George Burgess IV
78cd292954 [MSSA] Remove incorrect comment + autoify dyn_cast results; NFC
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@335399 91177308-0d34-0410-b5e6-96231b3b80d8
2018-06-22 22:34:07 +00:00