3419 Commits

Author SHA1 Message Date
Sean Silva
980a4b4d40 Fix - CodeExtractor : Inherit Target Dependent Attributes from the parent function.
When extracting a set of blocks make sure to inherit all of the target
dependent attributes to make sure that the function will be valid for
lowering. One example is the "target-features" attribute for x86, if the
extracted region has functionality that relies on a specific feature it
will fail to be lowered.
This also allows for extracted functions to be valid for inlining, at
least back into the parent function, as the target attributes are tested
when inlining for compatibility.

Patch by River Riddle!

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@277315 91177308-0d34-0410-b5e6-96231b3b80d8
2016-08-01 03:15:32 +00:00
Sean Silva
0f7cbe185c CodeExtractor : Add ability to preserve profile data.
Added ability to estimate the entry count of the extracted function and
the branch probabilities of the exit branches.

Patch by River Riddle!

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@277313 91177308-0d34-0410-b5e6-96231b3b80d8
2016-08-01 02:59:26 +00:00
Daniel Berlin
cdbca76b08 Fix the MemorySSA updating API to enable people to create memory accesses before removing old ones
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@277309 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-31 21:08:20 +00:00
Adam Nemet
c4f6d8cd25 [LoopUnroll] Include hotness of region in opt remark
LoopUnroll is a loop pass, so the analysis of OptimizationRemarkEmitter
is added to the common function analysis passes that loop passes
depend on.

The BFI and indirectly BPI used in this pass is computed lazily so no
overhead should be observed unless -pass-remarks-with-hotness is used.

This is how the patch affects the O3 pipeline:

         Dominator Tree Construction
         Natural Loop Information
         Canonicalize natural loops
         Loop-Closed SSA Form Pass
         Basic Alias Analysis (stateless AA impl)
         Function Alias Analysis Results
         Scalar Evolution Analysis
+        Lazy Branch Probability Analysis
+        Lazy Block Frequency Analysis
+        Optimization Remark Emitter
         Loop Pass Manager
           Rotate Loops
           Loop Invariant Code Motion
           Unswitch loops
         Simplify the CFG
         Dominator Tree Construction
         Basic Alias Analysis (stateless AA impl)
         Function Alias Analysis Results
         Combine redundant instructions
         Natural Loop Information
         Canonicalize natural loops
         Loop-Closed SSA Form Pass
         Scalar Evolution Analysis
+        Lazy Branch Probability Analysis
+        Lazy Block Frequency Analysis
+        Optimization Remark Emitter
         Loop Pass Manager
           Induction Variable Simplification
           Recognize loop idioms
           Delete dead loops
           Unroll loops
...

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@277203 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-29 19:29:47 +00:00
Andrew Kaylor
2f75f99d2f Recommitting r275284: add support to inline __builtin_mempcpy
Patch by Sunita Marathe

Third try, now following fixes to MSan to handle mempcy in such a way that this commit won't break the MSan buildbots. (Thanks, Evegenii!)



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@277189 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-29 18:23:18 +00:00
David Majnemer
e43ff14879 [ConstnatFolding] Teach the folder how to fold ConstantVector
A ConstantVector can have ConstantExpr operands and vice versa.
However, the folder had no ability to fold ConstantVectors which, in
some cases, was an optimization barrier.

Instead, rephrase the folder in terms of Constants instead of
ConstantExprs and teach callers how to deal with failure.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@277099 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-29 03:27:26 +00:00
Piotr Padlewski
d7e3771d59 Added ThinLTO inlining statistics
Summary:
copypasta doc of ImportedFunctionsInliningStatistics class
 \brief Calculate and dump ThinLTO specific inliner stats.
 The main statistics are:
 (1) Number of inlined imported functions,
 (2) Number of imported functions inlined into importing module (indirect),
 (3) Number of non imported functions inlined into importing module
 (indirect).
 The difference between first and the second is that first stat counts
 all performed inlines on imported functions, but the second one only the
 functions that have been eventually inlined to a function in the importing
 module (by a chain of inlines). Because llvm uses bottom-up inliner, it is
 possible to e.g. import function `A`, `B` and then inline `B` to `A`,
 and after this `A` might be too big to be inlined into some other function
 that calls it. It calculates this statistic by building graph, where
 the nodes are functions, and edges are performed inlines and then by marking
 the edges starting from not imported function.

 If `Verbose` is set to true, then it also dumps statistics
 per each inlined function, sorted by the greatest inlines count like
 - number of performed inlines
 - number of performed inlines to importing module

Reviewers: eraman, tejohnson, mehdi_amini

Subscribers: mehdi_amini, llvm-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@277089 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-29 00:27:16 +00:00
Evgeniy Stepanov
b57cbbd54d [sanitizer] Simplify and future-proof maybeMarkSanitizerLibraryCallNoBuiltin().
Sanitizers set nobuiltin attribute on certain library functions to
avoid a situation where such function is neither instrumented nor
intercepted.

At the moment the list of interesting functions is hardcoded. This
change replaces it with logic based on
TargetLibraryInfo::hasOptimizedCodegen and the presense of readnone
function attribute (sanitizers are generally interested in memory
behavior of library functions).

This is expected to be a no-op change: the new logic matches exactly
the same set of functions.

r276771 (currently reverted) added mempcpy() to the list, breaking
MSan tests. With this change, r276771 can be safely re-landed.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@277086 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-28 23:45:15 +00:00
Michael Zolotukhin
79e7020865 Add verifyAnalysis for LCSSA.
Summary:
LCSSAWrapperPass currently doesn't override verifyAnalysis method, so pass
manager doesn't verify LCSSA. This patch adds the method so that we start
verifying LCSSA between loop passes.

Reviewers: chandlerc, sanjoy, hfinkel

Subscribers: llvm-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@276941 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-27 23:35:53 +00:00
Sean Silva
9968808357 Refactor - CodeExtractor : Move check for valid block to static utility
This lets you actually check to see if a block is valid before trying to
extract.

Patch by River Riddle!

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@276846 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-27 08:02:46 +00:00
Andrew Kaylor
e60e6f6702 Reverting r276771 due to MSan failures.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@276824 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-27 01:19:24 +00:00
Adam Nemet
0f30994ef7 [LoopUtils] Sort headers
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@276776 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-26 17:52:02 +00:00
Andrew Kaylor
04defbca9e Re-committing r275284: add support to inline __builtin_mempcpy
Patch by Sunita Marathe

Differential Revision: http://reviews.llvm.org/D21920



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@276771 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-26 17:23:13 +00:00
Michael Kuperstein
b3391842c6 [PM] Port SymbolRewriter to the new PM
Differential Revision: https://reviews.llvm.org/D22703


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@276687 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-25 20:52:00 +00:00
Michael Kuperstein
8969e2c091 Attempt to pacify windows bots.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@276672 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-25 18:39:08 +00:00
Michael Kuperstein
875b0da43f Don't use iplist in SymbolRewriter. NFC.
There didn't appear to be a good reason to use iplist in this case, a regular
list of unique_ptr works just as well.
Change made in preparation to a new PM port (since iplist is not moveable).


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@276668 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-25 18:10:54 +00:00
David Majnemer
2d83d8a394 [Utils] Simplify combineMetadata
Use a range-based for loop, no functional change is intended.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@276600 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-25 02:21:19 +00:00
Elena Demikhovsky
ba55955caa [Loop Vectorizer] Handling loops FP induction variables.
Allowed loop vectorization with secondary FP IVs. Like this:
float *A;
float x = init;
for (int i=0; i < N; ++i) {
  A[i] = x;
  x -= fp_inc;
}

The auto-vectorization is possible when the induction binary operator is "fast" or the function has "unsafe" attribute.

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



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@276554 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-24 07:24:54 +00:00
George Burgess IV
21c0ab87c5 [MSSA] Make EXPENSIVE_CHECKS check more.
checkClobberSanity will now be run for all results of `ClobberWalk`,
instead of just the crazy phi-optimized ones. This can help us catch
cases where our cache is being wonky.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@276553 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-24 07:03:49 +00:00
George Burgess IV
946f2aebd3 [MSSA] Remove useless assert. NFC.
liveOnEntry is always a MemoryDef; asserting that a MemoryPhi isn't
liveOnEntry, while correct, isn't very helpful. :)


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@276542 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-24 01:50:07 +00:00
Sean Silva
9486968c02 Avoid using a raw AssumptionCacheTracker in various inliner functions.
This unblocks the new PM part of River's patch in
https://reviews.llvm.org/D22706

Conveniently, this same change was needed for D21921 and so these
changes are just spun out from there.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@276515 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-23 04:22:50 +00:00
Wei Mi
a6c7a032fe [PM] Port BreakCriticalEdges to the new PM.
Differential Revision: https://reviews.llvm.org/D22688


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@276449 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-22 18:04:25 +00:00
George Burgess IV
bd986a7d74 [MSSA] Add an overload for getClobberingMemoryAccess.
A seemingly common use for the walker's getClobberingMemoryAccess
function is:

```
MemoryAccess *getClobber(MemorySSAWalker *W, MemoryUseOrDef *MUD) {
  const Instruction *I = MUD->getMemoryInst();
  return W->getClobberingMemoryAccess(I);
}
```

Which is kind of redundant, since walkers will ultimately query MSSA to
find out which MemoryAccess `I` maps to (...which is always `MUD`).

So, this patch adds an overload of getClobberingMemoryAccess that
accepts MemoryAccesses directly. As a result, the Instruction overload
of getClobberingMemoryAccess becomes a lightweight wrapper around our
new overload.

Additionally, this patch un`virtual`izes the Instruction overload of
getClobberingMemoryAccess, since there doesn't seem to be a walker that
benefits from that being virtual, and I can't think of how else one
would implement it. Happy to make it virtual again if we would benefit
from doing so.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@276169 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-20 19:51:34 +00:00
Sanjay Patel
402ec84aa3 move decomposeBitTestICmp() to Transforms/Utils; NFC
As noted in https://reviews.llvm.org/D22537 , we can use this functionality in 
visitSelectInstWithICmp() and InstSimplify, but currently we have duplicated
code.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@276140 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-20 17:18:45 +00:00
Sanjay Patel
475ddcccb2 fix documentation comments; NFC
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@276135 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-20 16:30:55 +00:00
Michael Zolotukhin
11bf1ab282 Revert "Revert r275883 and r275891. They seem to cause PR28608."
This reverts commit r276064, and thus reapplies r275891 and r275883 with
a fix for PR28608.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@276077 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-20 01:55:27 +00:00
Sean Silva
98e46ef19c Revert r275883 and r275891. They seem to cause PR28608.
Revert "[LoopSimplify] Update LCSSA after separating nested loops."

This reverts commit r275891.

Revert "[LCSSA] Post-process PHI-nodes created by SSAUpdate when constructing LCSSA form."

This reverts commit r275883.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@276064 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-19 23:54:29 +00:00
Daniel Berlin
e37b4fdf43 Fix unused variable
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@276050 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-19 23:08:08 +00:00
Daniel Berlin
aee8a35ce9 Make MemorySSA::dominates/locallydominates constant time
Summary: Make MemorySSA::dominates/locallydominates constant time

Reviewers: george.burgess.iv, gberry

Subscribers: llvm-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@276046 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-19 22:49:43 +00:00
George Burgess IV
9906b88abc [MemorySSA] Update to the new shiny walker.
This patch updates MemorySSA's use-optimizing walker to be more
accurate and, in some cases, faster.

Essentially, this changed our core walking algorithm from a
cache-as-you-go DFS to an iteratively expanded DFS, with all of the
caching happening at the end. Said expansion happens when we hit a Phi,
P; we'll try to do the smallest amount of work possible to see if
optimizing above that Phi is legal in the first place. If so, we'll
expand the search to see if we can optimize to the next phi, etc.

An iteratively expanded DFS lets us potentially quit earlier (because we
don't assume that we can optimize above all phis) than our old walker.
Additionally, because we don't cache as we go, we can now optimize above
loops.

As an added bonus, this patch adds a ton of verification (if
EXPENSIVE_CHECKS are enabled), so finding bugs is easier.

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


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@275940 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-19 01:29:15 +00:00
Michael Zolotukhin
1bf3e6c4f5 [LoopSimplify] Update LCSSA after separating nested loops.
Summary:
Usually LCSSA survives this transformation, but in some cases (see
attached test) it doesn't: values from the original loop after
separating might be used from the outer loop. Before the transformation
it was the same loop, so LCSSA phis were not required.

This fixes PR28272.

Reviewers: sanjoy, hfinkel, chandlerc

Subscribers: llvm-commits

Differential Revision: http://reviews.llvm.org/D21665

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@275891 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-18 19:44:19 +00:00
Michael Zolotukhin
a2def1bba4 [LCSSA] Post-process PHI-nodes created by SSAUpdate when constructing LCSSA form.
Summary:
SSAUpdate might insert PHI-nodes inside loops, which can break LCSSA
form unless we fix it up.

This fixes PR28424.

Reviewers: sanjoy, chandlerc, hfinkel

Subscribers: uabelho, llvm-commits

Differential Revision: http://reviews.llvm.org/D21997

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@275883 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-18 19:05:08 +00:00
Michael Zolotukhin
bf4114e90b Make processInstruction from LCSSA.cpp externally available.
Summary:
When a pass tries to keep LCSSA form it's often convenient to be able to update
LCSSA for a set of instructions rather than for the entire loop. This patch makes the
processInstruction from LCSSA externally available under a name
formLCSSAForInstruction.

Reviewers: chandlerc, sanjoy, hfinkel

Subscribers: llvm-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@275613 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-15 21:08:41 +00:00
David Majnemer
af8dbbcde0 [AliasAnalysis] Give back AA results for fence instructions
Calling getModRefInfo with a fence resulted in crashes because fences
don't have a memory location.  Add a new predicate to Instruction
called isFenceLike which indicates that the instruction mutates memory
but not any single memory location in particular. In practice, it is a
proxy for the set of instructions which "mayWriteToMemory" but cannot be
used with MemoryLocation::get.

This fixes PR28570.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@275581 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-15 17:19:24 +00:00
Andrew Kaylor
b9ed6a643a Reverting r275284 due to platform-specific test failures
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@275304 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-13 19:09:16 +00:00
Andrew Kaylor
c949e6e642 Fix for Bug 26903, adds support to inline __builtin_mempcpy
Patch by Sunita Marathe

Differential Revision: http://reviews.llvm.org/D21920



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@275284 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-13 17:25:11 +00:00
Davide Italiano
c3bccfa86f [LoopSimplify] Remove a comment which is unlikely to age well.
Chandler pointed out in his review but I forgot to remove before
committing, my bad.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@274963 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-09 03:27:24 +00:00
Davide Italiano
fff81b23a8 [PM] Port LoopSimplify to the new pass manager.
While here move simplifyLoop() function to the new header, as
suggested by Chandler in the review.

Differential Revision:  http://reviews.llvm.org/D21404

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@274959 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-09 03:03:01 +00:00
Xinliang David Li
e042fe59dc Rename LoopAccessAnalysis to LoopAccessLegacyAnalysis /NFC
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@274927 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-08 20:55:26 +00:00
Davide Italiano
d0de2d93f5 [PM] Port InstSimplify to the new pass manager.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@274796 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-07 21:14:36 +00:00
Sjoerd Meijer
69d2b17af4 Addressing post-commit comments for not rewriting fputs:
moved the optimise for size check inside function optimizeFPuts.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@274758 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-07 14:31:19 +00:00
Sjoerd Meijer
5ab922ce5c Code size optimisation: don't rewrite fputs to fwrite when optimising for size
because fwrite requires more arguments and thus extra MOVs are required.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@274753 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-07 13:56:23 +00:00
Chad Rosier
705101d800 [MemorySSA] Reinstate the legacy printer and verifier.
Differential Revision: http://reviews.llvm.org/D22058

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@274679 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-06 21:20:47 +00:00
Daniel Berlin
dad636ee26 Fix handling of forward unreachable but reverse-reachable blocks in MemorySSA construction
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@274606 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-06 05:32:05 +00:00
George Burgess IV
a3d4e373c0 [MSSA] Fix typo. NFC.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@274590 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-06 00:28:43 +00:00
Xinliang David Li
6adce0835f [PM] refactor LoopAccessInfo code part-2
Differential Revision: http://reviews.llvm.org/D21636




git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@274334 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-01 05:59:55 +00:00
Michael Kuperstein
ce2862caac [PM] Normalize FIXMEs for missing PreserveCFG to have the same wording.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@273974 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-28 00:54:12 +00:00
Daniel Berlin
9577f286d4 Factor out buildMemorySSA from getWalker.
NFC.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@273901 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-27 18:22:27 +00:00
Benjamin Kramer
36a5f73f45 [CodeExtractor] Merge DEBUG statements in an attempt to fix the msvc
build.

There's a known bug in msvc 2013 that fails to compile do-while loops
inside of ranged for loops.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@273811 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-26 13:39:33 +00:00
Benjamin Kramer
5288df58b7 Apply clang-tidy's modernize-loop-convert to most of lib/Transforms.
Only minor manual fixes. No functionality change intended.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@273808 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-26 12:28:59 +00:00