summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms/IPO/Attributor.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* [Attributor] Use Alias Analysis in noalias callsite argument deductionHideto Ueno2019-09-171-5/+12
| | | | | | | | | | | | | | | | Summary: This patch adds a check of alias analysis in `noalias` callsite argument deduction. Reviewers: jdoerfert, sstefan1 Reviewed By: jdoerfert Subscribers: hiraditya, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D67604 llvm-svn: 372075
* [Attributor] Create helper struct for handling analysis gettersHideto Ueno2019-09-171-18/+8
| | | | | | | | | | | | | | | | Summary: This patch introduces a helper struct `AnalysisGetter` to put together analysis getters. In this patch, a getter for `AAResult` is also added for `noalias`. Reviewers: jdoerfert, sstefan1 Reviewed By: jdoerfert Subscribers: hiraditya, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D67603 llvm-svn: 372072
* [Attributor] Heap-To-Stack ConversionStefan Stipanovic2019-09-151-5/+259
| | | | | | | | | | | | D53362 gives a prototype heap-to-stack conversion pass. With addition of new attributes in the attributor, this can now be revisted and improved. This will place it in the Attributor to make it easier to use new attributes (eg. nofree, nosync, willreturn, etc.) and other attributor features. Reviewers: jdoerfert, uenoku, hfinkel, efriedma Subscribers: lebedev.ri, xbolva00, hiraditya, llvm-commits Differential Revision: https://reviews.llvm.org/D65408 llvm-svn: 371942
* [Attributor][Fix] Use right type to replace expressionsJohannes Doerfert2019-09-141-3/+8
| | | | | | | | | | | | | | Summary: This should be obsolete once the functionality in D66967 is integrated. Reviewers: uenoku, sstefan1 Subscribers: hiraditya, bollu, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D67231 llvm-svn: 371915
* [Attributor] Implement "noalias" callsite argument deductionHideto Ueno2019-09-111-4/+50
| | | | | | | | | | | | | | | | Summary: Now, `nocapture` is deduced in Attributor therefore, this patch introduces deduction for `noalias` callsite argument using `nocapture`. Reviewers: jdoerfert, sstefan1 Reviewed By: jdoerfert Subscribers: lebedev.ri, hiraditya, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D67286 llvm-svn: 371590
* [Attributor][Fix] Manifest nocapture only in CSArgument or ArgumentHideto Ueno2019-09-111-4/+6
| | | | | | | | | | | | | | | | | | | | | | | | | Summary: We can query to Attributor whether the value is captured in the scope or not on the following way: ``` const auto & NoCapAA = A.getAAFor<AANoCapture>(*this, IRPosition::value(V)); ``` And if V is CallSiteReturned then `getDeducedAttribute` will add `nocatpure` to the callsite returned value. It is not valid. This patch checks the position is an argument or call site argument. This is tested in D67286. Reviewers: jdoerfert, sstefan1 Reviewed By: jdoerfert Subscribers: hiraditya, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D67342 llvm-svn: 371589
* [Attributor] ValueSimplify Abstract AttributeHideto Ueno2019-09-071-4/+269
| | | | | | | | | | | | | | | | | | | | | Summary: This patch introduces initial `AAValueSimplify` which simplifies a value in a context. example - (for function returned) If all the return values are the same and constant, then we can replace callsite returned with the constant. - If an internal function takes the same value(constant) as an argument in the callsite, then we can replace the argument with that constant. Reviewers: jdoerfert, sstefan1 Reviewed By: jdoerfert Subscribers: hiraditya, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D66967 llvm-svn: 371291
* [Attributor][Stats] Use the right statistics macroJohannes Doerfert2019-09-041-2/+2
| | | | llvm-svn: 370976
* [Attributor][Fix] Make sure we do not delete live codeJohannes Doerfert2019-09-041-2/+14
| | | | | | | | | | | | | | Summary: Liveness needs to mark edges, not blocks as dead. Reviewers: sstefan1, uenoku Subscribers: hiraditya, bollu, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D67191 llvm-svn: 370975
* [Attributor][Fix] Ensure the attribute names are created properlyJohannes Doerfert2019-09-041-1/+3
| | | | | | | The names of the attributes were not always created properly which caused problems with the yaml output. llvm-svn: 370956
* [Attributor] Look at internal functions only on-demandJohannes Doerfert2019-09-041-55/+92
| | | | | | | | | | | | | | | | | | | Summary: Instead of building attributes for internal functions which we do not update as long as we assume they are dead, we now do not create attributes until we assume the internal function to be live. This improves the number of required iterations, as well as the number of required updates, in real code. On our tests, the results are mixed. Reviewers: sstefan1, uenoku Subscribers: hiraditya, bollu, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D66914 llvm-svn: 370924
* [Attributor] Use the white list for attributes consistentlyJohannes Doerfert2019-09-041-60/+32
| | | | | | | | | | | | | | | | | | | | Summary: We create attributes on-demand so we need to check the white list on-demand. This also unifies the location at which we create, initialize, and eventually invalidate new abstract attributes. The tests show mixed results, a few more call site attributes are determined which can cause more iterations. Reviewers: uenoku, sstefan1 Subscribers: hiraditya, bollu, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D66913 llvm-svn: 370922
* [Attributor] Deal more explicit with non-exact definitionsJohannes Doerfert2019-09-041-74/+31
| | | | | | | | | | | | | | | | | | | Summary: Before we tried to rule out non-exact definitions early but that lead to on-demand attributes created for them anyway. As a consequence we needed to look at the definition in the initialize of each attribute again. This patch centralized this lookup and tightens the condition under which we give up on non-exact definitions. Reviewers: uenoku, sstefan1 Subscribers: hiraditya, bollu, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D67115 llvm-svn: 370917
* [Attributor] Use the delete API for livenessJohannes Doerfert2019-09-031-5/+16
| | | | | | | | | | | | Reviewers: uenoku, sstefan1 Subscribers: hiraditya, bollu, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D66833 llvm-svn: 370818
* [Attributor] Deduce "no-capture" argument attributeJohannes Doerfert2019-09-031-10/+355
| | | | | | | | | | | | | | Add the no-capture argument attribute deduction to the Attributor fixpoint framework. The new string attributed "no-capture-maybe-returned" is introduced to allow deduction of no-capture through functions that "capture" an argument but only by "returning" it. It is only used by the Attributor for testing. Differential Revision: https://reviews.llvm.org/D59922 llvm-svn: 370817
* [Attributor] Fix: do not pretend to preserve the CFGJohannes Doerfert2019-08-301-1/+0
| | | | llvm-svn: 370485
* [Attributor] Use existing function information for the call siteJohannes Doerfert2019-08-301-16/+259
| | | | | | | | | | | | | | | | | | | | | | | Summary: Instead of recomputing information for call sites we now use the function information directly. This is always valid and once we have call site specific information we can improve here. This patch also bootstraps attributes that are created on-demand through an initial update call. Information that is known will then directly be available in the new attribute without causing an iteration delay. The tests show how this improves the iteration count. Reviewers: sstefan1, uenoku Subscribers: hiraditya, bollu, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D66781 llvm-svn: 370480
* [Attributor] Manifest load/store alignment generallyJohannes Doerfert2019-08-301-25/+25
| | | | | | | | | | | | | | | | Summary: Any pointer could have load/store users not only floating ones so we move the manifest logic for alignment into the AAAlignImpl class. Reviewers: uenoku, sstefan1 Subscribers: hiraditya, bollu, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D66922 llvm-svn: 370479
* [Attributor] Implement AANoAliasCallSiteArgument initializationHideto Ueno2019-08-301-2/+4
| | | | | | | | | | | | | | | | Summary: This patch adds an appropriate `initialize` method for `AANoAliasCallSiteArgument`. Reviewers: jdoerfert, sstefan1 Reviewed By: jdoerfert Subscribers: hiraditya, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D66927 llvm-svn: 370456
* Fix variable set but no used warnings on NDEBUG builds. NFCI.Simon Pilgrim2019-08-291-7/+7
| | | | llvm-svn: 370319
* [Attributor] Deduce "noalias" attributeHideto Ueno2019-08-291-8/+23
| | | | | | | | | | | | | | | Summary: This patch adds very basic deduction for noalias. Reviewers: jdoerfert, sstefan1 Reviewed By: jdoerfert Tags: LLVM Differential Revision: https://reviews.llvm.org/D66207 llvm-svn: 370295
* [Attributor] Improve messages in iteration verify modeJohannes Doerfert2019-08-291-11/+12
| | | | | | | When we now verify the iteration count we will see the actual count and the expected count before the assertion is triggered. llvm-svn: 370285
* [Attributor][Fix] Indicate change correctlyJohannes Doerfert2019-08-291-0/+1
| | | | llvm-svn: 370283
* [Attributor] Fix typoJohannes Doerfert2019-08-291-1/+1
| | | | llvm-svn: 370282
* [Attributor] Regularly clear dependences to remove spurious onesJohannes Doerfert2019-08-281-4/+31
| | | | | | | | | | | | | | | | As dependences between abstract attributes can become stale, e.g., if one was sufficient to imply another one at some point but it has since been wakened to the point it is not usable for the formerly implied one. To weed out spurious dependences, and thereby eliminate unneeded updates, we introduce an option to determine how often the dependence cache is cleared and recomputed during the fixpoint iteration. Note that the initial value was determined such that we see a positive result on our tests. Differential Revision: https://reviews.llvm.org/D63315 llvm-svn: 370230
* [Attributor] Restrict liveness and return information to functionsJohannes Doerfert2019-08-281-14/+62
| | | | | | | | | | | | | | | | | | | | Summary: Until we have proper call-site information we should not recompute liveness and return information for each call site. This patch directly uses the function versions and introduces TODOs at the usage sites. The required iterations to get to the fixpoint are most of the time reduced by this change and we always avoid work duplication. Reviewers: sstefan1, uenoku Subscribers: hiraditya, bollu, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D66562 llvm-svn: 370208
* [Attributor] Introduce an API to delete stuffJohannes Doerfert2019-08-271-0/+20
| | | | | | | | | | | | | | | | | Summary: During the fixpoint iteration, including the manifest stage, we should not delete stuff as other abstract attributes might have a reference to the value. Through the API this can now be done safely at the very end. Reviewers: uenoku, sstefan1 Subscribers: hiraditya, bollu, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D66779 llvm-svn: 370014
* [Attributor] Adjust and test the iteration bound of testsJohannes Doerfert2019-08-261-1/+13
| | | | | | | | | | | | | | | | | | Summary: Try to verify how many iterations we need for a fixpoint in our tests. This patch adjust the way we count to make it easier to follow. It also adjusts the bounds to actually account for a fixpoint and not only the minimum number to pass all checks. Reviewers: uenoku, sstefan1 Subscribers: hiraditya, bollu, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D66757 llvm-svn: 369945
* [Attributor] Further cut down on non-determinismJohannes Doerfert2019-08-261-1/+1
| | | | llvm-svn: 369936
* [Attributor] Allow explicit dependence trackingJohannes Doerfert2019-08-261-14/+44
| | | | | | | | | | | | | | | By default, the Attributor tracks potential dependences between abstract attributes based on the issued Attributor::getAAFor queries. This simplifies the development of new abstract attributes but it can also lead to spurious dependences that might increase compile time and make internalization harder (D63312). With this patch, abstract attributes can opt-out of implicit dependence tracking and instead register dependences explicitly. It is up to the implementation to make sure all existing dependences are registered. Differential Revision: https://reviews.llvm.org/D63314 llvm-svn: 369935
* [Attributor] Manifest alignment in load and store instructionsJohannes Doerfert2019-08-231-0/+50
| | | | | | | | | | | | | | | | Summary: We can now manifest alignment information in load/store instructions if the pointer is known to have a better alignment. Reviewers: uenoku, sstefan1, lebedev.ri Subscribers: hiraditya, bollu, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D66567 llvm-svn: 369804
* [Attributor] Manifest constant return valuesJohannes Doerfert2019-08-231-1/+25
| | | | | | | | | | | | | | | | Summary: If the unique return value is a constant we now replace call uses with that constant. Reviewers: sstefan1, uenoku Subscribers: hiraditya, bollu, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D66551 llvm-svn: 369785
* [Attributor] Deal with shrinking dereferenceability in a loopJohannes Doerfert2019-08-231-6/+17
| | | | | | | | | | | | | | | | | | Summary: If we have a loop in which the dereferenceability of a pointer decreases we did slowly decrease it iteration by iteration, leading to a timeout. With this patch we detect such circular reasoning and indicate a fixpoint early. Reviewers: uenoku, sstefan1 Subscribers: hiraditya, bollu, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D66558 llvm-svn: 369784
* [Attributor][Fix] Deal with "growing" dereferenceabilityJohannes Doerfert2019-08-231-0/+6
| | | | | | | | | | | | | | | | | | Summary: If we have a negative inbounds offset dereferenceabily "grows". However, until we do not handle the overflow that can occur in the dereferenceable bytes and the problem with loops, we simply do not grow the state. Reviewers: sstefan1, uenoku Subscribers: hiraditya, bollu, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D66557 llvm-svn: 369771
* [Attributor][NFCI] Avoid lookups when resolving returned valuesJohannes Doerfert2019-08-231-3/+16
| | | | | | | | | | If the number of potentially returned values not change since the last traversal we do not need to visit the returned values again. This works as we only add values to the returned values set now. Differential Revision: https://reviews.llvm.org/D66484 llvm-svn: 369770
* [Attributor] FIX: Treat new attributes as changed onesJohannes Doerfert2019-08-231-5/+5
| | | | | | | | | | | | | | | | | | | | | Summary: When we have new attributes and we end the fixpoint iteration because the iteration limit is reached, we need to treat the new ones as if they changed in the last iteration, as they might have. This adds a test for which we should not derive anything regardless of the iteration limit, e.g., if we abort there should not be any attributes manifested in the IR. Reviewers: uenoku, sstefan1 Subscribers: hiraditya, bollu, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D66549 llvm-svn: 369768
* [Attributor][NFCI] Try to avoid potential non-deterministic behaviorJohannes Doerfert2019-08-231-12/+10
| | | | | | | This commit replaces sets with set vectors in an effort to make the behavior of the Attributor deterministic. llvm-svn: 369767
* [Attributor][NFC] Move DerefState to header and use StateWrapperHideto Ueno2019-08-221-96/+1
| | | | | | | | | | | | | | | | Summary: In D65402, I want to get DerefState from AADereferenceable but it was not allowed. This patch moves DerefState definition into Attributor.h and makes AADerefenceable inherit StateWrapper. Reviewers: jdoerfert, sstefan1 Reviewed By: jdoerfert Subscribers: hiraditya, jfb, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D66585 llvm-svn: 369653
* [Attributor] Fix: Gracefully handle non-instruction usersJohannes Doerfert2019-08-211-1/+5
| | | | | | | Function can have users that are not instructions, e.g., bitcasts. For now, we simply give up when we see them. llvm-svn: 369588
* [Attributor][NFC] Fix copy & paste errorJohannes Doerfert2019-08-211-1/+1
| | | | llvm-svn: 369577
* [Attributor][NFC] Remove leftover semicolonJohannes Doerfert2019-08-211-1/+1
| | | | llvm-svn: 369576
* [Attributor] Use existing unreachable instead of introducing new onesJohannes Doerfert2019-08-211-0/+3
| | | | | | | So far we split the unreachable off and placed a new one, this is not necessary. llvm-svn: 369575
* [Attributor] Liveness for internal functions.Stefan Stipanovic2019-08-201-2/+43
| | | | | | | | | | | | For an internal function, if all its call sites are dead, the body of the function is considered dead. Reviewers: jdoerfert, uenoku Subscribers: hiraditya, llvm-commits Differential Revision: https://reviews.llvm.org/D66155 llvm-svn: 369470
* [Attributor] Remove unused variable. NFC.Michael Liao2019-08-201-1/+1
| | | | llvm-svn: 369444
* [Attributor] Fix -Wunused-variable in -DLLVM_ENABLE_ASSERTIONS=off builds ↵Fangrui Song2019-08-201-0/+1
| | | | | | after r369331 llvm-svn: 369334
* [Attributor] Create abstract attributes on-demandJohannes Doerfert2019-08-201-140/+194
| | | | | | | | | | | | | | | | | | | | | | | | Before, we create the set of abstract attributes initially and then dealt with the fact hat a lookup could fail, e.g., return a nullptr. This patch will ensure we always return a valid object from a lookup, allowing us not only to remove the nullptr checks but also to grow the set of abstract attributes "in-flight" on-demand. One can now start from those that have the best chance of improving performance without the need to specify all they might depend on. While this introduces some boilerplate, the usage of attributes is much easier and cleaner now. Reviewers: uenoku, sstefan1 Subscribers: hiraditya, bollu, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D66276 llvm-svn: 369331
* [Attributor][NFC] Cleanup statistics codeJohannes Doerfert2019-08-201-4/+7
| | | | llvm-svn: 369330
* [Attributor] Use structured deduction for AADereferenceableJohannes Doerfert2019-08-201-139/+74
| | | | | | | | | | | | | | | | | | | | Summary: This is analogous to D66128 but for AADereferenceable. We have the logic concentrated in the floating value updateImpl and we use the combiner helper classes for arguments and return values. The regressions will go away with "on-demand" attribute creation. Improvements are already visible in the existing tests. Reviewers: uenoku, sstefan1 Subscribers: hiraditya, bollu, jfb, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D66272 llvm-svn: 369329
* [Attributor] Use structured deduction for AANonNullJohannes Doerfert2019-08-201-103/+83
| | | | | | | | | | | | | | | | | | | Summary: What D66126 did for AAAlign, this patch does for AANonNull. Agian, the logic becomes more concise and localized. Again, returned poiners are not annotated properly but that will not be an issue if this lands with the "on-demand" generation of attributes. First improvements due to the genericValueTraversal are already visible. Reviewers: sstefan1, uenoku Subscribers: hiraditya, bollu, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D66128 llvm-svn: 369328
* [Attributor] Fix the "clamp" operatorJohannes Doerfert2019-08-201-0/+6
| | | | | | | | The clamp operator should not take the known of the given state as the known is potentially based on assumed information. This also adds TODOs to guide improvements. llvm-svn: 369327
OpenPOWER on IntegriCloud