summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms
Commit message (Collapse)AuthorAgeFilesLines
* Add basic tests for PlaceSafepointsPhilip Reames2015-02-091-5/+21
| | | | | | This is just adding really simple tests which should have been part of the original submission. When doing so, I discovered that I'd mistakenly removed required pieces when preparing the patch for upstream submission. I fixed two such bugs in this submission. llvm-svn: 228610
* Fix a bug in DemoteRegToStack where a reload instruction was inserted into theAkira Hatanaka2015-02-091-18/+16
| | | | | | | | | | | | | | | | | | wrong basic block. This would happen when the result of an invoke was used by a phi instruction in the invoke's normal destination block. An instruction to reload the invoke's value would get inserted before the critical edge was split and a new basic block (which is the correct insertion point for the reload) was created. This commit fixes the bug by splitting the critical edge before all the reload instructions are inserted. Also, hoist up the code which computes the insertion point to the only place that need that computation. rdar://problem/15978721 llvm-svn: 228566
* DeadArgElim: fix mismatch in accounting of array return types.Tim Northover2015-02-091-39/+47
| | | | | | | | | | | | Some parts of DeadArgElim were only considering the individual fields of StructTypes separately, but others (where insertvalue & extractvalue instructions occur) also looked into ArrayTypes. This one is an actual bug; the mismatch can lead to an argument being considered used by a return sub-value that isn't being tracked (and hence is dead by default). It then gets incorrectly eliminated. llvm-svn: 228559
* DeadArgElim: assess uses of entire return value aggregate.Tim Northover2015-02-091-26/+26
| | | | | | | | | | | | | | | | | | | | | | | Previously, a non-extractvalue use of an aggregate return value meant the entire return was considered live (the algorithm gave up entirely). This was correct, but conservative. It's better to actually look at that Use, making the analysis results apply to all sub-values under consideration. E.g. %val = call { i32, i32 } @whatever() [...] ret { i32, i32 } %val The return is using the entire aggregate (sub-values 0 and 1). We can still simplify @whatever if we can prove that this return is itself unused. Also unifies the logic slightly between aggregate and non-aggregate cases.. llvm-svn: 228558
* InstCombine: propagate nonNull through assumeRamkumar Ramachandra2015-02-091-1/+8
| | | | | | | | | Make assume (load (call|invoke) != null) set nonNull return attribute for the call and invoke. Also include tests. Differential Revision: http://reviews.llvm.org/D7107 llvm-svn: 228556
* Correctly combine alias.scope metadata by a union instead of intersectingBjorn Steinbrink2015-02-082-0/+4
| | | | | | | | | | | | | | | | | Summary: The alias.scope metadata represents sets of things an instruction might alias with. When generically combining the metadata from two instructions the result must be the union of the original sets, because the new instruction might alias with anything any of the original instructions aliased with. Reviewers: hfinkel Subscribers: llvm-commits Differential Revision: http://reviews.llvm.org/D7490 llvm-svn: 228525
* LoopIdiom: Use utility functions.Benjamin Kramer2015-02-071-54/+15
| | | | | | | | | The only difference between deleteIfDeadInstruction and RecursivelyDeleteTriviallyDeadInstructions is that the former also manually invalidates SCEV. That's unnecessary because SCEV automatically gets informed when an instruction is deleted via a ValueHandle. NFC. llvm-svn: 228508
* Properly update AA metadata when performing call slot optimizationBjorn Steinbrink2015-02-071-0/+10
| | | | | | | | Subscribers: llvm-commits Differential Revision: http://reviews.llvm.org/D7482 llvm-svn: 228500
* [msan] Fix "missing origin" in atomic store.Evgeniy Stepanov2015-02-061-1/+1
| | | | | | | | | | An atomic store always make the target location fully initialized (in the current implementation). It should not store origin. Initialized memory can't have meaningful origin, and, due to origin granularity (4 bytes) there is a chance that this extra store would overwrite meaningfull origin for an adjacent location. llvm-svn: 228444
* Use estimated number of optimized insns in unroll-threshold computation.Michael Zolotukhin2015-02-061-2/+44
| | | | | | | | | | If complete-unroll could help us to optimize away N% of instructions, we might want to do this even if the final size would exceed loop-unroll threshold. However, we don't want to unroll huge loop, and we are add AbsoluteThreshold to avoid that - this threshold will never be crossed, even if we expect to optimize 99% instructions after that. llvm-svn: 228434
* [InstSimplify] Add SimplifyFPBinOp function.Michael Zolotukhin2015-02-061-1/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | It is a variation of SimplifyBinOp, but it takes into account FastMathFlags. It is needed in inliner and loop-unroller to accurately predict the transformation's outcome (previously we dropped the flags and were too conservative in some cases). Example: float foo(float *a, float b) { float r; if (a[1] * b) r = /* a lot of expensive computations */; else r = 1; return r; } float boo(float *a) { return foo(a, 0.0); } Without this patch, we don't inline 'foo' into 'boo'. llvm-svn: 228432
* [LV] Move addRuntimeCheck to LoopAccessAnalysisAdam Nemet2015-02-061-104/+5
| | | | | | | | | | | | | This will allow it to be shared with the new Loop Distribution pass. getFirstInst is currently duplicated across LoopVectorize.cpp and LoopAccessAnalysis.cpp. This is a short-term work-around until we figure out a better solution. NFC. (The code moved is adjusted a bit for the name of the Loop member and that PtrRtCheck is now a reference rather than a pointer.) llvm-svn: 228418
* Make helper functions/classes/globals static. NFC.Benjamin Kramer2015-02-062-5/+5
| | | | llvm-svn: 228410
* InstCombine: Combine select sequences into a single selectMatthias Braun2015-02-061-0/+18
| | | | | | | | | | | | | | Normalize select(C0, select(C1, a, b), b) -> select((C0 & C1), a, b) select(C0, a, select(C1, a, b)) -> select((C0 | C1), a, b) This normal form may enable further combines on the And/Or and shortens paths for the values. Many targets prefer the other but can go back easily in CodeGen. Differential Revision: http://reviews.llvm.org/D7399 llvm-svn: 228409
* IRCE: Demote template to ArrayRef and SmallVector to array.Benjamin Kramer2015-02-061-26/+15
| | | | | | NFC. llvm-svn: 228398
* [ASan] Enable -asan-stack-dynamic-alloca by default.Alexey Samsonov2015-02-051-1/+1
| | | | | | | | | | | By default, store all local variables in dynamic alloca instead of static one. It reduces the stack space usage in use-after-return mode (dynamic alloca will not be called if the local variables are stored in a fake stack), and improves the debug info quality for local variables (they will not be described relatively to %rbp/%rsp, which are assumed to be clobbered by function calls). llvm-svn: 228336
* LowerSwitch: Use ConstantInt for CaseRange::{Low,High}Hans Wennborg2015-02-051-20/+20
| | | | | | | Case values are always ConstantInt. This allows us to remove a bunch of casts. NFC. llvm-svn: 228312
* LowerSwitch: remove default args from CaseRange ctor; NFCHans Wennborg2015-02-051-3/+2
| | | | llvm-svn: 228311
* Removing an unused variable warning I accidentally introduced with my last ↵Aaron Ballman2015-02-051-1/+1
| | | | | | warning fix; NFC. llvm-svn: 228295
* Silencing an MSVC warning about a switch statement with no cases; NFC.Aaron Ballman2015-02-051-8/+5
| | | | llvm-svn: 228294
* Implement new heuristic for complete loop unrolling.Michael Zolotukhin2015-02-051-2/+332
| | | | | | | | | | | | | | | | | | | | | | | | | Complete loop unrolling can make some loads constant, thus enabling a lot of other optimizations. To catch such cases, we look for loads that might become constants and estimate number of instructions that would be simplified or become dead after substitution. Example: Suppose we have: int a[] = {0, 1, 0}; v = 0; for (i = 0; i < 3; i ++) v += b[i]*a[i]; If we completely unroll the loop, we would get: v = b[0]*a[0] + b[1]*a[1] + b[2]*a[2] Which then will be simplified to: v = b[0]* 0 + b[1]* 1 + b[2]* 0 And finally: v = b[1] llvm-svn: 228265
* StructurizeCFG: Remove obsolete fix for loop backedge detectionTom Stellard2015-02-041-1/+1
| | | | | | | This is no longer needed now that we are using a reverse post-order traversal. llvm-svn: 228187
* StructurizeCFG: Use a reverse post-order traversalTom Stellard2015-02-041-4/+64
| | | | | | | | | | | | | | We were previously doing a post-order traversal and operating on the list in reverse, however this would occasionaly cause backedges for loops to be visited before some of the other blocks in the loop. We know use a reverse post-order traversal, which avoids this issue. The reverse post-order traversal is not completely ideal, so we need to manually fixup the list to ensure that inner loop backedges are visited before outer loop backedges. llvm-svn: 228186
* Utils: Resolve cycles under distinct MDNodesDuncan P. N. Exon Smith2015-02-041-20/+45
| | | | | | | | Track unresolved nodes under distinct `MDNode`s during `MapMetadata()`, and resolve them at the end. Previously, these cycles wouldn't get resolved. llvm-svn: 228180
* Add range adapters predecessors() and successors() for BBsReid Kleckner2015-02-042-7/+6
| | | | | | | Use them in two isolated transforms so we know they work and aren't dead code. llvm-svn: 228173
* SpecialCaseList: Add support for parsing multiple input files.Alexey Samsonov2015-02-041-16/+21
| | | | | | | | | | | | | | | | | | | | | | | Summary: This change allows users to create SpecialCaseList objects from multiple local files. This is needed to implement a proper support for -fsanitize-blacklist flag (allow users to specify multiple blacklists, in addition to default blacklist, see PR22431). DFSan can also benefit from this change, as DFSan instrumentation pass now accepts ABI-lists both from -fsanitize-blacklist= and -mllvm -dfsan-abilist flags. Go bindings are fixed accordingly. Test Plan: regression test suite Reviewers: pcc Subscribers: llvm-commits, axw, kcc Differential Revision: http://reviews.llvm.org/D7367 llvm-svn: 228155
* Fixing a -Wsign-compare warning; NFCAaron Ballman2015-02-041-1/+1
| | | | llvm-svn: 228142
* Fix a warning in non-asserts buildsPhilip Reames2015-02-041-0/+1
| | | | llvm-svn: 228114
* [sanitizer] add another workaround for PR 17409: when over a threshold emit ↵Kostya Serebryany2015-02-041-24/+32
| | | | | | coverage instrumentation as calls. llvm-svn: 228102
* Clang format of a file introduced in 228090 (NFC)Philip Reames2015-02-041-29/+22
| | | | llvm-svn: 228091
* Add a pass for inserting safepoints into (nearly) arbitrary IRPhilip Reames2015-02-043-0/+982
| | | | | | | | | | | | | | | | | | | | | This pass is responsible for figuring out where to place call safepoints and safepoint polls. It doesn't actually make the relocations explicit; that's the job of the RewriteStatepointsForGC pass (http://reviews.llvm.org/D6975). Note that this code is not yet finalized. Its moving in tree for incremental development, but further cleanup is needed and will happen over the next few days. It is not yet part of the standard pass order. Planned changes in the near future: - I plan on restructuring the statepoint rewrite to use the functions add to the IRBuilder a while back. - In the current pass, the function "gc.safepoint_poll" is treated specially but is not an intrinsic. I plan to make identifying the poll function a property of the GCStrategy at some point in the near future. - As follow on patches, I will be separating a collection of test cases we have out of tree and submitting them upstream. - It's not explicit in the code, but these two patches are introducing a new state for a statepoint which looks a lot like a patchpoint. There's no a transient form which doesn't yet have the relocations explicitly represented, but does prevent reordering of memory operations. Once this is in, I need to update actually make this explicit by reserving the 'unused' argument of the statepoint as a flag, updating the docs, and making the code explicitly check for such a thing. This wasn't really planned, but once I split the two passes - which was done for other reasons - the intermediate state fell out. Just reminds us once again that we need to merge statepoints and patchpoints at some point in the not that distant future. Future directions planned: - Identifying more cases where a backedge safepoint isn't required to ensure timely execution of a safepoint poll. - Tweaking the insertion process to generate easier to optimize IR. (For example, investigating making SplitBackedge) the default. - Adding opt-in flags for a GCStrategy to use this pass. Once done, add this pass to the actual pass ordering. Differential Revision: http://reviews.llvm.org/D6981 llvm-svn: 228090
* [LV] Split off memcheck block really at the first checkAdam Nemet2015-02-031-1/+1
| | | | | | | | | | | I've noticed this while trying to move addRuntimeCheck to LoopAccessAnalysis. I think that the intention was to early exit from the overflow checking before the code for the memchecks. This is the entire reason why we compute FirstCheckInst but then we don't use that as the splitting instruction but the final check. Looks like an oversight. llvm-svn: 228056
* Allow PRE to insert no-cost phi nodesDaniel Berlin2015-02-031-44/+68
| | | | llvm-svn: 228024
* Add straight-line strength reduction to LLVMJingyue Wu2015-02-033-0/+276
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: Straight-line strength reduction (SLSR) is implemented in GCC but not yet in LLVM. It has proven to effectively simplify statements derived from an unrolled loop, and can potentially benefit many other cases too. For example, LLVM unrolls #pragma unroll foo (int i = 0; i < 3; ++i) { sum += foo((b + i) * s); } into sum += foo(b * s); sum += foo((b + 1) * s); sum += foo((b + 2) * s); However, no optimizations yet reduce the internal redundancy of the three expressions: b * s (b + 1) * s (b + 2) * s With SLSR, LLVM can optimize these three expressions into: t1 = b * s t2 = t1 + s t3 = t2 + s This commit is only an initial step towards implementing a series of such optimizations. I will implement more (see TODO in the file commentary) in the near future. This optimization is enabled for the NVPTX backend for now. However, I am more than happy to push it to the standard optimization pipeline after more thorough performance tests. Test Plan: test/StraightLineStrengthReduce/slsr.ll Reviewers: eliben, HaoLiu, meheff, hfinkel, jholewinski, atrick Reviewed By: jholewinski, atrick Subscribers: karthikthecool, jholewinski, llvm-commits Differential Revision: http://reviews.llvm.org/D7310 llvm-svn: 228016
* [LoopVectorize] Fix rebase glitch in r227751Adam Nemet2015-02-031-5/+3
| | | | | | | | | LoopVectorizationLegality::{getNumLoads,getNumStores} should forward to LoopAccessAnalysis now. Thanks to Takumi for noticing this! llvm-svn: 227992
* Adding AArch64 support to ASan instrumentationRenato Golin2015-02-031-0/+4
| | | | | | | | | | For the time being, it is still hardcoded to support only the 39 VA bits variant, I plan to work on supporting 42 and 48 VA bits variants, but I don't have access to such hardware at the moment. Patch by Chrystophe Lyon. llvm-svn: 227965
* Resurrect initializers for NumLoads and NumStores in ↵NAKAMURA Takumi2015-02-031-2/+3
| | | | | | | LoopVectorizationLegality to suppress undefined behavior. FIXME: Shall they be managed in LAA? llvm-svn: 227940
* Resurrect the assertion removed by r227717Jingyue Wu2015-02-022-9/+9
| | | | | | | | | | | | | | Summary: MSVC can compile "LoopID->getOperand(0) == LoopID" when LoopID is MDNode*. Test Plan: no regression Reviewers: mkuper Subscribers: jholewinski, llvm-commits Differential Revision: http://reviews.llvm.org/D7327 llvm-svn: 227853
* Fix: SLPVectorizer crashes with assertion when vectorizing a cmp instruction.Erik Eckstein2015-02-021-0/+1
| | | | | | | | | The commit r225977 uncovered this bug. The problem was that the vectorizer tried to read the second operand of an already deleted instruction. The bug didn't show up before r225977 because the freed memory still contained a non-null pointer. With r225977 deletion of instructions is delayed and the read operand pointer is always null. llvm-svn: 227800
* LoopVectorize: Remove initializer list that blocks MSVC.Benjamin Kramer2015-02-011-4/+4
| | | | llvm-svn: 227766
* [LoopVectorize] Move LoopAccessAnalysis to its own moduleAdam Nemet2015-02-011-1216/+1
| | | | | | | | | | | | | | | | | | | | Other than moving code and adding the boilerplate for the new files, the code being moved is unchanged. There are a few global functions that are shared with the rest of the LoopVectorizer. I moved these to the new module as well (emitLoopAnalysis, stripIntegerCast, replaceSymbolicStrideSCEV) along with the Report class used by emitLoopAnalysis. There is probably room for further improvement in this area. I kept DEBUG_TYPE "loop-vectorize" because it's used as the PassName with emitOptimizationRemarkAnalysis. This will obviously have to change. NFC. This is part of the patchset that splits out the memory dependence logic from LoopVectorizationLegality into a new class LoopAccessAnalysis. LoopAccessAnalysis will be used by the new Loop Distribution pass. llvm-svn: 227756
* [LoopVectorize] Move RuntimePointerCheck under LoopAccessAnalysisAdam Nemet2015-02-011-44/+49
| | | | | | | | | | | This class needs to remain public because it's used by LoopVectorizationLegality::addRuntimeCheck. NFC. This is part of the patchset that splits out the memory dependence logic from LoopVectorizationLegality into a new class LoopAccessAnalysis. LoopAccessAnalysis will be used by the new Loop Distribution pass. llvm-svn: 227755
* [LoopVectorize] Pass parameters explicitly to MemoryDepCheckerAdam Nemet2015-02-011-14/+51
| | | | | | | | | | | | | | | Rather than using globals use a structure to pass parameters from the vectorizer. This prepares the class to be moved outside the LoopVectorizer. It's not great how all this is passed through in LoopAccessAnalysis but this is all expected to change once the class start servicing the Loop Distribution pass as well where some of these parameters make no sense. NFC. This is part of the patchset that splits out the memory dependence logic from LoopVectorizationLegality into a new class LoopAccessAnalysis. LoopAccessAnalysis will be used by the new Loop Distribution pass. llvm-svn: 227754
* [LoopVectorize] Split out LoopAccessAnalysis from LoopVectorizationLegalityAdam Nemet2015-02-011-18/+85
| | | | | | | | | | | | | | Move the canVectorizeMemory functionality from LoopVectorizationLegality to a new class LoopAccessAnalysis and forward users. Currently the collection of the symbolic stride information is kept with LoopVectorizationLegality and it becomes an input to LoopAccessAnalysis. NFC. This is part of the patchset that splits out the memory dependence logic from LoopVectorizationLegality into a new class LoopAccessAnalysis. LoopAccessAnalysis will be used by the new Loop Distribution pass. llvm-svn: 227751
* [LoopVectorize] Add accessors for Num{Stores,Loads,PredStores} in AccessAnalysisAdam Nemet2015-02-011-7/+18
| | | | | | | | | | | These members are moving to LoopAccessAnalysis. The accessors help to hide this. NFC. This is part of the patchset that splits out the memory dependence logic from LoopVectorizationLegality into a new class LoopAccessAnalysis. LoopAccessAnalysis will be used by the new Loop Distribution pass. llvm-svn: 227750
* [LoopVectorize] Rename the Report class to VectorizationReportAdam Nemet2015-02-011-50/+72
| | | | | | | | | | | This class will become public in the new LoopAccessAnalysis header so the name needs to be more global. NFC. This is part of the patchset that splits out the memory dependence logic from LoopVectorizationLegality into a new class LoopAccessAnalysis. LoopAccessAnalysis will be used by the new Loop Distribution pass. llvm-svn: 227749
* [LoopVectorize] Factor out duplicated code into Report::emitAnalysisAdam Nemet2015-02-011-10/+16
| | | | | | | | | | | The logic in emitAnalysis is duplicated across multiple functions. This splits it into a function. Another use will be added by the patchset. NFC. This is part of the patchset that splits out the memory dependence logic from LoopVectorizationLegality into a new class LoopAccessAnalysis. LoopAccessAnalysis will be used by the new Loop Distribution pass. llvm-svn: 227748
* [LoopVectorize] Split out RuntimePointerCheck from LoopVectorizationLegalityAdam Nemet2015-02-011-46/+47
| | | | | | | | | | | | RuntimePointerCheck will be used through LoopAccessAnalysis in LoopVectorizationLegality. Later in the patchset it will become a local class of LoopAccessAnalysis. NFC. This is part of the patchset that splits out the memory dependence logic from LoopVectorizationLegality into a new class LoopAccessAnalysis. LoopAccessAnalysis will be used by the new Loop Distribution pass. llvm-svn: 227747
* [multiversion] Kill FunctionTargetTransformInfo, TTI itself is nowChandler Carruth2015-02-011-8/+3
| | | | | | per-function and supports the exact desired interface. llvm-svn: 227743
* EarlyCSE: Replace custom hash mixing with Hashing.hBenjamin Kramer2015-02-011-14/+4
| | | | | | Brings it in line with the other hashes in EarlyCSE. llvm-svn: 227733
OpenPOWER on IntegriCloud