386 Commits

Author SHA1 Message Date
Max Kazantsev
187d9188f7 Re-enable "[NFC] Unify guards detection"
rL340921 has been reverted by rL340923 due to linkage dependency
from Transform/Utils to Analysis which is not allowed. In this patch
this has been fixed, a new utility function moved to Analysis.

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


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@341014 91177308-0d34-0410-b5e6-96231b3b80d8
2018-08-30 03:39:16 +00:00
Hans Wennborg
fc1247272f Revert r340921 "[NFC] Unify guards detection"
This broke the build, see e.g.

http://lab.llvm.org:8011/builders/clang-cmake-armv8-lnt/builds/4626/
http://lab.llvm.org:8011/builders/clang-ppc64be-linux-lnt/builds/18647/
http://lab.llvm.org:8011/builders/clang-cmake-x86_64-avx2-linux/builds/5856/
http://lab.llvm.org:8011/builders/lld-x86_64-freebsd/builds/22800/

> We have multiple places in code where we try to identify whether or not
> some instruction is a guard. This patch factors out this logic into a separate
> utility function which works uniformly in all places.
>
> Differential Revision: https://reviews.llvm.org/D51152
> Reviewed By: fedor.sergeev

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@340923 91177308-0d34-0410-b5e6-96231b3b80d8
2018-08-29 12:21:32 +00:00
Max Kazantsev
68de447e4f [NFC] Unify guards detection
We have multiple places in code where we try to identify whether or not
some instruction is a guard. This patch factors out this logic into a separate
utility function which works uniformly in all places.

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


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@340921 91177308-0d34-0410-b5e6-96231b3b80d8
2018-08-29 11:37:34 +00:00
Chandler Carruth
9179aee2c1 [IR] Replace isa<TerminatorInst> with isTerminator().
This is a bit awkward in a handful of places where we didn't even have
an instruction and now we have to see if we can build one. But on the
whole, this seems like a win and at worst a reasonable cost for removing
`TerminatorInst`.

All of this is part of the removal of `TerminatorInst` from the
`Instruction` type hierarchy.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@340701 91177308-0d34-0410-b5e6-96231b3b80d8
2018-08-26 09:51:22 +00:00
Chandler Carruth
acc248f4ab [IR] Sink isExceptional predicate to Instruction, rename it to
`isExceptionalTermiantor` and implement it for opcodes as well following
the common pattern in `Instruction`.

Part of removing `TerminatorInst` from the `Instruction` type hierarchy
to make it easier to share logic and interfaces between instructions
that are both terminators and not terminators.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@340699 91177308-0d34-0410-b5e6-96231b3b80d8
2018-08-26 08:56:42 +00:00
Florian Hahn
97d7bcd5c0 [Local] Make DoesKMove required for combineMetadata.
This patch makes the DoesKMove argument non-optional, to force people
to think about it. Most cases where it is false are either code hoisting
or code sinking, where we pick one instruction from a set of
equal instructions among different code paths.

Reviewers: dberlin, nlopes, efriedma, davide

Reviewed By: efriedma

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


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@340606 91177308-0d34-0410-b5e6-96231b3b80d8
2018-08-24 11:40:04 +00:00
Chijun Sima
18e311ebbb [Dominators] Convert existing passes and utils to use the DomTreeUpdater class
Summary:
This patch is the second in a series of patches related to the [[ http://lists.llvm.org/pipermail/llvm-dev/2018-June/123883.html | RFC - A new dominator tree updater for LLVM ]].

It converts passes (e.g. adce/jump-threading) and various functions which currently accept DDT in local.cpp and BasicBlockUtils.cpp to use the new DomTreeUpdater class.
These converted functions in utils can accept DomTreeUpdater with either UpdateStrategy and can deal with both DT and PDT held by the DomTreeUpdater.

Reviewers: brzycki, kuhar, dmgreen, grosser, davide

Reviewed By: brzycki

Subscribers: llvm-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@338814 91177308-0d34-0410-b5e6-96231b3b80d8
2018-08-03 05:08:17 +00:00
Michael Zolotukhin
bda51c282f Revert r332168: "Reapply "[PR16756] Use SSAUpdaterBulk in JumpThreading.""
There were a couple of issues reported (PR38047, PR37929) - I'll reland
the patch when I figure out and fix the rootcause.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@336393 91177308-0d34-0410-b5e6-96231b3b80d8
2018-07-05 22:10:31 +00:00
Michael Zolotukhin
d3c8f20a14 [JumpThreading] Don't try to rewrite a use if it's already valid.
Summary:
When recording uses we need to rewrite after cloning a loop we need to
check if the use is not dominated by the original def. The initial
assumption was that the cloned basic block will introduce a new path and
thus the original def will only dominate the use if they are in the same
BB, but as the reproducer from PR37745 shows it's not always the case.

This fixes PR37745.

Reviewers: haicheng, Ka-Ka

Subscribers: hiraditya, llvm-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@335675 91177308-0d34-0410-b5e6-96231b3b80d8
2018-06-26 22:19:48 +00:00
Hiroshi Inoue
26570985ef [NFC] fix trivial typos in comments
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@334687 91177308-0d34-0410-b5e6-96231b3b80d8
2018-06-14 05:41:49 +00:00
David Blaikie
8325fb20d4 Move Analysis/Utils/Local.h back to Transforms
Review feedback from r328165. Split out just the one function from the
file that's used by Analysis. (As chandlerc pointed out, the original
change only moved the header and not the implementation anyway - which
was fine for the one function that was used (since it's a
template/inlined in the header) but not in general)

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@333954 91177308-0d34-0410-b5e6-96231b3b80d8
2018-06-04 21:23:21 +00:00
Craig Topper
714d12718f [JumpThreading] Fix some strange formatting of code inside LLVM_DEBUG. NFC
I don't know if clang-format got confused here or what.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@333675 91177308-0d34-0410-b5e6-96231b3b80d8
2018-05-31 18:08:11 +00:00
Nicola Zaghen
0818e789cb Rename DEBUG macro to LLVM_DEBUG.
The DEBUG() macro is very generic so it might clash with other projects.
The renaming was done as follows:
- git grep -l 'DEBUG' | xargs sed -i 's/\bDEBUG\s\?(/LLVM_DEBUG(/g'
- git diff -U0 master | ../clang/tools/clang-format/clang-format-diff.py -i -p1 -style LLVM
- Manual change to APInt
- Manually chage DOCS as regex doesn't match it.

In the transition period the DEBUG() macro is still present and aliased
to the LLVM_DEBUG() one.

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



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@332240 91177308-0d34-0410-b5e6-96231b3b80d8
2018-05-14 12:53:11 +00:00
Michael Zolotukhin
0daa661eb9 Reapply "[PR16756] Use SSAUpdaterBulk in JumpThreading."
Stage3/stage4 bootstrap miscompares should be fixed by a non-determinism
fix in IDF (r332167).

This reverts commit r330446.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@332168 91177308-0d34-0410-b5e6-96231b3b80d8
2018-05-12 01:52:36 +00:00
Vedant Kumar
48fd38c573 [STLExtras] Add distance() for ranges, pred_size(), and succ_size()
This commit adds a wrapper for std::distance() which works with ranges.
As it would be a common case to write `distance(predecessors(BB))`, this
also introduces `pred_size()` and `succ_size()` helpers to make that
easier to write.

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@332057 91177308-0d34-0410-b5e6-96231b3b80d8
2018-05-10 23:01:54 +00:00
Wei Mi
deb49e5e4e Fix the issue that ComputeValueKnownInPredecessors only handles the case when
phi is on lhs of a comparison op.

For the following testcase,
L1:

  %t0 = add i32 %m, 7
  %t3 = icmp eq i32* %t2, null
  br i1 %t3, label %L3, label %L2

L2:

  %t4 = load i32, i32* %t2, align 4
  br label %L3

L3:

  %t5 = phi i32 [ %t0, %L1 ], [ %t4, %L2 ]
  %t6 = icmp eq i32 %t0, %t5
  br i1 %t6, label %L4, label %L5

We know if we go through the path L1 --> L3, %t6 should always be true. However
currently, if the rhs of the eq comparison is phi, JumpThreading fails to
evaluate %t6 to true. And we know that Instcombine cannot guarantee always
canonicalizing phi to the left hand side of the comparison operation according
to the operand priority comparison mechanism in instcombine. The patch handles
the case when rhs of the comparison op is a phi.

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



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@331266 91177308-0d34-0410-b5e6-96231b3b80d8
2018-05-01 14:47:24 +00:00
Michael Zolotukhin
b2249a973b Revert r330431.
There are still stage3/stage4 miscompares :(

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@330446 91177308-0d34-0410-b5e6-96231b3b80d8
2018-04-20 16:57:10 +00:00
Michael Zolotukhin
1efc1f1838 Revert "Revert r330403 and r330413."
Reapply the patches with a fix. Thanks Ilya and Hans for the reproducer!
This reverts commit r330416.

The issue was that removing predecessors invalidated uses that we stored
for rewrite. The fix is to finish manipulating with CFG before we select
uses for rewrite.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@330431 91177308-0d34-0410-b5e6-96231b3b80d8
2018-04-20 13:34:32 +00:00
Ilya Biryukov
8e71a936a4 Revert r330403 and r330413.
Revert r330413: "[SSAUpdaterBulk] Use SmallVector instead of DenseMap for storing rewrites."
Revert r330403 "Reapply "[PR16756] Use SSAUpdaterBulk in JumpThreading." one more time."

r330403 commit seems to crash clang during our integrate while doing PGO build with the following stacktrace:
      #2 llvm::SSAUpdaterBulk::RewriteAllUses(llvm::DominatorTree*, llvm::SmallVectorImpl<llvm::PHINode*>*)
      #3 llvm::JumpThreadingPass::ThreadEdge(llvm::BasicBlock*, llvm::SmallVectorImpl<llvm::BasicBlock*> const&, llvm::BasicBlock*)
      #4 llvm::JumpThreadingPass::ProcessThreadableEdges(llvm::Value*, llvm::BasicBlock*, llvm::jumpthreading::ConstantPreference, llvm::Instruction*)
      #5 llvm::JumpThreadingPass::ProcessBlock(llvm::BasicBlock*)
The crash happens while compiling 'lib/Analysis/CallGraph.cpp'.

r3340413 is reverted due to conflicting changes.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@330416 91177308-0d34-0410-b5e6-96231b3b80d8
2018-04-20 10:52:54 +00:00
Michael Zolotukhin
35a415fc01 [SSAUpdaterBulk] Use SmallVector instead of DenseMap for storing rewrites.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@330413 91177308-0d34-0410-b5e6-96231b3b80d8
2018-04-20 10:31:06 +00:00
Michael Zolotukhin
caacf23982 Reapply "[PR16756] Use SSAUpdaterBulk in JumpThreading." one more time.
Hopefully, changing set to vector removes nondeterminism detected by
some bots, or the new assert will catch something.

This reverts commit r330180.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@330403 91177308-0d34-0410-b5e6-96231b3b80d8
2018-04-20 08:01:08 +00:00
Michael Zolotukhin
f7a516d335 Revert "Reapply "[PR16756] Use SSAUpdaterBulk in JumpThreading." again."
This reverts r330175. There are still stage3/stage4 miscompares.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@330180 91177308-0d34-0410-b5e6-96231b3b80d8
2018-04-17 07:31:27 +00:00
Michael Zolotukhin
11001a689d Reapply "[PR16756] Use SSAUpdaterBulk in JumpThreading." again.
One more, hopefully the last, bug is fixed: when forming UsesToRewrite
we should ignore phi operands coming from edges that we want to delete.

This reverts r329910.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@330175 91177308-0d34-0410-b5e6-96231b3b80d8
2018-04-17 04:45:22 +00:00
Benjamin Kramer
9ef860a398 Revert "Reapply "[PR16756] Use SSAUpdaterBulk in JumpThreading." one more time."
This reverts commit r329865. Causes stage2/stage3 miscompare.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@329910 91177308-0d34-0410-b5e6-96231b3b80d8
2018-04-12 13:52:02 +00:00
Michael Zolotukhin
b33a02496a Reapply "[PR16756] Use SSAUpdaterBulk in JumpThreading." one more time.
This reapplies commit r329644.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@329865 91177308-0d34-0410-b5e6-96231b3b80d8
2018-04-11 23:37:53 +00:00
Michael Zolotukhin
4be25bd837 Revert "[PR16756] Use SSAUpdaterBulk in JumpThreading." one more time.
This reverts r329661. Bots are still unhappy.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@329666 91177308-0d34-0410-b5e6-96231b3b80d8
2018-04-10 03:40:29 +00:00
Michael Zolotukhin
134d36e085 Revert "Revert "[PR16756] Use SSAUpdaterBulk in JumpThreading.""
This reapplies commit r329644.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@329661 91177308-0d34-0410-b5e6-96231b3b80d8
2018-04-10 02:16:45 +00:00
Michael Zolotukhin
af04f87166 Revert "[PR16756] Use SSAUpdaterBulk in JumpThreading."
This reverts commit r329644.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@329650 91177308-0d34-0410-b5e6-96231b3b80d8
2018-04-10 00:42:43 +00:00
Michael Zolotukhin
79081b466d [PR16756] Use SSAUpdaterBulk in JumpThreading.
Summary:
SSAUpdater is a bottleneck in JumpThreading, and this patch improves the
situation by using SSAUpdaterBulk instead.

Compile time impact: no noticable changes on CTMark, a big improvement
on the test from PR16756.

Reviewers: dberlin, davide, MatzeB

Subscribers: llvm-commits, hiraditya

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@329644 91177308-0d34-0410-b5e6-96231b3b80d8
2018-04-09 23:37:37 +00:00
Haicheng Wu
9c598cb7f2 [JumpThreading] Don't select an edge that we know we can't thread
In r312664 (D36404), JumpThreading stopped threading edges into
loop headers. Unfortunately, I observed a significant performance
regression as a result of this change. Upon further investigation,
the problematic pattern looked something like this (after
many high level optimizations):

while (true) {
    bool cond = ...;
    if (!cond) {
        <body>
    }
    if (cond)
        break;
}

Now, naturally we want jump threading to essentially eliminate the
second if check and hook up the edges appropriately. However, the
above mentioned change, prevented it from doing this because it would
have to thread an edge into the loop header.

Upon further investigation, what is happening is that since both branches
are threadable, JumpThreading picks one of them at arbitrarily. In my
case, because of the way that the IR ended up, it tended to pick
the one to the loop header, bailing out immediately after. However,
if it had picked the one to the exit block, everything would have
worked out fine (because the only remaining branch would then be folded,
not thraded which is acceptable).

Thus, to fix this problem, we can simply eliminate loop headers from
consideration as possible threading targets earlier, to make sure that
if there are multiple eligible branches, we can still thread one of
the ones that don't target a loop header.

Patch by Keno Fischer!
Differential Revision: https://reviews.llvm.org/D42260

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@328798 91177308-0d34-0410-b5e6-96231b3b80d8
2018-03-29 16:01:26 +00:00
David Blaikie
283527b390 Fix a couple of layering violations in Transforms
Remove #include of Transforms/Scalar.h from Transform/Utils to fix layering.

Transforms depends on Transforms/Utils, not the other way around. So
remove the header and the "createStripGCRelocatesPass" function
declaration (& definition) that is unused and motivated this dependency.

Move Transforms/Utils/Local.h into Analysis because it's used by
Analysis/MemoryBuiltins.cpp.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@328165 91177308-0d34-0410-b5e6-96231b3b80d8
2018-03-21 22:34:23 +00:00
Brian M. Rzycki
cd83f2d5e3 [JumpThreading] Track unreachable BBs to avoid processing
JumpThreading iterates over F until the IR quiesces. Transforming
unreachable BBs increases compile time and it is also possible to
never stabilize causing JumpThreading to hang. An older attempt at
fixing this problem was D3991 where removeUnreachableBlocks(F)
was called before JumpThreading began. This has a few drawbacks:
 * expensive - the routine attempts to fix up the IR to identify
   additional BBs that can be removed along with unreachable BBs.
 * aggressive - does not identify and preserve the shape of the IR.
   At a minimum it does not preserve loop hierarchies.
 * invasive - altering reachable blocks it may disrupt IR shapes
   that could have otherwise been JumpThreaded.

This patch avoids removeUnreachableBlocks(F) and instead tracks
unreachable BBs in a SmallPtrSet using DominatorTree to validate the
initial state of all BBs. We then rely on subsequent passes to identify
and remove these unreachable blocks from F.

Reviewers: dberlin, sebpop, kuhar, dinesh.d

Reviewed by: sebpop, kuhar

Subscribers: hiraditya, uabelho, llvm-commits

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


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@327713 91177308-0d34-0410-b5e6-96231b3b80d8
2018-03-16 15:13:47 +00:00
Chad Rosier
4adc4526ec [JumpThreading] Don't restrict cast-traversal to i1
In r263618, JumpThreading learned to look trough simple cast instructions, but
only if the source of those cast instructions was a phi/cmp i1 (in an effort to
limit compile time effects). I think this condition is too restrictive. For
switches with limited value range, InstCombine will readily introduce an extra
trunc instruction to a smaller integer type (e.g. from i8 to i2), leaving us in
the somewhat perverse situation that jump-threading would work before running
instcombine, but not after. Since instcombine produces this pattern, I think we
need to consider it canonical and support it in JumpThreading.  In general,
for limiting recursion, I think the existing restriction to phi and cmp nodes
should be sufficient to avoid looking through unprofitable chains of
instructions.

Patch by Keno Fischer!
Differential Revision: https://reviews.llvm.org/D42262

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@327150 91177308-0d34-0410-b5e6-96231b3b80d8
2018-03-09 16:43:46 +00:00
Philip Reames
2082160f33 [NFC] Factor out a helper function for checking if a block has a potential early implicit exit.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@327065 91177308-0d34-0410-b5e6-96231b3b80d8
2018-03-08 21:25:30 +00:00
Brian M. Rzycki
55da8a3a3e [JumpThreading] PR36133 enable/disable DominatorTree for LVI analysis
Summary:
The LazyValueInfo pass caches a copy of the DominatorTree when available.
Whenever there are pending DominatorTree updates within JumpThreading's
DeferredDominance object we cannot use the cached DT for LVI analysis.
This commit adds the new methods enableDT() and disableDT() to LVI.
JumpThreading also sets the appropriate usage model before calling LVI
analysis methods.

Fixes https://bugs.llvm.org/show_bug.cgi?id=36133

Reviewers: sebpop, dberlin, kuhar

Reviewed by: sebpop, kuhar

Subscribers: uabelho, llvm-commits, aprantl, hiraditya, a.elovikov

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



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@325356 91177308-0d34-0410-b5e6-96231b3b80d8
2018-02-16 16:35:17 +00:00
Brian M. Rzycki
2495d26abd [JumpThreading][NFC] Rename LoadInst variables
Summary:
The JumpThreading pass has several locations where to the variable name LI
refers to a LoadInst type. This is confusing and inhibits the ability to use
LI for LoopInfo as a member of the JumpThreading class. Minor formatting
and comments were also altered to reflect this change.

Reviewers: dberlin, kuba, spop, sebpop

Reviewed by: sebpop

Subscribers: sebpop, hiraditya, llvm-commits

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



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@323695 91177308-0d34-0410-b5e6-96231b3b80d8
2018-01-29 21:29:44 +00:00
Brian M. Rzycki
a57b9dfaee [JumpThreading] Preservation of DT and LVI across the pass
Summary:
See D37528 for a previous (non-deferred) version of this
patch and its description.

Preserves dominance in a deferred manner using a new class
DeferredDominance. This reduces the performance impact of
updating the DominatorTree at every edge insertion and
deletion. A user may call DDT->flush() within JumpThreading
for an up-to-date DT. This patch currently has one flush()
at the end of runImpl() to ensure DT is preserved across
the pass.

LVI is also preserved to help subsequent passes such as
CorrelatedValuePropagation. LVI is simpler to maintain and
is done immediately (not deferred). The code to perform the
preversation was minimally altered and simply marked as
preserved for the PassManager to be informed.

This extends the analysis available to JumpThreading for
future enhancements such as threading across loop headers.

Reviewers: dberlin, kuhar, sebpop

Reviewed By: kuhar, sebpop

Subscribers: mgorny, dmgreen, kuba, rnk, rsmith, hiraditya, llvm-commits

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



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@322401 91177308-0d34-0410-b5e6-96231b3b80d8
2018-01-12 21:06:48 +00:00
Reid Kleckner
f810a3e05a Revert "[JumpThreading] Preservation of DT and LVI across the pass"
This reverts r321825, it causes crashes in Chromium. Reproducer
forthcoming.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@321832 91177308-0d34-0410-b5e6-96231b3b80d8
2018-01-04 23:23:46 +00:00
Brian M. Rzycki
f733002f9d [JumpThreading] Preservation of DT and LVI across the pass
Summary:
See D37528 for a previous (non-deferred) version of this
patch and its description.

Preserves dominance in a deferred manner using a new class
DeferredDominance. This reduces the performance impact of
updating the DominatorTree at every edge insertion and
deletion. A user may call DDT->flush() within JumpThreading
for an up-to-date DT. This patch currently has one flush()
at the end of runImpl() to ensure DT is preserved across
the pass.

LVI is also preserved to help subsequent passes such as
CorrelatedValuePropagation. LVI is simpler to maintain and
is done immediately (not deferred). The code to perfom the
preversation was minimally altered and was simply marked
as preserved for the PassManager to be informed.

This extends the analysis available to JumpThreading for
future enhancements. One example is loop boundary threading.

Reviewers: dberlin, kuhar, sebpop

Reviewed By: kuhar, sebpop

Subscribers: hiraditya, llvm-commits

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


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@321825 91177308-0d34-0410-b5e6-96231b3b80d8
2018-01-04 21:57:32 +00:00
Benjamin Kramer
66f3fb9fac Use phi ranges to simplify code. No functionality change intended.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@321585 91177308-0d34-0410-b5e6-96231b3b80d8
2017-12-30 15:27:33 +00:00
Easwaran Raman
fe7b9dc2d2 Add hasProfileData() to check if a function has profile data. NFC.
Summary:
This replaces calls to getEntryCount().hasValue() with hasProfileData
that does the same thing. This refactoring is useful to do before adding
synthetic function entry counts but also a useful cleanup IMO even
otherwise. I have used hasProfileData instead of hasRealProfileData as
David had earlier suggested since I think profile implies "real" and I
use the phrase "synthetic entry count" and not "synthetic profile count"
but I am fine calling it hasRealProfileData if you prefer.

Reviewers: davidxl, silvas

Subscribers: llvm-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@321331 91177308-0d34-0410-b5e6-96231b3b80d8
2017-12-22 01:33:52 +00:00
Max Kazantsev
8cc707a59e [JumpThreading] Restrict PRE across instructions that don't pass control to successors
PRE in JumpThreading should not be able to hoist copy of non-speculable loads across
instructions that don't always transfer execution to their successors, otherwise they may
introduce an unsafe load which otherwise would not be executed.

The same problem for GVN was fixed as rL316975.

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


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@321063 91177308-0d34-0410-b5e6-96231b3b80d8
2017-12-19 09:10:21 +00:00
Brian M. Rzycki
d76ae1215c Reverting [JumpThreading] Preservation of DT and LVI across the pass
Stage 2 bootstrap failed:
http://lab.llvm.org:8011/builders/clang-x86_64-linux-selfhost-modules-2/builds/14434



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@320641 91177308-0d34-0410-b5e6-96231b3b80d8
2017-12-13 22:01:17 +00:00
Brian M. Rzycki
7cc3dcfb80 [JumpThreading] Preservation of DT and LVI across the pass
Summary:
See D37528 for a previous (non-deferred) version of this
patch and its description.

Preserves dominance in a deferred manner using a new class
DeferredDominance. This reduces the performance impact of
updating the DominatorTree at every edge insertion and
deletion. A user may call DDT->flush() within JumpThreading
for an up-to-date DT. This patch currently has one flush()
at the end of runImpl() to ensure DT is preserved across
the pass.

LVI is also preserved to help subsequent passes such as
CorrelatedValuePropagation. LVI is simpler to maintain and
is done immediately (not deferred). The code to perfom the
preversation was minimally altered and was simply marked
as preserved for the PassManager to be informed.

This extends the analysis available to JumpThreading for
future enhancements. One example is loop boundary threading.

Reviewers: dberlin, kuhar, sebpop

Reviewed By: kuhar, sebpop

Subscribers: hiraditya, llvm-commits

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


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@320612 91177308-0d34-0410-b5e6-96231b3b80d8
2017-12-13 20:52:26 +00:00
Brian M. Rzycki
0f18499689 [JumpThreading] Minor comment cleanup. NFC. (test commit)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@320179 91177308-0d34-0410-b5e6-96231b3b80d8
2017-12-08 19:36:32 +00:00
Xinliang David Li
cebfaaf903 Fix comment /NFC
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@317514 91177308-0d34-0410-b5e6-96231b3b80d8
2017-11-06 21:57:51 +00:00
Craig Topper
e3e9913345 [JumpThreading] Move two PredValueInfoTy vectors to a scope closer to their usage. NFCI
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@315941 91177308-0d34-0410-b5e6-96231b3b80d8
2017-10-16 21:54:13 +00:00
Daniel Jasper
aaae73db73 Revert r314435: "[JumpThreading] Preserve DT and LVI across the pass"
Causes a segfault on a builtbot (and in our internal bootstrapping of
Clang). See Eli's response on the commit thread.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@314589 91177308-0d34-0410-b5e6-96231b3b80d8
2017-09-30 11:57:19 +00:00
Evandro Menezes
a10cceeff4 [JumpThreading] Preserve DT and LVI across the pass
JumpThreading now preserves dominance and lazy value information across the
entire pass.  The pass manager is also informed of this preservation with
the goal of DT and LVI being recalculated fewer times overall during
compilation.

This change prepares JumpThreading for enhanced opportunities; particularly
those across loop boundaries.

Patch by: Brian Rzycki <b.rzycki@samsung.com>,
          Sebastian Pop <s.pop@samsung.com>

Differential revision: https://reviews.llvm.org/D37528

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@314435 91177308-0d34-0410-b5e6-96231b3b80d8
2017-09-28 17:24:40 +00:00
Eugene Zelenko
c49953f5fe [Transforms] Fix some Clang-tidy modernize-use-using and Include What You Use warnings; other minor fixes (NFC).
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@313198 91177308-0d34-0410-b5e6-96231b3b80d8
2017-09-13 21:43:53 +00:00