summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms
Commit message (Collapse)AuthorAgeFilesLines
* [LoopInfo] Use early return in branch weight update functions. NFC.Serguei Katkov2019-07-181-29/+30
| | | | llvm-svn: 366411
* hwasan: Initialize the pass only once.Peter Collingbourne2019-07-171-6/+19
| | | | | | | | | | This will let us instrument globals during initialization. This required making the new PM pass a module pass, which should still provide access to analyses via the ModuleAnalysisManager. Differential Revision: https://reviews.llvm.org/D64843 llvm-svn: 366379
* [Attributor][NFC] Remove unnecessary debug outputHideto Ueno2019-07-171-1/+0
| | | | llvm-svn: 366373
* [Attributor] Deduce "willreturn" function attributeHideto Ueno2019-07-171-0/+120
| | | | | | | | | | | | | | | | | Summary: Deduce the "willreturn" attribute for functions. For now, intrinsics are not willreturn. More annotation will be done in another patch. Reviewers: jdoerfert Subscribers: jvesely, nhaehnle, nicholas, hiraditya, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D63046 llvm-svn: 366335
* [IndVars] Speculative fix for an assertion failure seen in botsPhilip Reames2019-07-161-1/+6
| | | | | | I don't have an IR sample which is actually failing, but the issue described in the comment is theoretically possible, and should be guarded against even if there's a different root cause for the bot failures. llvm-svn: 366241
* [ADCE] Fix non-deterministic behaviour due to iterating over a pointer set.Amara Emerson2019-07-161-3/+8
| | | | | | | | Original patch by Yann Laigle-Chapuy Differential Revision: https://reviews.llvm.org/D64785 llvm-svn: 366215
* Fix parameter name comments using clang-tidy. NFC.Rui Ueyama2019-07-1611-14/+14
| | | | | | | | | | | | | | | | | | | | | This patch applies clang-tidy's bugprone-argument-comment tool to LLVM, clang and lld source trees. Here is how I created this patch: $ git clone https://github.com/llvm/llvm-project.git $ cd llvm-project $ mkdir build $ cd build $ cmake -GNinja -DCMAKE_BUILD_TYPE=Debug \ -DLLVM_ENABLE_PROJECTS='clang;lld;clang-tools-extra' \ -DCMAKE_EXPORT_COMPILE_COMMANDS=On -DLLVM_ENABLE_LLD=On \ -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ ../llvm $ ninja $ parallel clang-tidy -checks='-*,bugprone-argument-comment' \ -config='{CheckOptions: [{key: StrictMode, value: 1}]}' -fix \ ::: ../llvm/lib/**/*.{cpp,h} ../clang/lib/**/*.{cpp,h} ../lld/**/*.{cpp,h} llvm-svn: 366177
* hwasan: Pad arrays with non-1 size correctly.Peter Collingbourne2019-07-161-5/+9
| | | | | | | | Spotted by eugenis. Differential Revision: https://reviews.llvm.org/D64783 llvm-svn: 366171
* Temporarily Revert "[SLP] Recommit: Look-ahead operand reordering heuristic."Eric Christopher2019-07-151-248/+46
| | | | | | | | | As there are some reported miscompiles with AVX512 and performance regressions in Eigen. Verified with the original committer and testcases will be forthcoming. This reverts commit r364964. llvm-svn: 366154
* Revert "[NewPM] Port Sancov"Leonard Chan2019-07-152-244/+117
| | | | | | This reverts commit 5652f35817f07b16f8b3856d594cc42f4d7ee29c. llvm-svn: 366153
* ARM MTE stack sanitizer.Evgeniy Stepanov2019-07-152-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | Add "memtag" sanitizer that detects and mitigates stack memory issues using armv8.5 Memory Tagging Extension. It is similar in principle to HWASan, which is a software implementation of the same idea, but there are enough differencies to warrant a new sanitizer type IMHO. It is also expected to have very different performance properties. The new sanitizer does not have a runtime library (it may grow one later, along with a "debugging" mode). Similar to SafeStack and StackProtector, the instrumentation pass (in a follow up change) will be inserted in all cases, but will only affect functions marked with the new sanitize_memtag attribute. Reviewers: pcc, hctim, vitalybuka, ostannard Subscribers: srhines, mehdi_amini, javed.absar, kristof.beyls, hiraditya, cryptoad, steven_wu, dexonsmith, cfe-commits, llvm-commits Tags: #clang, #llvm Differential Revision: https://reviews.llvm.org/D64169 llvm-svn: 366123
* [FunctionAttrs] Remove readonly and writeonly assertionJohannes Doerfert2019-07-151-2/+5
| | | | | | | | | | | | | There are scenarios where mutually recursive functions may cause the SCC to contain both read only and write only functions. This removes an assertion when adding read attributes which caused a crash with a the provided test case, and instead just doesn't add the attributes. Patch by Luke Lau <luke.lau@intel.com> Differential Revision: https://reviews.llvm.org/D60761 llvm-svn: 366090
* [Loop Peeling] Fix the bug with IDom setting for exit loopsSerguei Katkov2019-07-151-3/+18
| | | | | | | | | | | | | It is possible that loop exit has two predecessors in a loop body. In this case after the peeling the iDom of the exit should be a clone of iDom of original exit but no a clone of a block coming to this exit. Reviewers: reames, fhahn Reviewed By: reames Subscribers: hiraditya, zzheng, llvm-commits Differential Revision: https://reviews.llvm.org/D64618 llvm-svn: 366050
* [LoopVectorize] Pass unfiltered list of arguments to getIntrinsicInstCost.Florian Hahn2019-07-151-5/+2
| | | | | | | We do not compute the scalarization overhead in getVectorIntrinsicCost and TTI::getIntrinsicInstrCost requires the full arguments list. llvm-svn: 366049
* [Loop Peeling] Enable peeling for loops with multiple exitsSerguei Katkov2019-07-152-1/+22
| | | | | | | | | | | | | | | This CL enables peeling of the loop with multiple exits where one exit should be from latch and others are basic blocks with call to deopt. The peeling is enabled under the flag which is false by default. Reviewers: reames, mkuper, iajbar, fhahn Reviewed By: reames Subscribers: xbolva00, hiraditya, zzheng, llvm-commits Differential Revision: https://reviews.llvm.org/D63923 llvm-svn: 366048
* [Attributor] Deduce "nonnull" attributeHideto Ueno2019-07-151-0/+284
| | | | | | | | | | | | | | | | | Summary: Porting nonnull attribute to attributor. Reviewers: jdoerfert, sstefan1 Reviewed By: jdoerfert Subscribers: xbolva00, hiraditya, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D63604 llvm-svn: 366043
* [LoopUtils] Extend the scope of getLoopEstimatedTripCountSerguei Katkov2019-07-151-6/+14
| | | | | | | | | | | | | | | With this patch the getLoopEstimatedTripCount function will accept also the loops where there are more than one exit but all exits except latch block should ends up with a call to deopt. This side exits should not impact the estimated trip count. Reviewers: reames, mkuper, danielcdh Reviewed By: reames Subscribers: fhahn, lebedev.ri, hiraditya, llvm-commits Differential Revision: https://reviews.llvm.org/D64553 llvm-svn: 366042
* [LoopInfo] Introduce getUniqueNonLatchExitBlocks utility functionSerguei Katkov2019-07-151-13/+7
| | | | | | | | | | | | Extract the code from LoopUnrollRuntime into utility function to re-use it in D63923. Reviewers: reames, mkuper Reviewed By: reames Subscribers: fhahn, hiraditya, zzheng, dmgreen, llvm-commits Differential Revision: https://reviews.llvm.org/D64548 llvm-svn: 366040
* [LV] Exclude loop-invariant inputs from scalar cost computation.Florian Hahn2019-07-141-22/+42
| | | | | | | | | | | | | | | | Loop invariant operands do not need to be scalarized, as we are using the values outside the loop. We should ignore them when computing the scalarization overhead. Fixes PR41294 Reviewers: hsaito, rengolin, dcaballe, Ayal Reviewed By: Ayal Differential Revision: https://reviews.llvm.org/D59995 llvm-svn: 366030
* [Attributor][NFC] Run clang-format on the attributor files (.h/.cpp)Johannes Doerfert2019-07-131-12/+7
| | | | | | | The Attributor files are kept formatted with clang-format, we should try to keep this state. llvm-svn: 365984
* [Attributor] Only return attributes with a valid stateJohannes Doerfert2019-07-131-3/+2
| | | | | | | | | Attributor::getAAFor will now only return AbstractAttributes with a valid AbstractState. This simplifies call sites as they only need to check if the returned pointer is non-null. It also reduces the potential for accidental misuse. llvm-svn: 365983
* [MemorySSA] Use SetVector to avoid nondeterminism.Alina Sbirlea2019-07-124-7/+8
| | | | | | | | | | | | | | | | Summary: Use a SetVector for DeadBlockSet. Resolves PR42574. Reviewers: george.burgess.iv, uabelho, dblaikie Subscribers: jlebar, Prazek, mgrang, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D64601 llvm-svn: 365970
* [InstCombine] Disable fold from D64285 for non-integer typesDavid Bolvansky2019-07-121-0/+2
| | | | llvm-svn: 365959
* The variable "Latch" is only used in an assert, which makes builds that use ↵Sterling Augustine2019-07-121-2/+1
| | | | | | | | | | | | | | "-DNDEBUG" fail with unused variable messages. Summary: Move the logic into the assert itself. Subscribers: hiraditya, sanjoy, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D64654 llvm-svn: 365943
* Addition to rL365925, removing remaining virtualsStefan Stipanovic2019-07-121-5/+5
| | | | llvm-svn: 365938
* Remove unused methods in Sancov.Leonard Chan2019-07-121-27/+6
| | | | llvm-svn: 365931
* [Attributor] Removing unnecessary `virtual` keywords.Stefan Stipanovic2019-07-121-12/+12
| | | | | | | | | | | | | Some function in the Attributor framework are unnecessarily marked virtual. This patch removes virtual keyword Reviewers: jdoerfert Subscribers: hiraditya, llvm-commits Differential Revision: https://reviews.llvm.org/D64637 llvm-svn: 365925
* [Attributor] Deduce "nofree" function attributeHideto Ueno2019-07-121-0/+70
| | | | | | | | | | | | | | | | Summary: Deduce "nofree" function attribute. A more concise description of "nofree" is on D49165. Reviewers: jdoerfert Reviewed By: jdoerfert Subscribers: homerdin, hfinkel, lebedev.ri, hiraditya, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D62687 llvm-svn: 365924
* [IndVars] Use exit count reasoning to discharge obviously untaken exitsPhilip Reames2019-07-121-17/+110
| | | | | | | | | | Continue in the spirit of D63618, and use exit count reasoning to prove away loop exits which can not be taken since the backedge taken count of the loop as a whole is provably less than the minimal BE count required to take this particular loop exit. As demonstrated in the newly added tests, this triggers in a number of cases where IndVars was previously unable to discharge obviously redundant exit tests. And some not so obvious ones. Differential Revision: https://reviews.llvm.org/D63733 llvm-svn: 365920
* Delete dead storesFangrui Song2019-07-124-12/+5
| | | | llvm-svn: 365903
* [InstCombine] Fold select (icmp sgt x, -1), lshr (X, Y), ashr (X, Y) to ashr ↵David Bolvansky2019-07-121-0/+41
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | (X, Y)) Summary: (select (icmp sgt x, -1), lshr (X, Y), ashr (X, Y)) -> ashr (X, Y)) (select (icmp slt x, 1), ashr (X, Y), lshr (X, Y)) -> ashr (X, Y)) Fixes PR41173 Alive proof by @lebedev.ri (thanks) Name: PR41173 %cmp = icmp slt i32 %x, 1 %shr = lshr i32 %x, %y %shr1 = ashr i32 %x, %y %retval.0 = select i1 %cmp, i32 %shr1, i32 %shr => %retval.0 = ashr i32 %x, %y Optimization: PR41173 Done: 1 Optimization is correct! Reviewers: lebedev.ri, spatel Reviewed By: lebedev.ri Subscribers: nikic, craig.topper, llvm-commits, lebedev.ri Tags: #llvm Differential Revision: https://reviews.llvm.org/D64285 llvm-svn: 365893
* [InstCombine] Reorder pow() transformations (NFC)Evandro Menezes2019-07-121-23/+19
| | | | | | | Move the transformation from `powf(x, itofp(y))` to `powi(x, y)` to the group of transformations related to the exponent. llvm-svn: 365851
* [NewPM] Port SancovLeonard Chan2019-07-112-110/+258
| | | | | | | | | | | | | | | | | This patch contains a port of SanitizerCoverage to the new pass manager. This one's a bit hefty. Changes: - Split SanitizerCoverageModule into 2 SanitizerCoverage for passing over functions and ModuleSanitizerCoverage for passing over modules. - ModuleSanitizerCoverage exists for adding 2 module level calls to initialization functions but only if there's a function that was instrumented by sancov. - Added legacy and new PM wrapper classes that own instances of the 2 new classes. - Update llvm tests and add clang tests. Differential Revision: https://reviews.llvm.org/D62888 llvm-svn: 365838
* [Attributor] Deduce "nosync" function attribute.Stefan Stipanovic2019-07-112-0/+194
| | | | | | | | | | | | | | Introduce and deduce "nosync" function attribute to indicate that a function does not synchronize with another thread in a way that other thread might free memory. Reviewers: jdoerfert, jfb, nhaehnle, arsenm Subscribers: wdng, hfinkel, nhaenhle, mehdi_amini, steven_wu, dexonsmith, arsenm, uenoku, hiraditya, jfb, llvm-commits Differential Revision: https://reviews.llvm.org/D62766 llvm-svn: 365830
* [InstCombine] don't move FP negation out of a constant expressionSanjay Patel2019-07-111-2/+4
| | | | | | | -(X * ConstExpr) becomes X * (-ConstExpr), so don't reverse that and infinite loop. llvm-svn: 365774
* OpaquePtr: use load instruction directly for type. NFC.Tim Northover2019-07-111-2/+1
| | | | llvm-svn: 365768
* [InstCombine] Reorder recently added/improved pow transformationsDavid Bolvansky2019-07-111-3/+3
| | | | | | Changed cases are now faster with exp2. llvm-svn: 365758
* NFC: Pass DataLayout into isBytewiseValueVitaly Buka2019-07-102-7/+8
| | | | | | | | | | | | | | | | | | Summary: We will need to handle IntToPtr which I will submit in a separate patch as it's not going to be NFC. Reviewers: eugenis, pcc Reviewed By: eugenis Subscribers: hiraditya, cfe-commits, llvm-commits Tags: #clang, #llvm Differential Revision: https://reviews.llvm.org/D63940 llvm-svn: 365709
* [LoopRotate + MemorySSA] Keep an <instruction-cloned instruction> map.Alina Sbirlea2019-07-101-4/+8
| | | | | | | | | | | | | | | | | | | | Summary: The map kept in loop rotate is used for instruction remapping, in order to simplify the clones of instructions. Thus, if an instruction can be simplified, its simplified value is placed in the map, even when the clone is added to the IR. MemorySSA in contrast needs to know about that clone, so it can add an access for it. To resolve this: keep a different map for MemorySSA. Reviewers: george.burgess.iv Subscribers: jlebar, Prazek, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D63680 llvm-svn: 365672
* [CodeExtractor] Fix sinking of allocas with multiple bitcast uses (PR42451)Vedant Kumar2019-07-101-13/+29
| | | | | | | | | | | | | | An alloca which can be sunk into the extraction region may have more than one bitcast use. Move these uses along with the alloca to prevent use-before-def. Testing: check-llvm, stage2 build of clang Fixes llvm.org/PR42451. Differential Revision: https://reviews.llvm.org/D64463 llvm-svn: 365660
* [CodeExtractor] Simplify findAllocas, NFCVedant Kumar2019-07-101-73/+91
| | | | | | | | | Split getLifetimeMarkers out into its own method and have it return a struct. Differential Revision: https://reviews.llvm.org/D64467 llvm-svn: 365659
* [PatternMatch] Generalize m_SpecificInt_ULT() to take ICmpInst::PredicateRoman Lebedev2019-07-102-2/+4
| | | | | | | As discussed in the original review, this may be useful, so let's just do it. llvm-svn: 365652
* [InstCombine] pow(C,x) -> exp2(log2(C)*x)David Bolvansky2019-07-101-1/+24
| | | | | | | | | | | | | | | | | | | | | | | | | Summary: Transform pow(C,x) To exp2(log2(C)*x) if C > 0, C != inf, C != NaN (and C is not power of 2, since we have some fold for such case already). log(C) is folded by the compiler and exp2 is much faster to compute than pow. Reviewers: spatel, efriedma, evandro Reviewed By: evandro Subscribers: lebedev.ri, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D64099 llvm-svn: 365637
* [SimpleLoopUnswitch] Don't consider unswitching `switch` insructions with ↵Serguei Katkov2019-07-101-1/+1
| | | | | | | | | | | | | | | one unique successor Only instructions with two or more unique successors should be considered for unswitching. Patch Author: Daniil Suchkov. Reviewers: reames, asbirlea, skatkov Reviewed By: skatkov Subscribers: hiraditya, llvm-commits Differential Revision: https://reviews.llvm.org/D64404 llvm-svn: 365611
* [SLP] Optimize getSpillCost(); NFCINikita Popov2019-07-091-6/+10
| | | | | | | | | | | | For a given set of live values, the spill cost will always be the same for each call. Compute the cost once and multiply it by the number of calls. (I'm not sure this spill cost modeling makes sense if there are multiple calls, as the spill cost will likely be shared across calls in that case. But that's how it currently works.) llvm-svn: 365552
* hwasan: Improve precision of checks using short granule tags.Peter Collingbourne2019-07-091-14/+84
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | A short granule is a granule of size between 1 and `TG-1` bytes. The size of a short granule is stored at the location in shadow memory where the granule's tag is normally stored, while the granule's actual tag is stored in the last byte of the granule. This means that in order to verify that a pointer tag matches a memory tag, HWASAN must check for two possibilities: * the pointer tag is equal to the memory tag in shadow memory, or * the shadow memory tag is actually a short granule size, the value being loaded is in bounds of the granule and the pointer tag is equal to the last byte of the granule. Pointer tags between 1 to `TG-1` are possible and are as likely as any other tag. This means that these tags in memory have two interpretations: the full tag interpretation (where the pointer tag is between 1 and `TG-1` and the last byte of the granule is ordinary data) and the short tag interpretation (where the pointer tag is stored in the granule). When HWASAN detects an error near a memory tag between 1 and `TG-1`, it will show both the memory tag and the last byte of the granule. Currently, it is up to the user to disambiguate the two possibilities. Because this functionality obsoletes the right aligned heap feature of the HWASAN memory allocator (and because we can no longer easily test it), the feature is removed. Also update the documentation to cover both short granule tags and outlined checks. Differential Revision: https://reviews.llvm.org/D63908 llvm-svn: 365551
* [PoisonChecking] Flesh out complete todo list for full coveragePhilip Reames2019-07-091-8/+24
| | | | | Note: I don't actually plan to implement all of the cases at the moment, I'm just documenting them for completeness. There's a couple of cases left which are practically useful for me in debugging loop transforms, and I'll probably stop there for the moment. llvm-svn: 365550
* [PoisonCheker] Support for out of bounds operands on shifts + ↵Philip Reames2019-07-091-1/+41
| | | | | | | | insert/extractelement These are sources of poison which don't come from flags, but are clearly documented in the LangRef. Left off support for scalable vectors for the moment, but should be easy to add if anyone is interested. llvm-svn: 365543
* [PoisonChecking] Add validation rules for "exact" on sdiv/udivPhilip Reames2019-07-091-0/+18
| | | | | | As directly stated in the LangRef, no ambiguity here... llvm-svn: 365538
* Add a transform pass to make the executable semantics of poison explicit in ↵Philip Reames2019-07-092-0/+284
| | | | | | | | | | | | | | | | the IR Implements a transform pass which instruments IR such that poison semantics are made explicit. That is, it provides a (possibly partial) executable semantics for every instruction w.r.t. poison as specified in the LLVM LangRef. There are obvious parallels to the sanitizer tools, but this pass is focused purely on the semantics of LLVM IR, not any particular source language. The target audience for this tool is developers working on or targetting LLVM from a frontend. The idea is to be able to take arbitrary IR (with the assumption of known inputs), and evaluate it concretely after having made poison semantics explicit to detect cases where either a) the original code executes UB, or b) a transform pass introduces UB which didn't exist in the original program. At the moment, this is mostly the framework and still needs to be fleshed out. By reusing existing code we have decent coverage, but there's a lot of cases not yet handled. What's here is good enough to handle interesting cases though; for instance, one of the recent LFTR bugs involved UB being triggered by integer induction variables with nsw/nuw flags would be reported by the current code. (See comment in PoisonChecking.cpp for full explanation and context) Differential Revision: https://reviews.llvm.org/D64215 llvm-svn: 365536
OpenPOWER on IntegriCloud