summaryrefslogtreecommitdiff
path: root/llvm/lib/CodeGen/LiveIntervalUnion.cpp
AgeCommit message (Collapse)Author
2025-03-06[CodeGen] Use Register::id(). NFCCraig Topper
2023-11-13[llvm] Stop including llvm/ADT/SparseBitVector.h (NFC)Kazu Hirata
Identified with clangd.
2022-02-03[nfc][regalloc] const LiveIntervals within the allocatorMircea Trofin
Once built, LiveIntervals are immutable. This patch captures that. Differential Revision: https://reviews.llvm.org/D118918
2021-11-02[NFC][Regalloc] Ensure Query::interferingVRegs is accurate.Mircea Trofin
To correctly use Query, one had to first call collectInterferingVRegs to pre-cache the query result, then call interferingVRegs. Failing the former, interferingVRegs could be stale. This did cause a bug which was addressed in D98232, but the underlying usability issue of the Query API wasn't. This patch addresses the latter by making collectInterferingVRegs an implementation detail, and having interferingVRegs play both roles. One side-effect of this is that interferingVRegs is not const anymore. Differential Revision: https://reviews.llvm.org/D112882
2021-04-01[regalloc] Ensure Query::collectInterferringVregs is called before interval ↵Mircea Trofin
iteration The main part of the patch is the change in RegAllocGreedy.cpp: Q.collectInterferringVregs() needs to be called before iterating the interfering live ranges. The rest of the patch offers support that is the case: instead of clearing the query's InterferingVRegs field, we invalidate it. The clearing happens when the live reg matrix is invalidated (existing triggering mechanism). Without the change in RegAllocGreedy.cpp, the compiler ices. This patch should make it more easily discoverable by developers that collectInterferringVregs needs to be called before iterating. I will follow up with a subsequent patch to improve the usability and maintainability of Query. Differential Revision: https://reviews.llvm.org/D98232
2021-03-16Revert "[regalloc] Ensure Query::collectInterferringVregs is called before ↵Nikita Popov
interval iteration" This reverts commit d40b4911bd9aca0573752e065f29ddd9aff280e1. This causes a large compile-time regression: https://llvm-compile-time-tracker.com/compare.php?from=0aa637b2037d882ddf7861284169abf63f524677&to=d40b4911bd9aca0573752e065f29ddd9aff280e1&stat=instructions
2021-03-16[regalloc] Ensure Query::collectInterferringVregs is called before interval ↵Mircea Trofin
iteration The main part of the patch is the change in RegAllocGreedy.cpp: Q.collectInterferringVregs() needs to be called before iterating the interfering live ranges. The rest of the patch offers support that is the case: instead of clearing the query's InterferingVRegs field, we invalidate it. The clearing happens when the live reg matrix is invalidated (existing triggering mechanism). Without the change in RegAllocGreedy.cpp, the compiler ices. This patch should make it more easily discoverable by developers that collectInterferringVregs needs to be called before iterating. I will follow up with a subsequent patch to improve the usability and maintainability of Query. Differential Revision: https://reviews.llvm.org/D98232
2020-12-10[X86] AMX programming model.Luo, Yuanke
This patch implements amx programming model that discussed in llvm-dev (http://lists.llvm.org/pipermail/llvm-dev/2020-August/144302.html). Thank Hal for the good suggestion in the RA. The fast RA is not in the patch yet. This patch implemeted 7 components. 1. The c interface to end user. 2. The AMX intrinsics in LLVM IR. 3. Transform load/store <256 x i32> to AMX intrinsics or split the type into two <128 x i32>. 4. The Lowering from AMX intrinsics to AMX pseudo instruction. 5. Insert psuedo ldtilecfg and build the def-use between ldtilecfg to amx intruction. 6. The register allocation for tile register. 7. Morph AMX pseudo instruction to AMX real instruction. Change-Id: I935e1080916ffcb72af54c2c83faa8b2e97d5cb0 Differential Revision: https://reviews.llvm.org/D87981
2020-09-16[NFC][Regalloc] accessors for 'reg' and 'weight'Mircea Trofin
Also renamed the fields to follow style guidelines. Accessors help with readability - weight mutation, in particular, is easier to follow this way. Differential Revision: https://reviews.llvm.org/D87725
2019-01-19Update the file headers across all of the LLVM projects in the monorepoChandler Carruth
to reflect the new license. We understand that people may be surprised that we're moving the header entirely to discuss the new license. We checked this carefully with the Foundation's lawyer and we believe this is the correct approach. Essentially, all code in the project is now made available by the LLVM project under our new license, so you will see that the license headers include that license only. Some of our contributors have contributed code under our old license, and accordingly, we have retained a copy of our old license notice in the top-level files in each project and repository. llvm-svn: 351636
2018-02-20Report fatal error in the case of out of memorySerge Pavlov
This is the second part of recommit of r325224. The previous part was committed in r325426, which deals with C++ memory allocation. Solution for C memory allocation involved functions `llvm::malloc` and similar. This was a fragile solution because it caused ambiguity errors in some cases. In this commit the new functions have names like `llvm::safe_malloc`. The relevant part of original comment is below, updated for new function names. Analysis of fails in the case of out of memory errors can be tricky on Windows. Such error emerges at the point where memory allocation function fails, but manifests itself when null pointer is used. These two points may be distant from each other. Besides, next runs may not exhibit allocation error. In some cases memory is allocated by a call to some of C allocation functions, malloc, calloc and realloc. They are used for interoperability with C code, when allocated object has variable size and when it is necessary to avoid call of constructors. In many calls the result is not checked for null pointer. To simplify checks, new functions are defined in the namespace 'llvm': `safe_malloc`, `safe_calloc` and `safe_realloc`. They behave as corresponding standard functions but produce fatal error if allocation fails. This change replaces the standard functions like 'malloc' in the cases when the result of the allocation function is not checked for null pointer. Finally, there are plain C code, that uses malloc and similar functions. If the result is not checked, assert statement is added. Differential Revision: https://reviews.llvm.org/D43010 llvm-svn: 325551
2018-02-15Revert r325224 "Report fatal error in the case of out of memory"Serge Pavlov
It caused fails on some buildbots. llvm-svn: 325227
2018-02-15Report fatal error in the case of out of memorySerge Pavlov
Analysis of fails in the case of out of memory errors can be tricky on Windows. Such error emerges at the point where memory allocation function fails, but manifests itself when null pointer is used. These two points may be distant from each other. Besides, next runs may not exhibit allocation error. Usual programming practice does not require checking result of 'operator new' because it throws 'std::bad_alloc' in the case of allocation error. However, LLVM is usually built with exceptions turned off, so 'new' can return null pointer. This change installs custom new handler, which causes fatal error in the case of out of memory. The handler is installed automatically prior to call to 'main' during construction of a static object defined in 'lib/Support/ErrorHandling.cpp'. If the application does not use this file, the handler may be installed manually by a call to 'llvm::install_out_of_memory_new_handler', declared in 'include/llvm/Support/ErrorHandling.h". There are calls to C allocation functions, malloc, calloc and realloc. They are used for interoperability with C code, when allocated object has variable size and when it is necessary to avoid call of constructors. In many calls the result is not checked against null pointer. To simplify checks, new functions are defined in the namespace 'llvm' with the same names as these C function. These functions produce fatal error if allocation fails. User should use 'llvm::malloc' instead of 'std::malloc' in order to use the safe variant. This change replaces 'std::malloc' in the cases when the result of allocation function is not checked against null pointer. Finally, there are plain C code, that uses malloc and similar functions. If the result is not checked, assert statements are added. Differential Revision: https://reviews.llvm.org/D43010 llvm-svn: 325224
2017-11-28[CodeGen] Rename functions PrintReg* to printReg*Francis Visoiu Mistrih
LLVM Coding Standards: Function names should be verb phrases (as they represent actions), and command-like function should be imperative. The name should be camel case, and start with a lower case letter (e.g. openFile() or isFoo()). Differential Revision: https://reviews.llvm.org/D40416 llvm-svn: 319168
2017-11-17Fix a bunch more layering of CodeGen headers that are in TargetDavid Blaikie
All these headers already depend on CodeGen headers so moving them into CodeGen fixes the layering (since CodeGen depends on Target, not the other way around). llvm-svn: 318490
2017-06-06Sort the remaining #include lines in include/... and lib/....Chandler Carruth
I did this a long time ago with a janky python script, but now clang-format has built-in support for this. I fed clang-format every line with a #include and let it re-sort things according to the precise LLVM rules for include ordering baked into clang-format these days. I've reverted a number of files where the results of sorting includes isn't healthy. Either places where we have legacy code relying on particular include ordering (where possible, I'll fix these separately) or where we have particular formatting around #include lines that I didn't want to disturb in this patch. This patch is *entirely* mechanical. If you get merge conflicts or anything, just ignore the changes in this patch and run clang-format over your #include lines in the files. Sorry for any noise here, but it is important to keep these things stable. I was seeing an increasing number of patches with irrelevant re-ordering of #include lines because clang-format was used. This patch at least isolates that churn, makes it easy to skip when resolving conflicts, and gets us to a clean baseline (again). llvm-svn: 304787
2017-03-01LIU:::Query: Query LiveRange instead of LiveInterval; NFCMatthias Braun
- We only need the information from the base class, not the additional details in the LiveInterval class. - Spread more `const` - Some code cleanup llvm-svn: 296684
2017-02-17[CodeGen] Fix some Clang-tidy modernize and Include What You Use warnings; ↵Eugene Zelenko
other minor fixes (NFC). llvm-svn: 295499
2016-08-11Use the range variant of find instead of unpacking begin/endDavid Majnemer
If the result of the find is only used to compare against end(), just use is_contained instead. No functionality change is intended. llvm-svn: 278433
2014-12-10LiveIntervalUnion: Allow specification of liverange when unifying/extracting.Matthias Braun
This allows it to add subregister ranges into the union. llvm-svn: 223890
2014-04-22[Modules] Remove potential ODR violations by sinking the DEBUG_TYPEChandler Carruth
define below all header includes in the lib/CodeGen/... tree. While the current modules implementation doesn't check for this kind of ODR violation yet, it is likely to grow support for it in the future. It also removes one layer of macro pollution across all the included headers. Other sub-trees will follow. llvm-svn: 206837
2014-04-14[C++11] More 'nullptr' conversion. In some cases just using a boolean check ↵Craig Topper
instead of comparing to nullptr. llvm-svn: 206142
2012-12-03Use the new script to sort the includes of every file under lib.Chandler Carruth
Sooooo many of these had incorrect or strange main module includes. I have manually inspected all of these, and fixed the main module include to be the nearest plausible thing I could find. If you own or care about any of these source files, I encourage you to take some time and check that these edits were sensible. I can't have broken anything (I strictly added headers, and reordered them, never removed), but they may not be the headers you'd really like to identify as containing the API being implemented. Many forward declarations and missing includes were added to a header files to allow them to parse cleanly when included first. The main module rule does in fact have its merits. =] llvm-svn: 169131
2012-11-28Make the LiveRegMatrix analysis available to targets.Jakob Stoklund Olesen
No functional change, just moved header files. Targets can inject custom passes between register allocation and rewriting. This makes it possible to tweak the register allocation before rewriting, using the full global interference checking available from LiveRegMatrix. llvm-svn: 168806
2012-11-27Remove unused MachineLoopRanges analysis.Jakub Staszak
llvm-svn: 168659
2012-06-05Move LiveUnionArray into LiveIntervalUnion.hJakob Stoklund Olesen
It is useful outside RegAllocBase. llvm-svn: 158041
2012-06-05Don't print register names in LiveIntervalUnion::print().Jakob Stoklund Olesen
Soon we'll be making LiveIntervalUnions for register units as well. This was the only place using the RepReg member, so just remove it. llvm-svn: 158038
2011-12-21Oops - LiveIntervalUnion.cpp file does use std::find. Moving STL header ↵Lang Hames
include to LiveIntervalUnion.cpp file. llvm-svn: 147089
2011-08-12Simplify the interference checking code a bit.Jakob Stoklund Olesen
This is possible now that we now longer provide an interface to iterate the interference overlaps. llvm-svn: 137397
2011-08-11Eliminate the last use of InterferenceResult.Jakob Stoklund Olesen
The Query class now holds two iterators instead of an InterferenceResult instance. The iterators are used as bookmarks for repeated collectInterferingVRegs calls. llvm-svn: 137380
2011-08-11Remove more dead code.Jakob Stoklund Olesen
collectInterferingVRegs will be the primary function for interference checks. llvm-svn: 137354
2011-08-11Remove some dead code.Jakob Stoklund Olesen
The InterferenceResult iterator turned out to be less important than we thought it would be. LiveIntervalUnion clients want higher level information, like the list of interfering virtual registers. llvm-svn: 137346
2011-07-08Be more aggressive about following hints.Jakob Stoklund Olesen
RAGreedy::tryAssign will now evict interference from the preferred register even when another register is free. To support this, add the EvictionCost struct that counts how many hints are broken by an eviction. We don't want to break one hint just to satisfy another. Rename canEvict to shouldEvict, and add the first bit of eviction policy that doesn't depend on spill weights: Always make room in the preferred register as long as the evictees can be split and aren't already assigned to their preferred register. Also make the CSR avoidance more accurate. When looking for a cheaper register it is OK to use a new volatile register. Only CSR aliases that have never been used before should be avoided. llvm-svn: 134735
2011-04-11Speed up eviction by stopping collectInterferingVRegs as soon as the spillJakob Stoklund Olesen
weight limit has been exceeded. llvm-svn: 129305
2011-04-11Speed up LiveIntervalUnion::unify by handling end insertion specially.Jakob Stoklund Olesen
This particularly helps with the initial transfer of fixed intervals. llvm-svn: 129277
2011-02-09Add tags to live interval unions to avoid using stale queries.Jakob Stoklund Olesen
The tag is updated whenever the live interval union is changed, and it is tested before using cached information. llvm-svn: 125224
2011-01-09Replace TargetRegisterInfo::printReg with a PrintReg class that also works ↵Jakob Stoklund Olesen
without a TRI instance. Print virtual registers numbered from 0 instead of the arbitrary FirstVirtualRegister. The first virtual register is printed as %vreg0. TRI::NoRegister is printed as %noreg. llvm-svn: 123107
2010-12-17Avoid dereferencing end() in collectInterferingVRegs() when there is noJakob Stoklund Olesen
interference. llvm-svn: 122108
2010-12-17Provide LiveIntervalUnion::Query::checkLoopInterference.Jakob Stoklund Olesen
This is a three-way interval list intersection between a virtual register, a live interval union, and a loop. It will be used to identify interference-free loops for live range splitting. llvm-svn: 122034
2010-12-15Start using SplitKit and MachineLoopRanges in RegAllocGreedy in preparation ofJakob Stoklund Olesen
live range splitting around loops guided by register pressure. So far, trySplit() simply prints a lot of debug output. llvm-svn: 121918
2010-12-14Add LiveIntervalUnion print methods, RegAllocGreedy::trySplit debug spew.Jakob Stoklund Olesen
llvm-svn: 121783
2010-12-14Use TRI::printReg instead of AbstractRegisterDescription when printingJakob Stoklund Olesen
LiveIntervalUnions. llvm-svn: 121781
2010-12-09Add a forgotten initializer for CheckedFirstInterference.Jakob Stoklund Olesen
llvm-svn: 121410
2010-12-09Added register reassignment prototype to RAGreedy. It's a simpleAndrew Trick
heuristic to reshuffle register assignments when we can't find an available reg. llvm-svn: 121388
2010-12-09IntervalMap iterators are heavyweight, so avoid copying them around and useJakob Stoklund Olesen
references instead. Similarly, IntervalMap::begin() is almost as expensive as find(), so use find(x) instead of begin().advanceTo(x); This makes RegAllocBasic run another 5% faster. llvm-svn: 121344
2010-12-08Properly deal with empty intervals when checking for interference.Jakob Stoklund Olesen
llvm-svn: 121319
2010-12-07Switch LiveIntervalUnion from std::set to IntervalMap.Jakob Stoklund Olesen
This speeds up RegAllocBasic by 20%, not counting releaseMemory which becomes way faster. llvm-svn: 121201
2010-11-30Comment typo.Andrew Trick
llvm-svn: 120504
2010-11-30Coding style. No significant functionality. Abandon linear scan styleAndrew Trick
in favor of the widespread llvm style. Capitalize variables and add newlines for visual parsing. Rename variables for readability. And other cleanup. llvm-svn: 120490
2010-11-10RABasic is nearly functionally complete. There are a few remainingAndrew Trick
benchmarks hitting an assertion. Adds LiveIntervalUnion::collectInterferingVRegs. Fixes "late spilling" by checking for any unspillable live vregs among all physReg aliases. llvm-svn: 118701