summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms/IPO/Attributor.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* Recommit "[Attributor] Fix: Do not partially resolve returned calls."Johannes Doerfert2019-08-191-11/+28
| | | | | | | | | This reverts commit b1752f670f3d6393306dd5d37546b6e23384d8a2. Fixed the issue with a different commit, reapply this one as it was, afaik, not broken. llvm-svn: 369303
* Re-apply fixed "[Attributor] Fix: Make sure we set the changed flag"Johannes Doerfert2019-08-191-4/+4
| | | | | | | | | This reverts commit cedd0d9a6e4b433e1cd6585d1d4d152eb5e60b11. Re-apply the original commit but make sure the variables are initialized (even if they are not used) so UBSan is not complaining. llvm-svn: 369294
* Revert [Attributor] Fix: Make sure we set the changed flagDavid L. Jones2019-08-191-4/+4
| | | | | | | | This reverts r369159 (git commit cbaf1fdea2de891bdbc49cdec89ae2077e6b9ed0) r369160 caused a test to fail under UBSAN. See thread on llvm-commits. llvm-svn: 369241
* Revert [Attributor] Fix: Do not partially resolve returned calls.David L. Jones2019-08-191-28/+11
| | | | | | | | This reverts r369160 (git commit f72d9b1c97b41fff48ad1eecbba59a29c171bff4) r369160 caused some tests to fail under UBSAN. See thread on llvm-commits. llvm-svn: 369236
* [Attributor] Fix: Do not partially resolve returned calls.Johannes Doerfert2019-08-161-11/+28
| | | | | | | | | | By partially resolving returned calls we did not record that they were not fully resolved which caused odd behavior down the line. We could also end up with some, but not all, returned values of the callee in the returned values map of the caller, another odd behavior we want to avoid. llvm-svn: 369160
* [Attributor] Fix: Make sure we set the changed flagJohannes Doerfert2019-08-161-4/+4
| | | | | | | The flag was updated *before* we actually run the visitor callback so we might miss updates. llvm-svn: 369159
* [Attributor] Add all missing attribute definitions/symbolsJohannes Doerfert2019-08-161-35/+117
| | | | | | | | | | | | | | | | As a preparation to "on-demand" abstract attribute generation we need implementations for all attributes (as they can be queried and then created on-demand where we now fail to find one). Reviewers: uenoku, sstefan1 Subscribers: hiraditya, bollu, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D66129 llvm-svn: 369155
* [Attributor] Towards a more structured deduction patternJohannes Doerfert2019-08-161-111/+222
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: This is the first commit aiming to structure the attribute deduction. The base idea is that we have default propagation patterns as listed below on top of which we can add specific, e.g., context sensitive, logic. Deduction patterns used in this patch: - argument states are determined from call site argument states, see AAAlignArgument and AAArgumentFromCallSiteArguments. - call site argument states are determined as if they were floating values, see AAAlignCallSiteArgument and AAAlignFloating. - floating value states are determined by traversing the def-use chain and combining the states determined for the leaves, see AAAlignFloating and genericValueTraversal. - call site return states are determined from function return states, see AAAlignCallSiteReturned and AACallSiteReturnedFromReturned. - function return states are determined from returned value states, see AAAlignReturned and AAReturnedFromReturnedValues. Through this strategy all logic for alignment is concentrated in the AAAlignFloating::updateImpl method. Note: This commit works on its own but is part of a larger change that involves "on-demand" creation of abstract attributes that will participate in the fixpoint iteration. Without this part, we sometimes do not have an AAAlign abstract attribute to query, loosing information we determined before. All tests have appropriate FIXMEs and the information will be recovered once we added all parts. Reviewers: sstefan1, uenoku Subscribers: hiraditya, bollu, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D66126 llvm-svn: 369144
* [Attributor][NFC] Introduce aliases for call site attributesJohannes Doerfert2019-08-161-7/+40
| | | | | | | | | Until we have call site specific liveness and/or value information there is no need to do call site specific deduction. Though, we need the symbols in follow up patches that make Attributor::getAAFor return a reference. llvm-svn: 369143
* [Attributor] Introduce initialize calls and move code to keep attributes conciseJohannes Doerfert2019-08-161-179/+180
| | | | | | | | | | | | | | | | | | Summary: This patch should not change the behavior except that the added initialize methods might indicate an optimistic fixpoint earlier. The code movement is done to keep the attribute definitions in a single block where it makes sense. No functional changes intended there. Reviewers: uenoku, sstefan1 Subscribers: hiraditya, bollu, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D66258 llvm-svn: 369142
* [Attributor] Try to fix "missing field 'RetInsts' initializer" warningJohannes Doerfert2019-08-141-1/+1
| | | | | | http://lab.llvm.org:8011/builders/lld-x86_64-darwin13/builds/35674/steps/build_Lld/logs/stdio llvm-svn: 368938
* [Attributor][NFC] Make debug output consistentJohannes Doerfert2019-08-141-4/+4
| | | | llvm-svn: 368931
* [Attributor][NFC] Try to eliminate warnings (debug build + fall through)Johannes Doerfert2019-08-141-1/+3
| | | | llvm-svn: 368928
* [Attributor][NFC] Introduce statistics macros for new positionsJohannes Doerfert2019-08-141-54/+42
| | | | llvm-svn: 368927
* [Attributor][NFC] Add merge/join/clamp operators to the IntegerStateJohannes Doerfert2019-08-141-0/+24
| | | | | | Differential Revision: https://reviews.llvm.org/D66146 llvm-svn: 368925
* [Attributor] Use the AANoNull attribute directly in AADereferenceableJohannes Doerfert2019-08-141-78/+34
| | | | | | | | | | | | | | | | | Summary: Instead of constantly keeping track of the nonnull status with the dereferenceable information we can simply query the nonnull attribute whenever we need the information (debug + manifest). Reviewers: sstefan1, uenoku Subscribers: hiraditya, bollu, jfb, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D66113 llvm-svn: 368924
* [Attributor] Use liveness during the creation of AAReturnedValuesJohannes Doerfert2019-08-141-227/+182
| | | | | | | | | | | | | | | | | | | | | | | | | Summary: As one of the first attributes, and one of the complex ones, AAReturnedValues was not using liveness but we filtered the result after the fact. This change adds liveness usage during the creation. The algorithm is also improved and shorter. The new algorithm will collect returned values over time using the generic facilities that work with liveness already, e.g., genericValueTraversal which does not look at dead PHI node predecessors. A test to show how this leads to better results is included. Note: Unresolved calls and resolved calls are now tracked explicitly. Reviewers: uenoku, sstefan1 Subscribers: hiraditya, bollu, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D66120 llvm-svn: 368922
* [Attributor] Do not update or manifest dead attributesJohannes Doerfert2019-08-141-3/+23
| | | | | | | | | | | | | | | | Summary: If the associated context instruction is assumed dead we do not need to update or manifest the state. Reviewers: sstefan1, uenoku Subscribers: hiraditya, bollu, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D66116 llvm-svn: 368921
* [Attributor] Use IRPosition consistentlyJohannes Doerfert2019-08-141-234/+367
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: The next attempt to clean up the Attributor interface before we grow it further. Before, we used a combination of two values (associated + anchor) and an argument number (or -1) to determine a location. This was very fragile. The new system uses exclusively IR positions and we restrict the generation of IR positions to special constructor methods that verify internal constraints we have. This will catch misuse early. The auto-conversion, e.g., in getAAFor, is now performed through the SubsumingPositionIterator. This iterator takes an IR position and allows to visit all IR positions that "subsume" the given one, e.g., function attributes "subsume" argument attributes of that function. For a detailed breakdown see the class comment of SubsumingPositionIterator. This patch also introduces the IRPosition::getAttrs() to extract IR attributes at a certain position. The method knows how to look up in different positions that are equivalent, e.g., the argument position for call site arguments. We also introduce three new positions kinds such that we have all IR positions where attributes can be placed and one for "floating" values. Reviewers: sstefan1, uenoku Subscribers: hiraditya, bollu, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D65977 llvm-svn: 368919
* [Attributor] Use the cached data layout directlyJohannes Doerfert2019-08-121-11/+8
| | | | | | | This removes the warning by using the new DL member. It also simplifies the code. llvm-svn: 368625
* [Attributor][NFC] Add IntegerState raw_ostream << operatorJohannes Doerfert2019-08-121-0/+5
| | | | llvm-svn: 368622
* [Attributor] Make the InformationCache an Attributor memberJohannes Doerfert2019-08-121-96/+66
| | | | | | | The functionality is not changed but the interfaces are simplified and repetition is removed. llvm-svn: 368621
* [Attributor][Stats] Locate statistics tracking with the attributesJohannes Doerfert2019-08-071-106/+127
| | | | | | | | | | | | | | | | | | Summary: The ever growing switch required Attribute::AttrKind values but they might not be available for all abstract attributes we deduce. With the new method we track statistics at the abstract attribute level. The provided macros simplify the usage and make the messages uniform. Reviewers: sstefan1, uenoku Subscribers: hiraditya, bollu, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D65732 llvm-svn: 368227
* [Attributor][NFC] Code simplification and style normalizationJohannes Doerfert2019-08-071-38/+24
| | | | llvm-svn: 368225
* [Attributor] Introduce a state wrapper classJohannes Doerfert2019-08-071-112/+12
| | | | | | | | | | | | | | | | | | | Summary: The wrapper reduces boilerplate code and also provide a nice way to determine the state type used by an abstract attributes statically via AAType::StateType. This was already discussed as part of the review of D65711. Reviewers: sstefan1, uenoku Subscribers: hiraditya, bollu, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D65786 llvm-svn: 368224
* [Attributor][NFC] Avoid unnecessary liveness queriesJohannes Doerfert2019-08-071-0/+10
| | | | | | | | | If we know everything is live there is no need to query for liveness. Indicating a pessimistic fixpoint will cause the state to be "invalid" which will cause the Attributor to not return the AAIsDead on request, which will prevent us from querying isAssumedDead(). llvm-svn: 368223
* [Attributor] Provide easier checkForallReturnedValues functionalityJohannes Doerfert2019-08-071-59/+85
| | | | | | | | | | | | | | | | | | | Summary: So far, whenever one wants to look at returned values, one had to deal with the AAReturnedValues and potentially with the AAIsDead attribute. In the same spirit as other checkForAllXXX methods, we add this functionality now to the Attributor. By adopting the use sites we got better results when return instructions were dead. Reviewers: sstefan1, uenoku Subscribers: hiraditya, bollu, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D65733 llvm-svn: 368222
* [Attributor] Introduce checkForAllReadWriteInstructions(...).Stefan Stipanovic2019-08-071-19/+35
| | | | | | | | | | | | | | Summary: Similarly to D65731 `Attributor::checkForAllReadWriteInstructions` is introduced. Reviewers: jdoerfert, uenoku Subscribers: hiraditya, jfb, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D65825 llvm-svn: 368194
* [Attributor][modulemap] Revert r368064 but fix the buildKristina Brooks2019-08-061-13/+8
| | | | | | | | | | | | | | | | Commit r368064 was necessary after r367953 (D65712) broke the module build. That happened, apparently, because the template class IRAttribute defined in the header had a virtual method defined in the corresponding source file (IRAttribute::manifest). To unbreak the situation this patch introduces a helper function IRAttributeManifest::manifestAttrs which is used to implement IRAttribute::manifest in the header. The deifnition of the helper function is still in the source file. Patch by jdoerfert (Johannes Doerfert) Differential Revision: https://reviews.llvm.org/D65821 llvm-svn: 368076
* [Attributor][NFC] Outline common pattern into helper methodJohannes Doerfert2019-08-061-37/+50
| | | | | | | This helper will also allow to also place logic to determine if an abstract attribute is necessary in the first place. llvm-svn: 367966
* [Attributor] Provide a generic interface to check live instructionsJohannes Doerfert2019-08-061-104/+76
| | | | | | | | | | | | | | | | | | | Summary: Similar to `Attributor::checkForAllCallSites`, we now provide such functionality for instructions of a certain opcode through `Attributor::checkForAllInstructions` and the convenient wrapper `Attributor::checkForAllCallLikeInstructions`. This cleans up code, avoids duplication, and simplifies the usage of liveness information. Reviewers: sstefan1, uenoku Subscribers: hiraditya, bollu, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D65731 llvm-svn: 367961
* [Attributor] Introduce the IRAttribute helper structJohannes Doerfert2019-08-051-69/+39
| | | | | | | | | | | | | | | | Summary: Certain properties, e.g., an AttrKind, are not shared among all abstract attributes. This patch extracts the functionality into a helper struct. Reviewers: uenoku, sstefan1 Subscribers: hiraditya, bollu, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D65712 llvm-svn: 367953
* [Attributor] Make abstract attributes statelessJohannes Doerfert2019-08-051-289/+183
| | | | | | | | | | | | | | | | | To remove boilerplate, mostly passing through values to the AbstractAttriubute base class, we extract the state into an IRPosition helper. There is no function change intended but the IRPosition struct will provide more functionality down the line. Reviewers: sstefan1, uenoku Subscribers: hiraditya, bollu, jfb, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D65711 llvm-svn: 367952
* [Attributor] Use proper ID for attribute lookupJohannes Doerfert2019-08-051-17/+32
| | | | | | | | | | | | | | | | | | Summary: The new scheme is similar to the pass manager and dyn_cast scheme where we identify classes by the address of a static member. This is better than the old scheme in which we had to "invent" new Attributor enums if there was no corresponding one. Reviewers: sstefan1, uenoku Subscribers: hiraditya, bollu, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D65710 llvm-svn: 367951
* [Attributor][NFCI] Avoid duplication of the InformationCache referenceJohannes Doerfert2019-08-051-129/+128
| | | | | | | | | | | | | | | | Summary: Instead of storing the reference to the InformationCache we now pass it whenever it might be needed. Reviewers: sstefan1, uenoku Subscribers: hiraditya, bollu, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D65709 llvm-svn: 367950
* [Attributor] Deduce the "no-return" attribute for functionsJohannes Doerfert2019-08-051-0/+61
| | | | | | | | | | | | | | | A function is "no-return" if we never reach a return instruction, either because there are none or the ones that exist are dead. Test have been adjusted: - either noreturn was added, or - noreturn was avoided by modifying the code. The new noreturn_{sync,async} test make sure we do handle invoke instructions with a noreturn (and potentially nowunwind) callee correctly, even in the presence of potential asynchronous exceptions. llvm-svn: 367948
* [Attributor][Fix] Do not remove instructions during manifestationJohannes Doerfert2019-08-051-6/+20
| | | | | | | | When we remove instructions cached references could still be live. This patch avoids removing invoke instructions that are replaced by calls and instead keeps them around but in a dead block. llvm-svn: 367933
* [Attributor][Fix] Keep invokes if handlers catch asynchronous exceptionsJohannes Doerfert2019-08-051-9/+31
| | | | | | | | | | Similar to other places where we transform invokes to calls we need to be careful if the handler (=personality) can catch asynchronous exceptions as they are not modeled as part of nounwind. This is tested with D59978. llvm-svn: 367931
* [Attributor][NFC] Create some attributes earlierJohannes Doerfert2019-08-041-6/+6
| | | | llvm-svn: 367793
* [Attributor][NFC] Improve debug outputJohannes Doerfert2019-08-041-1/+2
| | | | llvm-svn: 367792
* [Attributor][Fix] Resolve various liveness issuesJohannes Doerfert2019-08-041-72/+94
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: This contains various fixes: - Explicitly determine and return the next noreturn instruction. - If an invoke calls a noreturn function which is not nounwind we keep the unwind destination live. This also means we require an invoke. Though we can still add the unreachable to the normal destination block. - Check if the return instructions are dead after we look for calls to avoid triggering an optimistic fixpoint in the presence of assumed liveness information. - Make the interface work with "const" pointers. - Some simplifications While additional tests are included, full coverage is achieved only with D59978. Reviewers: sstefan1, uenoku Subscribers: hiraditya, bollu, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D65701 llvm-svn: 367791
* [Attributor][NFC] Simplify common pattern wrt. fixpointsJohannes Doerfert2019-08-041-70/+41
| | | | | | | | When a fixpoint is indicated the change status is known due to the fixpoint kind. This simplifies a common code pattern by making the connection explicit. llvm-svn: 367790
* [Attributor][NFC] Invalid DerefState is at fixpointJohannes Doerfert2019-08-041-2/+3
| | | | | | | | | | | | | | | | | Summary: If the DerefBytesState (and thereby the DerefState) is invalid, we reached a fixpoint for the whole DerefState as we will not manifest/provide information then. Reviewers: uenoku, sstefan1 Subscribers: hiraditya, bollu, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D65586 llvm-svn: 367789
* [Attributor][NFC] run clang-format on Attributor.cppStefan Stipanovic2019-08-031-4/+5
| | | | llvm-svn: 367757
* [Attributor] Fix dereferenceable callsite argument initializationHideto Ueno2019-08-031-2/+4
| | | | llvm-svn: 367748
* [Attributor] Using liveness in other attributes.Stefan Stipanovic2019-08-021-30/+139
| | | | | | | | | | | | Modifying other AbstractAttributes to use Liveness AA and skip dead instructions. Reviewers: jdoerfert, uenoku Subscribers: hiraditya, llvm-commits Differential revision: https://reviews.llvm.org/D65243 llvm-svn: 367725
* [Attributor][FIX] Indicate a missing update changeJohannes Doerfert2019-08-011-3/+7
| | | | | | | | | | User of AAReturnedValues need to know if HasOverdefinedReturnedCalls changed from false to true as it will impact the result of the return value traversal (calls are not ignored anymore). This will be tested with the tests in D59978. llvm-svn: 367581
* [Attributor] Deduce "align" attributeHideto Ueno2019-07-281-0/+236
| | | | | | | | | | | | | | | | | Summary: Deduce "align" attribute in attributor. Reviewers: jdoerfert, sstefan1 Reviewed By: jdoerfert Subscribers: hiraditya, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D64152 llvm-svn: 367187
* [Attributor][NFC] Re-run clang-format on the Attributor.cppHideto Ueno2019-07-231-7/+4
| | | | llvm-svn: 366789
* [Attributor] Deduce "dereferenceable" attributeHideto Ueno2019-07-231-14/+429
| | | | | | | | | | | | | | | | | | | | | Summary: Deduce dereferenceable attribute in Attributor. These will be added in a later patch. * dereferenceable(_or_null)_globally (D61652) * Deduction based on load instruction (similar to D64258) Reviewers: jdoerfert, sstefan1 Reviewed By: jdoerfert Subscribers: hiraditya, jfb, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D64876 llvm-svn: 366788
OpenPOWER on IntegriCloud