Commit Graph

13255 Commits

Author SHA1 Message Date
Michael Zolotukhin
c82121e77d [Unroll] Add debug dumps to loop-unroll analyzer.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@243471 91177308-0d34-0410-b5e6-96231b3b80d8
2015-07-28 20:07:29 +00:00
Michael Zolotukhin
8ae1a0f789 [Unroll] Don't analyze blocks outside the loop.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@243466 91177308-0d34-0410-b5e6-96231b3b80d8
2015-07-28 19:21:21 +00:00
Sanjay Patel
9c12f72a2e fix formatting; NFC
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@243424 91177308-0d34-0410-b5e6-96231b3b80d8
2015-07-28 15:38:43 +00:00
Adam Nemet
bd426c622e [LDist][LVer] Explicitly pass the set of memchecks to LoopVersioning, NFC
Before the patch, the checks were generated internally in
addRuntimeCheck.  Now, we use the new overloaded version of
addRuntimeCheck that takes the ready-made set of checks as a parameter.

The checks are now generated by the client (LoopDistribution) with the
new RuntimePointerChecking::generateChecks API.

Also the new printChecks API is used to print out the checks for
debugging.

This is to continue the transition over to the new model whereby clients
will get the full set of checks from LAA, filter it and then pass it to
LoopVersioning and in turn to addRuntimeCheck.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@243382 91177308-0d34-0410-b5e6-96231b3b80d8
2015-07-28 05:01:53 +00:00
Sanjoy Das
477137f4d7 [LSR] Generate and use zero extends
Summary:
If a scale or a base register can be rewritten as "Zext({A,+,1})" then
LSR will now consider a formula of that form in its normal cost
computation.

Depends on D9180

Reviewers: qcolombet, atrick

Subscribers: llvm-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@243348 91177308-0d34-0410-b5e6-96231b3b80d8
2015-07-27 23:27:51 +00:00
Sanjoy Das
39d6da003d [IndVars] Make loop varying predicates loop invariant.
Summary:
Was D9784: "Remove loop variant range check when induction variable is
strictly increasing"

This change re-implements D9784 with the two differences:

 1. It does not use SCEVExpander and does not generate new
    instructions.  Instead, it does a quick local search for existing
    `llvm::Value`s that it needs when modifying the `icmp`
    instruction.

 2. It is more general -- it deals with both increasing and decreasing
    induction variables.

I've added all of the tests included with D9784, and two more.

As an example on what this change does (copied from D9784):

Given C code:

```
for (int i = M; i < N; i++) // i is known not to overflow
  if (i < 0) break;
  a[i] = 0;
}
```

This transformation produces:

```
for (int i = M; i < N; i++)
  if (M < 0) break;
  a[i] = 0;
}
```

Which can be unswitched into:

```
if (!(M < 0))
  for (int i = M; i < N; i++)
    a[i] = 0;
}
```

I went back and forth on whether the top level logic should live in
`SimplifyIndvar::eliminateIVComparison` or be put into its own
routine.  Right now I've put it under `eliminateIVComparison` because
even though the `icmp` is not *eliminated*, it no longer is an IV
comparison.  I'm open to putting it in its own helper routine if you
think that is better.

Reviewers: reames, nicholas, atrick

Subscribers: llvm-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@243331 91177308-0d34-0410-b5e6-96231b3b80d8
2015-07-27 21:42:49 +00:00
Simon Pilgrim
eb30d38ac8 Fixed signed/unsigned comparison warning.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@243306 91177308-0d34-0410-b5e6-96231b3b80d8
2015-07-27 19:07:15 +00:00
Simon Pilgrim
8e2e335276 [InstCombine][X86][SSE] Replace sign/zero extension intrinsics with native IR
Now that we are generating sane codegen for vector sext/zext nodes on SSE targets, this patch uses instcombine to replace the SSE41/AVX2 pmovsx and pmovzx intrinsics with the equivalent native IR code.

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@243303 91177308-0d34-0410-b5e6-96231b3b80d8
2015-07-27 18:52:15 +00:00
Pete Cooper
2deaa2924e Revert "Remove unnecessary null check. NFC."
This reverts commit r243167.

Duncan pointed out that dyn_cast can return null in these cases, so this
was an unsafe commit to make.  Sorry for the noise.

Worryingly there were no tests which fail...

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@243302 91177308-0d34-0410-b5e6-96231b3b80d8
2015-07-27 18:37:58 +00:00
Jingyue Wu
580991b5c9 Roll forward r243250
r243250 appeared to break clang/test/Analysis/dead-store.c on one of the build
slaves, but I couldn't reproduce this failure locally. Probably a false
positive as I saw this test was broken by r243246 or r243247 too but passed
later without people fixing anything.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@243253 91177308-0d34-0410-b5e6-96231b3b80d8
2015-07-26 19:10:03 +00:00
Jingyue Wu
e48b1257f1 Revert r243250
breaks tests


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@243251 91177308-0d34-0410-b5e6-96231b3b80d8
2015-07-26 18:30:13 +00:00
Jingyue Wu
9f141640b5 [TTI/CostModel] improve TTI::getGEPCost and use it in CostModel::getInstructionCost
Summary:
This patch updates TargetTransformInfoImplCRTPBase::getGEPCost to consider
addressing modes. It now returns TCC_Free when the GEP can be completely folded
to an addresing mode.

I started this patch as I refactored SLSR. Function isGEPFoldable looks common
and is indeed used by some WIP of mine. So I extracted that logic to getGEPCost.

Furthermore, I noticed getGEPCost wasn't directly tested anywhere. The best
testing bed seems CostModel, but its getInstructionCost method invokes
getAddressComputationCost for GEPs which provides very coarse estimation. So
this patch also makes getInstructionCost call the updated getGEPCost for GEPs.
This change inevitably breaks some tests because the cost model changes, but
nothing looks seriously wrong -- if we believe the new cost model is the right
way to go, these tests should be updated.

This patch is not perfect yet -- the comments in some tests need to be updated.
I want to know whether this is a right approach before fixing those details.

Reviewers: chandlerc, hfinkel

Subscribers: aschwaighofer, llvm-commits, aemerson

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@243250 91177308-0d34-0410-b5e6-96231b3b80d8
2015-07-26 17:28:13 +00:00
Simon Pilgrim
ddcbf4ce91 [InstCombine][SSE4A] Standardized references to Length/Width and Index/Start to match AMD docs. NFCI.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@243226 91177308-0d34-0410-b5e6-96231b3b80d8
2015-07-25 20:41:00 +00:00
Chen Li
7b0238cdc1 [LoopUnswitch] Improve loop unswitch pass to find trivial unswitch conditions more effectively
Summary:
This patch improves trivial loop unswitch. 

The current trivial loop unswitch only checks if loop header's terminator contains a trivial unswitch condition. But if the loop header only has one reachable successor (due to intentionally or unintentionally missed code simplification), we should consider the successor as part of the loop header. Therefore, instead of stopping at loop header's terminator, we should keep traversing its successors within loop until reach a *real* conditional branch or switch (whose condition can not be constant folded). This change will enable a single -loop-unswitch pass to unswitch multiple trivial conditions (unswitch one trivial condition could open opportunity to unswitch another one in the same loop), while the old implementation can unswitch only one per pass. 

Reviewers: reames, broune

Subscribers: llvm-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@243203 91177308-0d34-0410-b5e6-96231b3b80d8
2015-07-25 03:21:06 +00:00
Lawrence Hu
5136ca2c6d Handle loop with negtive induction variable increment
This patch extend LoopReroll pass to hand the loops which
is similar to the following:

      while (len > 1) {
            sum4 += buf[len];
            sum4 += buf[len-1];
            len -= 2;
        }

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@243171 91177308-0d34-0410-b5e6-96231b3b80d8
2015-07-24 22:01:49 +00:00
Pete Cooper
b0fd31a910 Remove unnecessary null check. NFC.
Since both places which set this variable do so with dyn_cast, and not
dyn_cast_or_null, its impossible to get a nullptr here, so we can remove
the check.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@243167 91177308-0d34-0410-b5e6-96231b3b80d8
2015-07-24 21:38:01 +00:00
Pete Cooper
9f2f1650c4 Use make_range(rbegin(), rend()) to allow foreach loops. NFC.
Instead of the pattern

for (auto I = x.rbegin(), E = x.end(); I != E; ++I)

we can use make_range to construct the reverse range and iterate using
that instead.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@243163 91177308-0d34-0410-b5e6-96231b3b80d8
2015-07-24 21:13:43 +00:00
Diego Novillo
8cae9a32fc Remove unused variable. NFC.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@243145 91177308-0d34-0410-b5e6-96231b3b80d8
2015-07-24 19:18:32 +00:00
Jingyue Wu
ab0a70d3a3 Remove the user-count threshold when analyzing read attributes
Summary:
This threshold limited FunctionAttrs ability to prove arguments to be read-only. 
In NVPTX, a specialized instruction ld.global.nc can be used to load memory
with non-coherent texture cache. We notice that in SHOC [1] benchmark, some
function arguments are not marked with readonly because FunctionAttrs reaches
a hardcoded threshold when analysis uses.

Removing this threshold won't cause significant regression in compilation time, because the worst-case time complexity of the algorithm is still O(# of instructions) for each parameter.

Patched by Xuetian Weng.  

[1] https://github.com/vetter/shoc

Reviewers: nlewycky, jingyue, nicholas

Subscribers: nicholas, test, llvm-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@243141 91177308-0d34-0410-b5e6-96231b3b80d8
2015-07-24 19:05:53 +00:00
Philip Reames
ec2871f730 [RewriteStatepointsForGC] Adjust naming scheme to be more stable
The names for instructions inserted were previous dependent on iteration order.  By deriving the names from the original instructions, we can avoid instability in tests without resorting to ordered traversals.  It also makes the IR mildly easier to read at large scale.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@243140 91177308-0d34-0410-b5e6-96231b3b80d8
2015-07-24 19:01:39 +00:00
Pete Cooper
2914cbf164 Use foreach loops for StructType::elements(). NFC.
We had a few places where we did

for (unsigned i = 0, e = STy->getNumElements(); i != e; ++i) {

but those could instead do

for (auto *EltTy : STy->elements()) {

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@243136 91177308-0d34-0410-b5e6-96231b3b80d8
2015-07-24 18:55:49 +00:00
Michael Zolotukhin
fc561accb7 Handle resolvable branches in complete loop unroll heuristic.
Summary:
Resolving a branch allows us to ignore blocks that won't be executed, and thus make our estimate more accurate.
This patch is intended to be applied after D10205 (though it could be applied independently).

Reviewers: chandlerc

Subscribers: llvm-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@243084 91177308-0d34-0410-b5e6-96231b3b80d8
2015-07-24 01:53:04 +00:00
Philip Reames
a8f6ce415b [RewriteStatepointsForGC] Fix release build warning
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@243076 91177308-0d34-0410-b5e6-96231b3b80d8
2015-07-24 00:42:55 +00:00
Philip Reames
eb902a7509 [RewriteStatepointsForGC] Use a worklist algorithm for first part of base pointer algorithm [NFC]
The new code should hopefully be equivalent to the old code; it just uses a worklist to track instructions which need to visited rather than iterating over all instructions visited each time. This should be faster, but the primary benefit is that the purpose should be more clear and the diff of adding another instruction type (forthcoming) much more obvious.

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



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@243071 91177308-0d34-0410-b5e6-96231b3b80d8
2015-07-24 00:02:11 +00:00
Jingyue Wu
cab4b8c41b [NaryReassociate] remove redundant code
This check is already done by findClosestMatchingDominator.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@243065 91177308-0d34-0410-b5e6-96231b3b80d8
2015-07-23 23:13:37 +00:00
Philip Reames
e2d5247dee [RewriteStatepointsForGC] Rename PhiState to reflect that it's associated w/more than just PHIs
Today, Select instructions also have associated PhiStates.  In the near future, so will ExtractElement and SuffleVector.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@243056 91177308-0d34-0410-b5e6-96231b3b80d8
2015-07-23 22:49:14 +00:00
Philip Reames
173e222715 [RewriteStatepointsForGC] Use idomatic mechanisms for debug tracing [NFC]
Deleting much of the code using trace-rewrite-statepoints and use idiomatic DEBUG statements instead.  This includes adding operator<< to a helper class.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@243054 91177308-0d34-0410-b5e6-96231b3b80d8
2015-07-23 22:25:26 +00:00
Philip Reames
6c5bfdf124 [RewriteStatepointsForGC] Simplify code around meet of PhiStates [NFC]
We don't need to pass in the map from BDV to PhiStates; we can instead handle that externally and let the MeetPhiStates helper class just meet PhiStates.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@243045 91177308-0d34-0410-b5e6-96231b3b80d8
2015-07-23 21:41:27 +00:00
Matt Wala
106d75d396 [Scalarizer] Fix potential for stale data in Scattered across invocations
Summary:
Scalarizer has two data structures that hold information about changes
to the function, Gathered and Scattered. These are cleared in finish()
at the end of runOnFunction() if finish() detects any changes to the
function.

However, finish() was checking for changes by only checking if
Gathered was non-empty. The function visitStore() only modifies
Scattered without touching Gathered. As a result, Scattered could have
ended up having stale data if Scalarizer only scalarized store
instructions. Since the data in Scattered is used during the execution
of the pass, this introduced dangling pointer errors.

The fix is to check whether both Scattered and Gathered are empty
before deciding what to do in finish(). This also fixes a problem
where the Function can be modified although the pass returns false.

Reviewers: rnk

Subscribers: rnk, srhines, llvm-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@243040 91177308-0d34-0410-b5e6-96231b3b80d8
2015-07-23 20:53:46 +00:00
Kuba Brecka
00a917ca7c [asan] Rename the ABI versioning symbol to '__asan_version_mismatch_check' instead of abusing '__asan_init'
We currently version `__asan_init` and when the ABI version doesn't match, the linker gives a `undefined reference to '__asan_init_v5'` message. From this, it might not be obvious that it's actually a version mismatch error. This patch makes the error message much clearer by changing the name of the undefined symbol to be `__asan_version_mismatch_check_xxx` (followed by the version string). We obviously don't want the initializer to be named like that, so it's a separate symbol that is used only for the purpose of version checking.

Reviewed at http://reviews.llvm.org/D11004



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@243003 91177308-0d34-0410-b5e6-96231b3b80d8
2015-07-23 10:54:06 +00:00
Chandler Carruth
8de7149b0d [GMR] Add a late run of GlobalsModRef to the main pass pipeline behind
the general GMR-in-non-LTO flag.

Without this, we have the global information during the CGSCC pipeline
for GVN and such, but don't have it available during the late loop
optimizations such as the vectorizer. Moreover, after the CGSCC pipeline
has finished we have substantially more accurate and refined call graph
information, function annotations, etc, which will make GMR even more
powerful than it is early in the pipelien.

Note that we have to play silly games with preserving AliasAnalysis
(which is now trivially preserved) in order to let a module analysis
magically be preserved into the entire function pass pipeline.
Simultaneously we have to not make GMR an immutable pass in order to be
able to re-run it and collect fresh data on the final call graph.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@242999 91177308-0d34-0410-b5e6-96231b3b80d8
2015-07-23 09:34:01 +00:00
Chandler Carruth
52ab0bc417 [PM/AA] Extract the ModRef enums from the AliasAnalysis class in
preparation for de-coupling the AA implementations.

In order to do this, they had to become fake-scoped using the
traditional LLVM pattern of a leading initialism. These can't be actual
scoped enumerations because they're bitfields and thus inherently we use
them as integers.

I've also renamed the behavior enums that are specific to reasoning
about the mod/ref behavior of functions when called. This makes it more
clear that they have a very narrow domain of applicability.

I think there is a significantly cleaner API for all of this, but
I don't want to try to do really substantive changes for now, I just
want to refactor the things away from analysis groups so I'm preserving
the exact original design and just cleaning up the names, style, and
lifting out of the class.

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@242963 91177308-0d34-0410-b5e6-96231b3b80d8
2015-07-22 23:15:57 +00:00
Anthony Pesch
186b8ca6dc Revert "Improve merging of stores from static constructors in GlobalOpt"
This reverts commit 0a9dee959a30b81b9e7df64c9a58ff9898c24024.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@242954 91177308-0d34-0410-b5e6-96231b3b80d8
2015-07-22 22:26:54 +00:00
Anthony Pesch
63abd4b150 Revert "IPO: Avoid brace initialization of a map, some versions of libc++ don't like it"
This reverts commit fc2dad0c68f8d32273d3c2d790ed496961f829af.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@242953 91177308-0d34-0410-b5e6-96231b3b80d8
2015-07-22 22:26:52 +00:00
Justin Bogner
34e7058dc8 IPO: Avoid brace initialization of a map, some versions of libc++ don't like it
Should fix the build failure on these darwin bots:

http://lab.llvm.org:8080/green/job/clang-stage1-cmake-RA-incremental_build/12427/
http://lab.llvm.org:8080/green/job/clang-stage1-configure-RA_build/10389/

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@242945 91177308-0d34-0410-b5e6-96231b3b80d8
2015-07-22 21:41:12 +00:00
Anthony Pesch
a5fd3fdc5b Improve merging of stores from static constructors in GlobalOpt
Summary:
While working on a project I wound up generating a fairly large lookup table (10k entries) of callbacks inside of a static constructor. Clang was taking upwards of ~10 minutes to compile the lookup table. I generated a smaller test case (http://www.inolen.com/static_initializer_test.ll) that, after running with -ftime-report, pointed fingers at GlobalOpt and MemCpyOptimizer.

Running globalopt took around ~9 minutes. The slowdown came from how GlobalOpt merged stores from static constructors individually into the global initializer in EvaluateStaticConstructor. For each store it discovered and wanted to commit, it would copy the existing global initializer and then merge in the individual store. I changed this so that stores are now grouped by global, and sorted from most significant to least significant by their GEP indexes (e.g. a store to GEP 0, 0 comes before GEP 0, 0, 1). With this representation, the existing initializer can be copied and all new stores merged into it in a single pass.

With this patch and http://reviews.llvm.org/D11198, the lookup table that was taking ~10 minutes to compile now compiles in around 5 seconds. I've ran 'make check' and the test-suite, which all passed.

I'm not really sure who to tag as a reviewer, Lang mentioned that Chandler may be appropriate.

Reviewers: chandlerc, nlewycky

Subscribers: nlewycky, llvm-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@242935 91177308-0d34-0410-b5e6-96231b3b80d8
2015-07-22 21:10:45 +00:00
Hans Wennborg
380de5479c Fix -Wextra-semi warnings.
Patch by Eugene Zelenko!

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@242930 91177308-0d34-0410-b5e6-96231b3b80d8
2015-07-22 20:46:11 +00:00
Anthony Pesch
dc719f5fdf Test commit, added blank line
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@242923 91177308-0d34-0410-b5e6-96231b3b80d8
2015-07-22 18:50:10 +00:00
Chandler Carruth
c63b4b9f3a [GMR] Add a flag to enable GlobalsModRef in the normal compilation
pipeline.

Even before I started improving its runtime, it was already crazy fast
once the call graph exists, and if we can get it to be conservatively
correct, will still likely catch a lot of interesting and useful cases.
So it may well be useful to enable by default.

But more importantly for me, this should make it easier for me to test
that changes aren't breaking it in fundamental ways by enabling it for
normal builds.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@242895 91177308-0d34-0410-b5e6-96231b3b80d8
2015-07-22 11:57:28 +00:00
Michael Kuperstein
6418278e7d Fix mem2reg to correctly handle allocas only used in a single block
Currently, a load from an alloca that is used in as single block and is not preceded
by a store is replaced by undef. This is not always correct if the single block is
inside a loop.
Fix the logic so that:
1) If there are no stores in the block, replace the load with an undef, as before.
2) If there is a store (regardless of where it is in the block w.r.t the load), bail
out, and let the rest of mem2reg handle this alloca.

Patch by: gil.rapaport@intel.com
Differential Revision: http://reviews.llvm.org/D11355

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@242884 91177308-0d34-0410-b5e6-96231b3b80d8
2015-07-22 10:29:29 +00:00
Kuba Brecka
a5812d5bbf [asan] Improve moving of non-instrumented allocas
In r242510, non-instrumented allocas are now moved into the first basic block.  This patch limits that to only move allocas that are present *after* the first instrumented one (i.e. only move allocas up).  A testcase was updated to show behavior in these two cases.  Without the patch, an alloca could be moved down, and could cause an invalid IR.

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



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@242883 91177308-0d34-0410-b5e6-96231b3b80d8
2015-07-22 10:25:38 +00:00
Chandler Carruth
f020cb2f75 [PM/AA] Remove all of the dead AliasAnalysis pointers being threaded
through APIs that are no longer necessary now that the update API has
been removed.

This will make changes to the AA interfaces significantly less
disruptive (I hope). Either way, it seems like a really nice cleanup.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@242882 91177308-0d34-0410-b5e6-96231b3b80d8
2015-07-22 09:52:54 +00:00
Chandler Carruth
ac17c4d9b5 [PM/AA] Remove the last of the legacy update API from AliasAnalysis as
part of simplifying its interface and usage in preparation for porting
to work with the new pass manager.

Note that this will likely expose that we have dead arguments, members,
and maybe even pass requirements for AA. I'll be cleaning those up in
seperate patches. This just zaps the actual update API.

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@242881 91177308-0d34-0410-b5e6-96231b3b80d8
2015-07-22 09:49:59 +00:00
Chandler Carruth
bf35115273 [PM/AA] Switch to an early-exit. NFC. This was split out of another
change because the diff is *useless*. I assure you, I just switched to
early-return in this function.

Cleanup in preparation for my next commit, as requested in code review!

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@242880 91177308-0d34-0410-b5e6-96231b3b80d8
2015-07-22 09:44:54 +00:00
Chen Li
5015f9766b [LoopUnswitch] Code refactoring to separate trivial loop unswitch and non-trivial loop unswitch in processCurrentLoop()
Summary: The current code in LoopUnswtich::processCurrentLoop() mixes trivial loop unswitch and non-trivial loop unswitch together. It goes over all basic blocks in the loop and checks if a condition is trivial or non-trivial unswitch condition. However, trivial unswitch condition can only occur in the loop header basic block (where it controls whether or not the loop does something at all). This refactoring separate trivial loop unswitch and non-trivial loop unswitch. Before going over all basic blocks in the loop, it checks if the loop header contains a trivial unswitch condition. If so, unswitch it. Otherwise, go over all blocks like before but don't check trivial condition any more since they are not possible to be in the other blocks. This code has no functionality change.

Reviewers: meheff, reames, broune

Subscribers: llvm-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@242873 91177308-0d34-0410-b5e6-96231b3b80d8
2015-07-22 05:26:29 +00:00
Chandler Carruth
2cf40d1ae5 [SROA] Fix a nasty pile of bugs to do with big-endian, different alloca
types and loads, loads or stores widened past the size of an alloca,
etc.

This started off with a bug report about big-endian behavior with
bitfields and loads and stores to a { i32, i24 } struct. An initial
attempt to fix this was sent for review in D10357, but that didn't
really get to the root of the problem.

The core issue was that canConvertValue and convertValue in SROA were
handling different bitwidth integers by doing a zext of the integer. It
wouldn't do a trunc though, only a zext! This would in turn lead SROA to
form an i24 load from an i24 alloca, zext it to i32, and then use it.
This would at least produce the wrong value for big-endian systems.

One of my many false starts here was to correct the computation for
big-endian systems by shifting. But this doesn't actually work because
the original code has a 64-bit store to the entire 8 bytes, and a 32-bit
load of the last 4 bytes, and because the alloc size is 8 bytes, we
can't lose that last (least significant if bigendian) byte! The real
problem here is that we're forming an i24 load in SROA which is actually
not sufficiently wide to load all of the necessary bits here. The source
has an i32 load, and SROA needs to form that as well.

The straightforward way to do this is to disable the zext logic in
canConvertValue and convertValue, forcing us to actually load all
32-bits. This seems like a really good change, but it in turn breaks
several other parts of SROA.

First in the chain of knock-on failures, we had places where we were
doing integer-widening promotion even though some of the integer loads
or stores extended *past the end* of the alloca's memory! There was even
a comment about preventing this, but it only prevented the case where
the type had a different bit size from its store size. So I added checks
to handle the cases where we actually have a widened load or store and
to avoid trying to special integer widening promotion in those cases.

Second, we actually rely on the ability to promote in the face of loads
past the end of an alloca! This is important so that we can (for
example) speculate loads around PHI nodes to do more promotion. The bits
loaded are garbage, but as long as they aren't used and the alignment is
suitable high (which it wasn't in the test case!) this is "fine". And we
can't stop promoting here, lots of things stop working well if we do. So
we need to add specific logic to handle the extension (and truncation)
case, but *only* where that extension or truncation are over bytes that
*are outside the alloca's allocated storage* and thus totally bogus to
load or store.

And of course, once we add back this correct handling of extension or
truncation, we need to correctly handle bigendian systems to avoid
re-introducing the exact bug that started us off on this chain of misery
in the first place, but this time even more subtle as it only happens
along speculated loads atop a PHI node.

I've ported an existing test for PHI speculation to the big-endian test
file and checked that we get that part correct, and I've added several
more interesting big-endian test cases that should help check that we're
getting this correct.

Fun times.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@242869 91177308-0d34-0410-b5e6-96231b3b80d8
2015-07-22 03:32:42 +00:00
Nick Lewycky
f17fb8d947 Fix a performance problem in memcpyopt by removing a linear scan over ranges when inserting a new range. No functionality change intended. Patch by Anthony Pesch!
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@242843 91177308-0d34-0410-b5e6-96231b3b80d8
2015-07-21 21:56:26 +00:00
Philip Reames
4ccee6b377 [RewriteStatepointsForGC] minor style cleanup
Use a named lambda for readability, common some code, remove a stale comments, and use llvm style variable names.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@242827 91177308-0d34-0410-b5e6-96231b3b80d8
2015-07-21 19:04:38 +00:00
Reid Kleckner
90a1b93e9f Re-land 242726 to use RAII to do cleanup
The LooksLikeCodeInBug11395() codepath was returning without clearing
the ProcessedAllocas cache.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@242809 91177308-0d34-0410-b5e6-96231b3b80d8
2015-07-21 17:40:14 +00:00
Philip Reames
d0db907e73 [RewriteStatepointsForGC] Hoist some code out of a loop
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@242808 91177308-0d34-0410-b5e6-96231b3b80d8
2015-07-21 17:18:03 +00:00