9245 Commits

Author SHA1 Message Date
Nikita Popov
61d184be59 [ConstantRange] Add getFull() + getEmpty() named constructors; NFC
This adds ConstantRange::getFull(BitWidth) and
ConstantRange::getEmpty(BitWidth) named constructors as more readable
alternatives to the current ConstantRange(BitWidth, /* full */ false)
and similar. Additionally private getFull() and getEmpty() member
functions are added which return a full/empty range with the same bit
width -- these are commonly needed inside ConstantRange.cpp.

The IsFullSet argument in the ConstantRange(BitWidth, IsFullSet)
constructor is now mandatory for the few usages that still make use of it.

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@356852 91177308-0d34-0410-b5e6-96231b3b80d8
2019-03-24 09:34:40 +00:00
Daniel Sanders
b1aec70893 Fix non-determinism in Reassociate caused by address coincidences
Summary:
Between building the pair map and querying it there are a few places that
erase and create Values. It's rare but the address of these newly created
Values is occasionally the same as a just-erased Value that we already
have in the pair map. These coincidences should be accounted for to avoid
non-determinism.

Thanks to Roman Tereshin for the test case.

Reviewers: rtereshin, bogner

Reviewed By: rtereshin

Subscribers: mgrang, llvm-commits

Tags: #llvm

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


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@356803 91177308-0d34-0410-b5e6-96231b3b80d8
2019-03-22 20:16:35 +00:00
Simon Pilgrim
4d12ab485a Fix -Wmisleading-indentation gcc7 warning. NFCI.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@356658 91177308-0d34-0410-b5e6-96231b3b80d8
2019-03-21 11:58:22 +00:00
Mikael Holmen
a182adac95 Silence warning about unused variable in builds without asserts [NFC]
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@356648 91177308-0d34-0410-b5e6-96231b3b80d8
2019-03-21 07:54:44 +00:00
Alina Sbirlea
7201b5f868 [NFC] Fix brace indentation.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@356596 91177308-0d34-0410-b5e6-96231b3b80d8
2019-03-20 19:18:55 +00:00
Alina Sbirlea
906007f75a [LICM & MemorySSA] Don't sink/hoist stores in the presence of ordered loads.
Summary:
Before this patch, if any Use existed in the loop, with a defining
access in the loop, we conservatively decide to not move the store.
What this approach was missing, is that ordered loads are not Uses, they're Defs
in MemorySSA. So, even when the clobbering walker does not find that
volatile load to interfere, we still cannot hoist a store past a
volatile load.
Resolves PR41140.

Reviewers: george.burgess.iv

Subscribers: sanjoy, jlebar, Prazek, llvm-commits

Tags: #llvm

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@356588 91177308-0d34-0410-b5e6-96231b3b80d8
2019-03-20 18:33:37 +00:00
Florian Hahn
f75dbeb8e7 [LSR] Check for signed overflow in NarrowSearchSpaceByDetectingSupersets.
We are adding a sign extended IR value to an int64_t, which can cause
signed overflows, as in the attached test case, where we have a formula
with BaseOffset = -1 and a constant with numeric_limits<int64_t>::min().

If the addition would overflow, skip the simplification for this
formula. Note that the target triple is required to trigger the failure.

Reviewers: qcolombet, gilr, kparzysz, efriedma

Reviewed By: efriedma

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@356256 91177308-0d34-0410-b5e6-96231b3b80d8
2019-03-15 12:17:36 +00:00
Sam Parker
b425d6d63a Fix for buildbots
Remove unused private field.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@356135 91177308-0d34-0410-b5e6-96231b3b80d8
2019-03-14 11:38:55 +00:00
Sam Parker
6273747bc3 [NFC][LSR] Cleanup Cost API
Create members for Loop, ScalarEvolution, DominatorTree,
TargetTransformInfo and Formula.

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


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@356131 91177308-0d34-0410-b5e6-96231b3b80d8
2019-03-14 11:05:07 +00:00
Philip Reames
1ca9798456 [SROA] Fix a crash when trying to convert a memset to an non-integral pointer type
The included test case currently crashes on tip of tree. Rather than adding a bailout, I chose to restructure the code so that the existing helper function could be used. Given that, the majority of the diff is NFC-ish, but the key difference is that canConvertValue returns false when only one side is a non-integral pointer.

Thanks to Cherry Zhang for the test case.

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




git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@355962 91177308-0d34-0410-b5e6-96231b3b80d8
2019-03-12 20:15:05 +00:00
Liang Zou
d2440eb270 [format] \t => ' '
Summary:
1. \t => '  '
2. test commit access

Reviewers: Higuoxing, liangdzou

Reviewed By: Higuoxing, liangdzou

Subscribers: kristina, llvm-commits

Tags: #llvm

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@355924 91177308-0d34-0410-b5e6-96231b3b80d8
2019-03-12 14:48:32 +00:00
Kristina Brooks
5cb331b889 Very minor typo. NFC
Typo `we we're` => `we were` in the pass EarlyCSE

Patch by liangdzou (Liang ZOU)

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



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@355895 91177308-0d34-0410-b5e6-96231b3b80d8
2019-03-12 07:08:19 +00:00
Jeremy Morse
b6c96952b7 [JumpThreading] Retain debug info when replacing branch instructions
Fixes bug 37966: https://bugs.llvm.org/show_bug.cgi?id=37966

The Jump Threading pass will replace certain conditional branch
instructions with unconditional branches when it can prove that only one
branch can occur. Prior to this patch, it would not carry the debug
info from the old instruction to the new one.

This patch fixes the bug described by copying the debug info from the
conditional branch instruction to the new unconditional branch
instruction, and adds a regression test for the Jump Threading pass that
covers this case.

Patch by Stephen Tozer!

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


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@355822 91177308-0d34-0410-b5e6-96231b3b80d8
2019-03-11 11:48:57 +00:00
David Green
8babc52a2b [LSR] Attempt to increase the accuracy of LSR's setup cost
In some loops, we end up generating loop induction variables that look like:
  {(-1 * (zext i16 (%i0 * %i1) to i32))<nsw>,+,1}
As opposed to the simpler:
  {(zext i16 (%i0 * %i1) to i32),+,-1}
i.e we count up from -limit to 0, not the simpler counting down from limit to
0. This is because the scores, as LSR calculates them, are the same and the
second is filtered in place of the first. We end up with a redundant SUB from 0
in the code.

This patch tries to make the calculation of the setup cost a little more
thoroughly, recursing into the scev members to better approximate the setup
required. The cost function for comparing LSR costs is:

return std::tie(C1.NumRegs, C1.AddRecCost, C1.NumIVMuls, C1.NumBaseAdds,
                C1.ScaleCost, C1.ImmCost, C1.SetupCost) <
       std::tie(C2.NumRegs, C2.AddRecCost, C2.NumIVMuls, C2.NumBaseAdds,
                C2.ScaleCost, C2.ImmCost, C2.SetupCost);
So this will only alter results if none of the other variables turn out to be
different.

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


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@355597 91177308-0d34-0410-b5e6-96231b3b80d8
2019-03-07 13:44:40 +00:00
Fangrui Song
00648c2f76 [BDCE] Optimize find+insert with early insert
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@355583 91177308-0d34-0410-b5e6-96231b3b80d8
2019-03-07 06:38:03 +00:00
Sanjay Patel
080999b5bb [ConstantHoisting] avoid hang/crash from unreachable blocks (PR40930)
I'm not too familiar with this pass, so there might be a better
solution, but this appears to fix the degenerate:
PR40930
PR40931
PR40932
PR40934
...without affecting any real-world code.

As we've seen in several other passes, when we have unreachable blocks,
they can contain semi-bogus IR and/or cause unexpected conditions. We
would not typically expect these patterns to make it this far, but we
have to guard against them anyway.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@355337 91177308-0d34-0410-b5e6-96231b3b80d8
2019-03-04 20:57:14 +00:00
Philip Reames
d68ef42919 [LICM] Infer proper alignment from loads during scalar promotion
This patch fixes an issue where we would compute an unnecessarily small alignment during scalar promotion when no store is not to be guaranteed to execute, but we've proven load speculation safety. Since speculating a load requires proving the existing alignment is valid at the new location (see Loads.cpp), we can use the alignment fact from the load.

For non-atomics, this is a performance problem. For atomics, this is a correctness issue, though an *incredibly* rare one to see in practice. For atomics, we might not be able to lower an improperly aligned load or store (i.e. i32 align 1). If such an instruction makes it all the way to codegen, we *may* fail to codegen the operation, or we may simply generate a slow call to a library function. The part that makes this super hard to see in practice is that the memory location actually *is* well aligned, and instcombine knows that. So, to see a failure, you have to have a) hit the bug in LICM, b) somehow hit a depth limit in InstCombine/ValueTracking to avoid fixing the alignment, and c) then have generated an instruction which fails codegen rather than simply emitting a slow libcall. All around, pretty hard to hit.

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



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@355217 91177308-0d34-0410-b5e6-96231b3b80d8
2019-03-01 18:45:05 +00:00
Fangrui Song
b1f04183c4 [ConstantHoisting] Call cleanup() in ConstantHoistingPass::runImpl to avoid dangling elements in ConstIntInfoVec for new PM
Summary:
ConstIntInfoVec contains elements extracted from the previous function.
In new PM, releaseMemory() is not called and the dangling elements can
cause segfault in findConstantInsertionPoint.

Rename releaseMemory() to cleanup() to deliver the idea that it is
mandatory and call cleanup() in ConstantHoistingPass::runImpl to fix
this.

Reviewers: ormris, zzheng, dmgreen, wmi

Reviewed By: ormris, wmi

Subscribers: llvm-commits

Tags: #llvm

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@355174 91177308-0d34-0410-b5e6-96231b3b80d8
2019-03-01 05:27:01 +00:00
Alina Sbirlea
a1d5c6d1e8 [MemorySSA] Make insertDef insert corresponding phi nodes.
Summary:
The original assumption for the insertDef method was that it would not
materialize Defs out of no-where, hence it will not insert phis needed
after inserting a Def.

However, when cloning an instruction (use case used in LICM), we do
materialize Defs "out of no-where". If the block receiving a Def has at
least one other Def, then no processing is needed. If the block just
received its first Def, we must check where Phi placement is needed.
The only new usage of insertDef is in LICM, hence the trigger for the bug.

But the original goal of the method also fails to apply for the move()
method. If we move a Def from the entry point of a diamond to either the
left or right blocks, then the merge block must add a phi.
While this usecase does not currently occur, or may be viewed as an
incorrect transformation, MSSA must behave corectly given the scenario.

Resolves PR40749 and PR40754.

Reviewers: george.burgess.iv

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

Tags: #llvm

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@355040 91177308-0d34-0410-b5e6-96231b3b80d8
2019-02-27 22:20:22 +00:00
Alina Sbirlea
02e42d437e [MemorySSA & SimpleLoopUnswitch] Update MemorySSA in ReplaceUsesOfWith.
SimpleLoopUnswitch must update MemorySSA when removing instructions.
Resolves PR39197.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@354919 91177308-0d34-0410-b5e6-96231b3b80d8
2019-02-26 19:44:52 +00:00
Chijun Sima
0ac04b4ce6 [DTU] Refine the interface and logic of applyUpdates
Summary:
This patch separates two semantics of `applyUpdates`:
1. User provides an accurate CFG diff and the dominator tree is updated according to the difference of `the number of edge insertions` and `the number of edge deletions` to infer the status of an edge before and after the update.
2. User provides a sequence of hints. Updates mentioned in this sequence might never happened and even duplicated.

Logic changes:

Previously, removing invalid updates is considered a side-effect of deduplication and is not guaranteed to be reliable. To handle the second semantic, `applyUpdates` does validity checking before deduplication, which can cause updates that have already been applied to be submitted again. Then, different calls to `applyUpdates` might cause unintended consequences, for example,
```
DTU(Lazy) and Edge A->B exists.
1. DTU.applyUpdates({{Delete, A, B}, {Insert, A, B}}) // User expects these 2 updates result in a no-op, but {Insert, A, B} is queued
2. Remove A->B
3. DTU.applyUpdates({{Delete, A, B}}) // DTU cancels this update with {Insert, A, B} mentioned above together (Unintended)
```
But by restricting the precondition that updates of an edge need to be strictly ordered as how CFG changes were made, we can infer the initial status of this edge to resolve this issue.

Interface changes:
The second semantic of `applyUpdates`  is separated to `applyUpdatesPermissive`.
These changes enable DTU(Lazy) to use the first semantic if needed, which is quite useful in `transforms/utils`.

Reviewers: kuhar, brzycki, dmgreen, grosser

Reviewed By: brzycki

Subscribers: hiraditya, llvm-commits

Tags: #llvm

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@354669 91177308-0d34-0410-b5e6-96231b3b80d8
2019-02-22 13:48:38 +00:00
Alina Sbirlea
d96108c682 [MemorySSA & LoopPassManager] Resolve PR40038.
The correct edge being deleted is not to the unswitched exit block, but to the
original block before it was split. That's the key in the map, not the
value.
The insert is correct. The new edge is to the .split block.

The splitting turns OriginalBB into:
OriginalBB -> OriginalBB.split.
Assuming the orignal CFG edge: ParentBB->OriginalBB, we must now delete
ParentBB->OriginalBB, not ParentBB->OriginalBB.split.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@354656 91177308-0d34-0410-b5e6-96231b3b80d8
2019-02-22 07:18:37 +00:00
Chijun Sima
e9b2f29faf [DTU] Deprecate insertEdge*/deleteEdge*
Summary: This patch converts all existing `insertEdge*/deleteEdge*` to `applyUpdates` and marks `insertEdge*/deleteEdge*` as deprecated.

Reviewers: kuhar, brzycki

Reviewed By: kuhar, brzycki

Subscribers: hiraditya, llvm-commits

Tags: #llvm

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@354652 91177308-0d34-0410-b5e6-96231b3b80d8
2019-02-22 05:41:43 +00:00
Alina Sbirlea
a653fee83b [MemorySSA & LoopPassManager] Update MemorySSA in formDedicatedExitBlocks.
MemorySSA is now updated when forming dedicated exit blocks.
Resolves PR40037.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@354623 91177308-0d34-0410-b5e6-96231b3b80d8
2019-02-21 21:13:34 +00:00
Alina Sbirlea
eacfb8541a [LoopSimplifyCFG] Update MemorySSA after r353911.
Summary:
MemorySSA is not properly updated in LoopSimplifyCFG after recent changes. Use SplitBlock utility to resolve that and clear all updates once handleDeadExits is finished.
All updates that follow are removal of edges which are safe to handle via the removeEdge() API.
Also, deleting dead blocks is done correctly as is, i.e. delete from MemorySSA before updating the CFG and DT.

Reviewers: mkazantsev, rtereshin

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

Tags: #llvm

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@354613 91177308-0d34-0410-b5e6-96231b3b80d8
2019-02-21 19:54:05 +00:00
Alina Sbirlea
924e7815a5 [EarlyCSE] Cleanup deadcode. [NFCI]
Summary: Cleanup nop assignments.

Reviewers: george.burgess.iv, davide

Subscribers: sanjoy, jlebar, llvm-commits

Tags: #llvm

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@354612 91177308-0d34-0410-b5e6-96231b3b80d8
2019-02-21 19:49:57 +00:00
Joey Gouly
94a41692b4 [InferAddressSpaces] Fix fallthrough error
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@354580 91177308-0d34-0410-b5e6-96231b3b80d8
2019-02-21 13:10:37 +00:00
Joey Gouly
1730d3775c [InferAddressSpaces] Fix crash on select of non-ptr operands
Check the operands of a select are pointers, to determine if it is an address
expression or not.

https://reviews.llvm.org/D58226


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@354576 91177308-0d34-0410-b5e6-96231b3b80d8
2019-02-21 12:31:36 +00:00
Max Kazantsev
98a9c14860 [LoopSimplifyCFG] Add missing MSSA edge deletion
When we create fictive switch in preheader, we should take
care about MSSA and delete edge between old preheader and
header.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@354547 91177308-0d34-0410-b5e6-96231b3b80d8
2019-02-21 05:51:29 +00:00
Max Kazantsev
58b987211a [NFC] API for signaling that the current loop is being deleted
We are planning to be able to delete the current loop in LoopSimplifyCFG
in the future. Add API to notify the loop pass manager that it happened.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@354314 91177308-0d34-0410-b5e6-96231b3b80d8
2019-02-19 11:14:05 +00:00
Max Kazantsev
394aa56658 [NFC] Store loop header in a local to keep it available after the loop is deleted
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@354313 91177308-0d34-0410-b5e6-96231b3b80d8
2019-02-19 11:13:58 +00:00
Max Kazantsev
8924ea3d57 [NFC] Teach getInnermostLoopFor walk up the loop trees
This should be NFC in current use case of this method, but it will
help to use it for solving more compex tasks in follow-up patches.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@354227 91177308-0d34-0410-b5e6-96231b3b80d8
2019-02-17 18:21:51 +00:00
Max Kazantsev
281eb93196 [NFC] Fix name and clarifying comment for factored-out function
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@354220 91177308-0d34-0410-b5e6-96231b3b80d8
2019-02-17 15:22:48 +00:00
Max Kazantsev
47fab601df [NFC] Factor out a function for future reuse
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@354218 91177308-0d34-0410-b5e6-96231b3b80d8
2019-02-17 15:04:09 +00:00
Alina Sbirlea
2b63446e67 [EarlyCSE & MSSA] Cap the clobbering calls in EarlyCSE.
Summary:
Unlimitted number of calls to getClobberingAccess can lead to high
compile times in pathological cases.
Limitting getClobberingAccess to a fairly high number. Can be adjusted
based on users/need.
Note: this is the only user of MemorySSA currently enabled by default.
The same handling exists in LICM (disabled atm). As MemorySSA gains more
users, this logic of capping will need to move inside MemorySSA.

Reviewers: george.burgess.iv

Subscribers: llvm-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@354182 91177308-0d34-0410-b5e6-96231b3b80d8
2019-02-15 22:47:54 +00:00
Clement Courbet
a79e97e495 [MergeICmps] Make base ordering really deterministic.
Summary:
The idea is that we now manipulate bases through a `unsigned BaseID` based on
order of appearance in the comparison chain rather than through the `Value*`.

Fixes 40714.

Reviewers: gchatelet

Subscribers: mgrang, jfb, jdoerfert, llvm-commits, hans

Tags: #llvm

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@354131 91177308-0d34-0410-b5e6-96231b3b80d8
2019-02-15 14:17:17 +00:00
Clement Courbet
9b96000bd6 [MergeICmps][NFC] Improve doc.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@354128 91177308-0d34-0410-b5e6-96231b3b80d8
2019-02-15 12:58:06 +00:00
Max Kazantsev
45cd157a1e [NFCI] Factor out block removal from stack of nested loops
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@354124 91177308-0d34-0410-b5e6-96231b3b80d8
2019-02-15 12:18:10 +00:00
Simon Pilgrim
97cf8fa3e7 Fix "field 'DFS' will be initialized after field 'DTU'" warning. NFCI.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@354123 91177308-0d34-0410-b5e6-96231b3b80d8
2019-02-15 12:13:16 +00:00
Max Kazantsev
e45a4d2855 [NFC] Promote DFS to field for further use
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@354118 91177308-0d34-0410-b5e6-96231b3b80d8
2019-02-15 11:39:35 +00:00
Max Kazantsev
f3757f2463 [NFC] Refactor LICM code for better readability
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@354013 91177308-0d34-0410-b5e6-96231b3b80d8
2019-02-14 09:04:12 +00:00
Max Kazantsev
259523f75a [NFC] Add const qualifiers where possible
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@353941 91177308-0d34-0410-b5e6-96231b3b80d8
2019-02-13 11:54:45 +00:00
Max Kazantsev
9f58367558 [GuardWidening] Support widening of explicitly expressed guards
This patch adds support of guards expressed in explicit form via
`widenable_condition` in Guard Widening pass.

Differential Revision: https://reviews.llvm.org/D56075
Reviewed By: reames



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@353932 91177308-0d34-0410-b5e6-96231b3b80d8
2019-02-13 09:56:30 +00:00
Max Kazantsev
9b05819742 [LoopSimplifyCFG] Re-enable const branch folding by default
Known underlying bugs have been fixed, intensive fuzz testing did not
find any new problems. Re-enabling by default. Feel free to revert if
it causes any functional failures.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@353911 91177308-0d34-0410-b5e6-96231b3b80d8
2019-02-13 06:12:48 +00:00
Alina Sbirlea
7c0006da85 [MemorySSA & LoopPassManager] Add remaining book keeping [NFCI].
Add plumbing to get MemorySSA in the remaining loop passes.
Also update unit test to add the dependency.
[EnableMSSALoopDependency remains disabled].

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@353901 91177308-0d34-0410-b5e6-96231b3b80d8
2019-02-12 23:48:02 +00:00
Alina Sbirlea
bb0402417f [LICM] Cap the clobbering calls in LICM.
Summary:
Unlimitted number of calls to getClobberingAccess can lead to high
compile times in pathological cases.
Switching EnableLicmCap flag from bool to int, and enabling to default 100.
(tested to be appropriate for current bechmarks)
We can revisit this value when enabling MemorySSA.

Reviewers: sanjoy, chandlerc, george.burgess.iv

Subscribers: jlebar, llvm-commits

Tags: #llvm

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@353897 91177308-0d34-0410-b5e6-96231b3b80d8
2019-02-12 23:05:40 +00:00
Max Kazantsev
9d1a27061c [IndVars] Fix corner case with unreachable Phi inputs. PR40454
Logic in `getInsertPointForUses` doesn't account for a corner case when `Def`
only comes to a Phi user from unreachable blocks. In this case, the incoming
value may be arbitrary (and not even available in the input block) and break
the loop-related invariants that are asserted below.

In fact, if we encounter this situation, no IR modification is needed. This
Phi will be simplified away with nearest cleanup.

Differential Revision: https://reviews.llvm.org/D58045
Reviewed By: spatel


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@353816 91177308-0d34-0410-b5e6-96231b3b80d8
2019-02-12 09:59:44 +00:00
Max Kazantsev
cfa6c5f00a [LoopSimplifyCFG] Change logic of dead loops removal to avoid hitting asserts
The function `LI.erase` has some invariants that need to be preserved when it
tries to remove a loop which is not the top-level loop. In particular, it
requires loop's preheader to be strictly in loop's parent. Our current logic
of deletion of dead blocks may erase the information about preheader before we
handle the loop, and therefore we may hit this assertion.

This patch changes the logic of loop deletion: we make them top-level loops
before we actually erase them. This allows us to trigger the simple branch of
`erase` logic which just detatches blocks from the loop and does not try to do
some complex stuff that need this invariant.

Thanks to @uabelho for reporting this!

Differential Revision: https://reviews.llvm.org/D57221
Reviewed By: fedor.sergeev


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@353813 91177308-0d34-0410-b5e6-96231b3b80d8
2019-02-12 09:37:00 +00:00
Max Kazantsev
2841bd0ff5 Delete blocks from DTU to avoid dangling pointers
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@353804 91177308-0d34-0410-b5e6-96231b3b80d8
2019-02-12 08:10:29 +00:00
Max Kazantsev
ce2d739dc1 [LoopSimplifyCFG] Pay respect to LCSSA when removing dead blocks
Utility function that we use for blocks deletion always unconditionally removes
one-input Phis. In LoopSimplifyCFG, it can lead to breach of LCSSA form.
This patch alters this function to keep them if needed.

Differential Revision: https://reviews.llvm.org/D57231
Reviewed By: fedor.sergeev


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@353803 91177308-0d34-0410-b5e6-96231b3b80d8
2019-02-12 07:48:07 +00:00