summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms
Commit message (Collapse)AuthorAgeFilesLines
* asan: do not instrument direct inbounds accesses to stack variablesDmitry Vyukov2015-03-041-263/+285
| | | | | | | | | | | | | | | Do not instrument direct accesses to stack variables that can be proven to be inbounds, e.g. accesses to fields of structs on stack. But it eliminates 33% of instrumentation on webrtc/modules_unittests (number of memory accesses goes down from 290152 to 193998) and reduces binary size by 15% (from 74M to 64M) and improved compilation time by 6-12%. The optimization is guarded by asan-opt-stack flag that is off by default. http://reviews.llvm.org/D7583 llvm-svn: 231241
* [RewriteStatepointsForGC] Fix a relocation bug w.r.t values defined by ↵Philip Reames2015-03-041-2/+12
| | | | | | | | | | | | | | | invoke instructions RewriteStatepointsForGC pass emits an alloca for each GC pointer which will be relocated. It then inserts stores after def and all relocations, and inserts loads before each use as well. In the end, mem2reg is used to update IR with relocations in SSA form. However, there is a problem with inserting stores for values defined by invoke instructions. The code didn't expect a def was a terminator instruction, and inserting instructions after these terminators resulted in malformed IR. This patch fixes this problem by handling invoke instructions as a special case. If the def is an invoke instruction, the store will be inserted at the beginning of the normal destination block. Since return value from invoke instruction does not dominate the unwind destination block, no action is needed there. Patch by: Chen Li Differential Revision: http://reviews.llvm.org/D7923 llvm-svn: 231183
* [sanitizer/coverage] Add AFL-style coverage counters (search heuristic for ↵Kostya Serebryany2015-03-031-7/+55
| | | | | | | | | | | | | | | | | | | | | | | | | fuzzing). Introduce -mllvm -sanitizer-coverage-8bit-counters=1 which adds imprecise thread-unfriendly 8-bit coverage counters. The run-time library maps these 8-bit counters to 8-bit bitsets in the same way AFL (http://lcamtuf.coredump.cx/afl/technical_details.txt) does: counter values are divided into 8 ranges and based on the counter value one of the bits in the bitset is set. The AFL ranges are used here: 1, 2, 3, 4-7, 8-15, 16-31, 32-127, 128+. These counters provide a search heuristic for single-threaded coverage-guided fuzzers, we do not expect them to be useful for other purposes. Depending on the value of -fsanitize-coverage=[123] flag, these counters will be added to the function entry blocks (=1), every basic block (=2), or every edge (=3). Use these counters as an optional search heuristic in the Fuzzer library. Add a test where this heuristic is critical. llvm-svn: 231166
* InstCombine: Ensure select condition types are identical before mergingDavid Majnemer2015-03-031-28/+32
| | | | | | | | | | Selection conditions may be vectors or scalars. Make sure InstCombine doesn't indiscriminately assume that a select which is value dependent on another select have identical select condition types. This fixes PR22773. llvm-svn: 231156
* RewriteStatepointsForGC::PhiState: Remove explicit copy ctor in favor of the ↵David Blaikie2015-03-031-3/+0
| | | | | | | | | | | | Rule of Zero The assertion was just checking a class invariant that's pretty easy to verify by inspection (no mutating operations, and the two non-copy ctors already ensure the state is maintained) so remove the explicit copy ctor in favor of the default, thus allowing the use of the default copy assignment operator without hitting the C++11 deprecation here. llvm-svn: 231143
* Revert "Remove the explicit SDNodeIterator::operator= in favor of the ↵David Blaikie2015-03-031-1/+0
| | | | | | | | | | | implicit default" Accidentally committed a few more of these cleanup changes than intended. Still breaking these out & tidying them up. This reverts commit r231135. llvm-svn: 231136
* Remove the explicit SDNodeIterator::operator= in favor of the implicit defaultDavid Blaikie2015-03-031-0/+1
| | | | | | | | | | There doesn't seem to be any need to assert that iterator assignment is between iterators over the same node - if you want to reuse an iterator variable to iterate another node, that's perfectly acceptable. Just don't mix comparisons between iterators into disjoint sequences, as usual. llvm-svn: 231135
* LowerBitSets: Use byte arrays instead of bit sets to represent in-memory bit ↵Peter Collingbourne2015-03-031-64/+156
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | sets. By loading from indexed offsets into a byte array and applying a mask, a program can test bits from the bit set with a relatively short instruction sequence. For example, suppose we have 15 bit sets to lay out: A (16 bits), B (15 bits), C (14 bits), D (13 bits), E (12 bits), F (11 bits), G (10 bits), H (9 bits), I (7 bits), J (6 bits), K (5 bits), L (4 bits), M (3 bits), N (2 bits), O (1 bit) These bits can be laid out in a 16-byte array like this: Byte Offset 0123456789ABCDEF Bit 7 HHHHHHHHHIIIIIII 6 GGGGGGGGGGJJJJJJ 5 FFFFFFFFFFFKKKKK 4 EEEEEEEEEEEELLLL 3 DDDDDDDDDDDDDMMM 2 CCCCCCCCCCCCCCNN 1 BBBBBBBBBBBBBBBO 0 AAAAAAAAAAAAAAAA For example, to test bit X of A, we evaluate ((bits[X] & 1) != 0), or to test bit X of I, we evaluate ((bits[9 + X] & 0x80) != 0). This can be done in 1-2 machine instructions on x86, or 4-6 instructions on ARM. This uses the LPT multiprocessor scheduling algorithm to lay out the bits efficiently. Saves ~450KB of instructions in a recent build of Chromium. Differential Revision: http://reviews.llvm.org/D7954 llvm-svn: 231043
* LoopIdiom: Give globals for memset_pattern16 private linkage.Benjamin Kramer2015-03-031-1/+1
| | | | | | | | There's really no reason to have them have entries in the symbol table anymore. Old versions of ld64 had some bugs in this area but those have been fixed long ago. llvm-svn: 231041
* Revert some changes that were made to fix PR20680.Sanjoy Das2015-03-021-42/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | This re-lands change r230921. r230921 was reverted because it broke a clang test; a checkin fixing the clang test will be commited shortly. Summary: As far as I can tell, the real bug causing the issue was fixed in r230533. SCEVExpander should mark an increment operation as nuw or nsw only if it can *prove* that the operation does not overflow. There shouldn't be any situation where we have to do something different because of no-wrap flags generated by SCEVExpander. Revert "IndVarSimplify: Allow LFTR to fire more often" This reverts commit 1ade0f0faa98877b688e0b9da58e876052c1e04e (SVN: 222213). Revert "IndVarSimplify: Don't let LFTR compare against a poison value" This reverts commit c0f2b8b528d8a37b0a1522aae90af649d6357eb5 (SVN: 217102). Reviewers: majnemer, atrick, spatel Differential Revision: http://reviews.llvm.org/D7979 llvm-svn: 231018
* Make ToVectorTy static.Michael Zolotukhin2015-03-021-11/+9
| | | | llvm-svn: 231007
* SLPVectorizer: Rewrite ArrayRef slice compare to be more idiomatic.Benjamin Kramer2015-03-021-9/+5
| | | | | | NFC intended. llvm-svn: 230965
* Revert r230921, "Revert some changes that were made to fix PR20680.", for now.NAKAMURA Takumi2015-03-021-6/+42
| | | | | | It caused a failure on clang/test/Misc/backend-optimization-failure.cpp . llvm-svn: 230929
* Revert some changes that were made to fix PR20680.Sanjoy Das2015-03-011-42/+6
| | | | | | | | | | | | | | | | | | | | | | | Summary: As far as I can tell, the real bug causing the issue was fixed in r230533. SCEVExpander should mark an increment operation as nuw or nsw only if it can *prove* that the operation does not overflow. There shouldn't be any situation where we have to do something different because of no-wrap flags generated by SCEVExpander. Revert "IndVarSimplify: Allow LFTR to fire more often" This reverts commit 1ade0f0faa98877b688e0b9da58e876052c1e04e (SVN: 222213). Revert "IndVarSimplify: Don't let LFTR compare against a poison value" This reverts commit c0f2b8b528d8a37b0a1522aae90af649d6357eb5 (SVN: 217102). Reviewers: majnemer, atrick, spatel Differential Revision: http://reviews.llvm.org/D7979 llvm-svn: 230921
* TRE: Just erase dead BBs and tweak the iteration loop not to increment the ↵Benjamin Kramer2015-02-281-19/+7
| | | | | | | | | | | deleted BB iterator. Leaving empty blocks around just opens up a can of bugs like PR22704. Deleting them early also slightly simplifies code. Thanks to Sanjay for the IR test case. llvm-svn: 230856
* Convert push_back loops into append calls.Benjamin Kramer2015-02-281-2/+1
| | | | | | No functionality change intended. llvm-svn: 230849
* Silence variable set but not used warning, NFC.Yaron Keren2015-02-281-2/+3
| | | | llvm-svn: 230848
* Replace std::copy with a back inserter with vector append where feasibleBenjamin Kramer2015-02-281-1/+1
| | | | | | | | | All of the cases were just appending from random access iterators to a vector. Using insert/append can grow the vector to the perfect size directly and moves the growing out of the loop. No intended functionalty change. llvm-svn: 230845
* [RewriteStatepointsForGC] Reduce indentation via early continue [NFC]Philip Reames2015-02-281-81/+82
| | | | llvm-svn: 230836
* [RewriteStatepointsForGC] Fix another order of iteration bugPhilip Reames2015-02-281-4/+20
| | | | | | | | | | | | It turns out the naming of inserted phis and selects is sensative to the order in which two sets are iterated. We need to nail this down to avoid non-deterministic output and possible test failures. The modified test is the one I first noticed something odd in. The change is making it more strict to report the error. With the test change, but without the code change, the test fails roughly 1 in 5. With the code change, I've run ~30 runs without error. Long term, the right fix here is to adjust the naming scheme. I'm checking in this hack to avoid any possible non-determinism in the tests over the weekend. HJust because I only noticed one case doesn't mean it's actually the only case. I hope to get to the right change Monday. std->llvm data structure changes bugfix change #3 llvm-svn: 230835
* [RewriteStatepointsForGC] Reduce indentation via early continue [NFC]Philip Reames2015-02-281-35/+36
| | | | llvm-svn: 230829
* [RewriteStatepointsForGC] Fix iterator invalidation bugPhilip Reames2015-02-281-2/+11
| | | | | | | | Inserting into a DenseMap you're iterating over is not well defined. This is unfortunate since this is well defined on a std::map. "cleanup per llvm code style standards" bug #2 llvm-svn: 230827
* [RewriteStatepointsForGC] Add tests for the base pointer identification ↵Philip Reames2015-02-281-2/+11
| | | | | | | | | | | | algorithm These tests cover the 'base object' identification and rewritting portion of RewriteStatepointsForGC. These aren't completely exhaustive, but they've proven to be reasonable effective over time at finding regressions. In the process of porting these tests over, I found my first "cleanup per llvm code style standards" bug. We were relying on the order of iteration when testing the base pointers found for a derived pointer. When we switched from std::set to DenseSet, this stopped being a safe assumption. I'm suspecting I'm going to find more of those. In particular, I'm now really wondering about the main iteration loop for this algorithm. I need to go take a closer look at the assumptions there. I'm not really happy with the fact these are testing what is essentially debug output (i.e. enabled via command line flags). Suggestions for how to structure this better are very welcome. llvm-svn: 230818
* remove function names from comments; NFCSanjay Patel2015-02-271-20/+15
| | | | llvm-svn: 230766
* [asan] Skip promotable allocas to improve performance at -O0Anna Zaks2015-02-271-31/+51
| | | | | | | | | | | | Currently, the ASan executables built with -O0 are unnecessarily slow. The main reason is that ASan instrumentation pass inserts redundant checks around promotable allocas. These allocas do not get instrumented under -O1 because they get converted to virtual registered by mem2reg. With this patch, ASan instrumentation pass will only instrument non promotable allocas, giving us a speedup of 39% on a collection of benchmarks with -O0. (There is no measurable speedup at -O1.) llvm-svn: 230724
* Remove DebugLoc::print(LLVMContext, raw_ostream), it was justEric Christopher2015-02-261-1/+1
| | | | | | forwarding to the one that didn't take a context. llvm-svn: 230700
* [InstCombine/PowerPC] Convert aligned QPX load/store intrinsics into ↵Hal Finkel2015-02-261-0/+38
| | | | | | | | | | loads/stores InstCombine has long had logic to convert aligned Altivec load/store intrinsics into regular loads and stores. This mirrors that functionality for QPX vector load/store intrinsics. llvm-svn: 230660
* IRCE: only touch loops that have been shown to have a highSanjoy Das2015-02-261-4/+17
| | | | | | backedge-taken count in profiliing data. llvm-svn: 230619
* IRCE: generalize to handle loops with decreasing induction variables.Sanjoy Das2015-02-261-207/+358
| | | | | | | | | IRCE can now split the iteration space for loops like: for (i = n; i >= 0; i--) a[i + k] = 42; // bounds check on access llvm-svn: 230618
* IRCE: print newline after printing an InductiveRangeCheck.Sanjoy Das2015-02-261-0/+1
| | | | llvm-svn: 230607
* PlaceSafepoints: use IRBuilder helpersRamkumar Ramachandra2015-02-261-44/+39
| | | | | | | | | | Use the IRBuilder helpers for gc.statepoint and gc.result, instead of coding the construction by hand. Note that the gc.statepoint IRBuilder handles only CallInst, not InvokeInst; retain that part of hand-coding. Differential Revision: http://reviews.llvm.org/D7518 llvm-svn: 230591
* InstrProf: Make the __llvm_profile_runtime_user symbol hiddenJustin Bogner2015-02-251-0/+1
| | | | | | | | | This symbol exists only to pull in the required pieces of the runtime, so nothing ever needs to refer to it. Making it hidden avoids the potential for issues with duplicate symbols when linking profiled libraries together. llvm-svn: 230566
* only propagate equality comparisons of FP values that we are certain are ↵Sanjay Patel2015-02-251-3/+7
| | | | | | | | | | | | non-zero This is a follow-on to r227491 which tightens the check for propagating FP values. If a non-constant value happens to be a zero, we would hit the same bug as before. Bug noted and patch suggested by Eli Friedman. llvm-svn: 230564
* InstCombine: extract instead of shuffle when performing vector/array type ↵JF Bastien2015-02-251-5/+116
| | | | | | | | | | | | | punning Summary: SROA generates code that isn't quite as easy to optimize and contains unusual-sized shuffles, but that code is generally correct. As discussed in D7487 the right place to clean things up is InstCombine, which will pick up the type-punning pattern and transform it into a more obvious bitcast+extractelement, while leaving the other patterns SROA encounters as-is. Test Plan: make check Reviewers: jvoung, chandlerc Subscribers: llvm-commits llvm-svn: 230560
* LowerBitSets: Align referenced globals.Peter Collingbourne2015-02-251-22/+40
| | | | | | | | | | | | | | | | This change aligns globals to the next highest power of 2 bytes, up to a maximum of 128. This makes it more likely that we will be able to compress bit sets with a greater alignment. In many more cases, we can now take advantage of a new optimization also introduced in this patch that removes bit set checks if the bit set is all ones. The 128 byte maximum was found to provide the best tradeoff between instruction overhead and data overhead in a recent build of Chromium. It allows us to remove ~2.4MB of instructions at the cost of ~250KB of data. Differential Revision: http://reviews.llvm.org/D7873 llvm-svn: 230540
* [IC] Turn non-null MD on pointer loads to range MD on integer loads.Charles Davis2015-02-251-4/+18
| | | | | | | | | | | | | | | | | Summary: This change fixes the FIXME that you recently added when you committed (a modified version of) my patch. When `InstCombine` combines a load and store of an pointer to those of an equivalently-sized integer, it currently drops any `!nonnull` metadata that might be present. This change replaces `!nonnull` metadata with `!range !{ 1, -1 }` metadata instead. Reviewers: chandlerc Subscribers: llvm-commits Differential Revision: http://reviews.llvm.org/D7621 llvm-svn: 230462
* LowerBitSets: Introduce global layout builder.Peter Collingbourne2015-02-241-10/+78
| | | | | | | | | | The builder is based on a layout algorithm that tries to keep members of small bit sets together. The new layout compresses Chromium's bit sets to around 15% of their original size. Differential Revision: http://reviews.llvm.org/D7796 llvm-svn: 230394
* remove function names from comments; NFCSanjay Patel2015-02-241-42/+38
| | | | llvm-svn: 230391
* Fix alloca_instruments_all_paddings.cc test to work under higher -O levels ↵Kuba Brecka2015-02-241-7/+5
| | | | | | | | | | (llvm part) When AddressSanitizer only a single dynamic alloca and no static allocas, due to an early exit from FunctionStackPoisoner::poisonStack we forget to unpoison the dynamic alloca. This patch fixes that. Reviewed at http://reviews.llvm.org/D7810 llvm-svn: 230316
* New instcombine rule: max(~a,~b) -> ~min(a, b)Sanjoy Das2015-02-243-23/+66
| | | | | | | | | | This case is interesting because ScalarEvolutionExpander lowers min(a, b) as ~max(~a,~b). I think the profitability heuristics can be made more clever/aggressive, but this is a start. Differential Revision: http://reviews.llvm.org/D7821 llvm-svn: 230285
* add newline for easier reading; NFCSanjay Patel2015-02-231-1/+1
| | | | llvm-svn: 230265
* Remap frame variables for native Windows exception handling.Andrew Kaylor2015-02-231-2/+22
| | | | | | Differential Revision: http://reviews.llvm.org/D7770 llvm-svn: 230249
* Prevent hoisting fmul from THEN/ELSE to IF if there is fmsub/fmadd opportunity.Chad Rosier2015-02-231-2/+6
| | | | | | | | | | | This patch adds the isProfitableToHoist API. For AArch64, we want to prevent a fmul from being hoisted in cases where it is more profitable to form a fmsub/fmadd. Phabricator Review: http://reviews.llvm.org/D7299 Patch by Lawrence Hu <lawrence@codeaurora.org> llvm-svn: 230241
* InstSimplify: simplify 0 / X if nnan and nszMehdi Amini2015-02-231-2/+4
| | | | | From: Fiona Glaser <fglaser@apple.com> llvm-svn: 230238
* Roll condition into an assert then wrap it 'ifndef NDEBUG' to protect from ↵David Blaikie2015-02-221-8/+7
| | | | | | the inevitable "unused variable" warning in a non-asserts build. llvm-svn: 230181
* [LICM] Refactor to expose functionality as utility functionsHal Finkel2015-02-221-173/+199
| | | | | | | | | | | This refactors the core functionality of LICM: HoistRegion, SinkRegion and PromoteAliasSet (renamed to promoteLoopAccessesToScalars) as utility functions in LoopUtils. This will enable other transformations to make use of them directly. Patch by Ashutosh Nema. llvm-svn: 230178
* RewriteStatepointsForGC.cpp: Fix for -Asserts to mark isNullConstant() as ↵NAKAMURA Takumi2015-02-221-1/+1
| | | | | | LLVM_ATTRIBUTE_UNUSED. [-Wunused-function] llvm-svn: 230169
* RewriteStatepointsForGC.cpp: Fix for -Asserts. [-Wunused-variable]NAKAMURA Takumi2015-02-221-2/+1
| | | | llvm-svn: 230168
* LowerBitSets.cpp: Prune incorrect \param(s). [-Wdocumentation]NAKAMURA Takumi2015-02-221-6/+6
| | | | | | \param should be used as itemized. llvm-svn: 230167
* IRCE: generalize InductiveRangeCheck::computeSafeIterationSpace toSanjoy Das2015-02-211-32/+57
| | | | | | | | | | work with a non-canonical induction variable. This is currently a non-functional change because we only ever call computeSafeIterationSpace on a canonical induction variable; but the generalization will be useful in a later commit. llvm-svn: 230151
OpenPOWER on IntegriCloud