summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms/IPO
Commit message (Collapse)AuthorAgeFilesLines
...
* [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
* [ThinLTO][AutoFDO] Fix memory corruption due to race condition from thin ↵Wenlei He2019-08-121-1/+74
| | | | | | | | | | | | | | | | | | backends Summary: This commit fixed a race condition from multi-threaded thinLTO backends that causes non-deterministic memory corruption for a data structure used only by AutoFDO with compact binary profile. GUIDToFuncNameMap, a static data member of type DenseMap in FunctionSamples is used as a per-module mapping from function name MD5 to name string when input AutoFDO profile is in compact binary format. However with ThinLTO, we can have parallel backends modifying and accessing the class static map concurrently. The fix is to make GUIDToFuncNameMap a member of SampleProfileLoader instead of a file static data. Reviewers: wmi, davidxl, danielcdh Subscribers: mehdi_amini, inglorion, hiraditya, dexonsmith, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D65848 llvm-svn: 368596
* cfi-icall: Allow the jump table to be optionally made non-canonical.Peter Collingbourne2019-08-093-90/+155
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The default behavior of Clang's indirect function call checker will replace the address of each CFI-checked function in the output file's symbol table with the address of a jump table entry which will pass CFI checks. We refer to this as making the jump table `canonical`. This property allows code that was not compiled with ``-fsanitize=cfi-icall`` to take a CFI-valid address of a function, but it comes with a couple of caveats that are especially relevant for users of cross-DSO CFI: - There is a performance and code size overhead associated with each exported function, because each such function must have an associated jump table entry, which must be emitted even in the common case where the function is never address-taken anywhere in the program, and must be used even for direct calls between DSOs, in addition to the PLT overhead. - There is no good way to take a CFI-valid address of a function written in assembly or a language not supported by Clang. The reason is that the code generator would need to insert a jump table in order to form a CFI-valid address for assembly functions, but there is no way in general for the code generator to determine the language of the function. This may be possible with LTO in the intra-DSO case, but in the cross-DSO case the only information available is the function declaration. One possible solution is to add a C wrapper for each assembly function, but these wrappers can present a significant maintenance burden for heavy users of assembly in addition to adding runtime overhead. For these reasons, we provide the option of making the jump table non-canonical with the flag ``-fno-sanitize-cfi-canonical-jump-tables``. When the jump table is made non-canonical, symbol table entries point directly to the function body. Any instances of a function's address being taken in C will be replaced with a jump table address. This scheme does have its own caveats, however. It does end up breaking function address equality more aggressively than the default behavior, especially in cross-DSO mode which normally preserves function address equality entirely. Furthermore, it is occasionally necessary for code not compiled with ``-fsanitize=cfi-icall`` to take a function address that is valid for CFI. For example, this is necessary when a function's address is taken by assembly code and then called by CFI-checking C code. The ``__attribute__((cfi_jump_table_canonical))`` attribute may be used to make the jump table entry of a specific function canonical so that the external code will end up taking a address for the function that will pass CFI checks. Fixes PR41972. Differential Revision: https://reviews.llvm.org/D65629 llvm-svn: 368495
* [GlobalOpt] prevent crashing on large integer types (PR42932)Sanjay Patel2019-08-091-2/+4
| | | | | | | | | | | This is a minimal fix (copy the predicate for the assert) to prevent the crashing seen in: https://bugs.llvm.org/show_bug.cgi?id=42932 ...when converting a constant integer of arbitrary width to uint64_t. Differential Revision: https://reviews.llvm.org/D65970 llvm-svn: 368437
* [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
* Rename F_{None,Text,Append} to OF_{None,Text,Append}. NFCFangrui Song2019-08-053-3/+3
| | | | | | F_{None,Text,Append} are kept for compatibility since r334221. llvm-svn: 367800
* [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
* [ThinLTO] Implement index-based WPDTeresa Johnson2019-08-021-5/+298
| | | | | | | | | | | | | | | | | | | This patch adds support to the WholeProgramDevirt pass to perform index-based WPD, which is invoked from ThinLTO during the thin link. The ThinLTO backend (WPD import phase) behaves the same regardless of whether the WPD decisions were made with the index-based or (the existing) IR-based analysis. Depends on D54815. Reviewers: pcc Subscribers: mehdi_amini, inglorion, eraman, steven_wu, dexonsmith, arphaman, dang, llvm-commits Differential Revision: https://reviews.llvm.org/D55153 llvm-svn: 367679
* [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
* [IR] Value: add replaceUsesWithIf() utilityRoman Lebedev2019-08-011-10/+1
| | | | | | | | | | | | | | | | | | | | | | Summary: While there is always a `Value::replaceAllUsesWith()`, sometimes the replacement needs to be conditional. I have only cleaned a few cases where `replaceUsesWithIf()` could be used, to both add test coverage, and show that it is actually useful. Reviewers: jdoerfert, spatel, RKSimon, craig.topper Reviewed By: jdoerfert Subscribers: dschuff, sbc100, jgravelle-google, hiraditya, aheejin, george.burgess.iv, asbirlea, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D65528 llvm-svn: 367548
* ThinLTOBitcodeWriter: Include globals associated with type metadata globals ↵Peter Collingbourne2019-07-291-3/+11
| | | | | | | | | | | in the merged module. Globals that are associated with globals with type metadata need to appear in the merged module because they will reference the global's section directly. Differential Revision: https://reviews.llvm.org/D65312 llvm-svn: 367242
* [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
* [LLVM-C] Improve Bindings to The Internalize PassRobert Widmann2019-07-231-0/+9
| | | | | | | | | | | | | | | | Summary: Adds a binding to the internalize pass that allows the caller to pass a function pointer that acts as the visibility-preservation predicate. Previously, one could only pass an unsigned value (not LLVMBool?) that directed the pass to consider "main" or not. Reviewers: whitequark, deadalnix, harlanhaskins Reviewed By: whitequark, harlanhaskins Subscribers: kren1, hiraditya, llvm-commits, harlanhaskins Tags: #llvm Differential Revision: https://reviews.llvm.org/D62456 llvm-svn: 366777
* Inline function call into assert to fix unused variable warning.Richard Trieu2019-07-231-3/+2
| | | | llvm-svn: 366774
* Fixing build error from commit 95cbc3dStefan Stipanovic2019-07-221-0/+174
| | | | | | | | | | | | | | | [Attributor] Liveness analysis. Liveness analysis abstract attribute used to indicate which BasicBlocks are dead and can therefore be ignored. Right now we are only looking at noreturn calls. Reviewers: jdoerfert, uenoku Subscribers: hiraditya, llvm-commits Differential Revision: https://reviews.llvm.org/D64162 llvm-svn: 366769
* Revert "Fixing build error from commit 9285295."Stefan Stipanovic2019-07-221-172/+0
| | | | | | This reverts commit 95cbc3da8871f43c1ce2b2926afaedcd826202b1. llvm-svn: 366759
* Fixing build error from commit 9285295.Stefan Stipanovic2019-07-221-0/+172
| | | | | | | | | | | | | | | [Attributor] Liveness analysis. Liveness analysis abstract attribute used to indicate which BasicBlocks are dead and can therefore be ignored. Right now we are only looking at noreturn calls. Reviewers: jdoerfert, uenoku Subscribers: hiraditya, llvm-commits Differential revision: https://reviews.llvm.org/D64162 llvm-svn: 366753
* Temporarily Revert "[Attributor] Liveness analysis." as it's breaking the build.Eric Christopher2019-07-221-174/+0
| | | | | | This reverts commit 9285295f75a231dc446fa7cbc10a0a391b3434a5. llvm-svn: 366737
OpenPOWER on IntegriCloud