aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/CodeGen/LiveRangeCalc.cpp
AgeCommit message (Collapse)AuthorFilesLines
2019-08-01Finish moving TargetRegisterInfo::isVirtualRegister() and friends to ↵Daniel Sanders1-2/+1
llvm::Register as started by r367614. NFC llvm-svn: 367633
2019-03-26[LiveRange] Reset the VNIs when splitting subrangesQuentin Colombet1-4/+5
When splitting a subrange we end up with two different subranges covering two different, non overlapping, lanes. As part of this splitting the VNIs of the original live-range need to be dispatched to the subranges according to which lanes they are actually defining. Prior to this patch we were assuming that all values were defining all lanes. This was wrong as demonstrated by llvm.org/PR40835. Differential Revision: https://reviews.llvm.org/D59731 llvm-svn: 357032
2019-01-19Update the file headers across all of the LLVM projects in the monorepoChandler Carruth1-4/+3
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-10-30Pass TRI to printRegMatt Arsenault1-1/+1
llvm-svn: 345553
2018-06-26Account for undef values from predecessors in extendSegmentsToUsesKrzysztof Parzyszek1-0/+21
It is legal for a PHI node not to have a live value in a predecessor as long as the end of the predecessor is jointly dominated by an undef value. llvm-svn: 335607
2017-12-13Rename LiveIntervalAnalysis.h to LiveIntervals.hMatthias Braun1-1/+1
Headers/Implementation files should be named after the class they declare/define. Also eliminated an `#include "llvm/CodeGen/LiveIntervalAnalysis.h"` in favor of `class LiveIntarvals;` llvm-svn: 320546
2017-12-04[CodeGen] Unify MBB reference format in both MIR and debug outputFrancis Visoiu Mistrih1-1/+1
As part of the unification of the debug format and the MIR format, print MBB references as '%bb.5'. The MIR printer prints the IR name of a MBB only for block definitions. * find . \( -name "*.mir" -o -name "*.cpp" -o -name "*.h" -o -name "*.ll" \) -type f -print0 | xargs -0 sed -i '' -E 's/BB#" << ([a-zA-Z0-9_]+)->getNumber\(\)/" << printMBBReference(*\1)/g' * find . \( -name "*.mir" -o -name "*.cpp" -o -name "*.h" -o -name "*.ll" \) -type f -print0 | xargs -0 sed -i '' -E 's/BB#" << ([a-zA-Z0-9_]+)\.getNumber\(\)/" << printMBBReference(\1)/g' * find . \( -name "*.txt" -o -name "*.s" -o -name "*.mir" -o -name "*.cpp" -o -name "*.h" -o -name "*.ll" \) -type f -print0 | xargs -0 sed -i '' -E 's/BB#([0-9]+)/%bb.\1/g' * grep -nr 'BB#' and fix Differential Revision: https://reviews.llvm.org/D40422 llvm-svn: 319665
2017-11-28[CodeGen] Rename functions PrintReg* to printReg*Francis Visoiu Mistrih1-2/+2
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 Blaikie1-1/+1
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-08-24[CodeGen] Fix some Clang-tidy modernize-use-using and Include What You Use ↵Eugene Zelenko1-9/+21
warnings; other minor fixes (NFC). llvm-svn: 311703
2017-06-28Rangify loops, formatting changes, use bool instead of unsigned, NFCKrzysztof Parzyszek1-18/+16
llvm-svn: 306557
2017-06-28Missed a check for UndefVI in r306466Krzysztof Parzyszek1-1/+1
llvm-svn: 306553
2017-06-27Create a PHI value when merging with a known undef live-inKrzysztof Parzyszek1-8/+19
Differential Revision: https://reviews.llvm.org/D34640 llvm-svn: 306466
2017-06-27LiveRangeCalc: Slightly improve map usage; NFCMatthias Braun1-8/+11
- DenseMap should be faster than std::map - Use the `InsertRes = insert() if (!InsertRes.inserted)` pattern rather than the `if (!X.contains(...)) { X.insert(...); }` to save one map lookup. llvm-svn: 306436
2017-03-03RegisterCoalescer: Simplify subrange splitting code; NFCMatthias Braun1-27/+4
- Use slightly better variable names / compute in a more direct way. llvm-svn: 296905
2017-01-18Treat segment [B, E) as not overlapping block with boundaries [A, B)Krzysztof Parzyszek1-1/+6
llvm-svn: 292446
2017-01-13Remove unused lambda captures. NFCMalcolm Parsons1-2/+1
llvm-svn: 291916
2016-12-16Implement LaneBitmask::any(), use it to replace !none(), NFCIKrzysztof Parzyszek1-2/+2
llvm-svn: 289974
2016-12-15Extract LaneBitmask into a separate typeKrzysztof Parzyszek1-7/+8
Specifically avoid implicit conversions from/to integral types to avoid potential errors when changing the underlying type. For example, a typical initialization of a "full" mask was "LaneMask = ~0u", which would result in a value of 0x00000000FFFFFFFF if the type was extended to uint64_t. Differential Revision: https://reviews.llvm.org/D27454 llvm-svn: 289820
2016-09-19LiveRangeCalc: Fix reporting of invalid vreg usage in liveness calculationMatthias Braun1-3/+3
Machine programs need a definition of each vreg before reaching a use (the definition may come from an IMPLICIT_DEF instruction). This class of errors is not detected by the MachineVerifier because of efficiency concerns. LiveRangeCalc used to report these problems, make it do that again (followup to r279625). Also use report_fatal_error() instead of llvm_unreachable() as the error reporting is only present in asserts build anyway. llvm-svn: 281914
2016-09-03Improve debug error message with register nameMatt Arsenault1-1/+2
llvm-svn: 280583
2016-09-02Do not consider subreg defs as reads when computing subrange livenessKrzysztof Parzyszek1-1/+6
Subregister definitions are considered uses for the purpose of tracking liveness of the whole register. At the same time, when calculating live interval subranges, subregister defs should not be treated as uses. Differential Revision: https://reviews.llvm.org/D24190 llvm-svn: 280532
2016-08-29Do not use MRI::getMaxLaneMaskForVReg as a mask covering whole registerKrzysztof Parzyszek1-4/+3
MRI::getMaxLaneMaskForVReg does not always cover the whole register. For example, on X86 the upper 16 bits of EAX cannot be accessed via any subregister. Consequently, there is no lane mask that only covers that part of EAX. The getMaxLaneMaskForVReg will return the union of the lane masks for all subregisters, and in case of EAX, that union will not cover the upper 16 bits. This fixes https://llvm.org/bugs/show_bug.cgi?id=29132 llvm-svn: 279969
2016-08-24Create subranges for new intervals resulting from live interval splittingKrzysztof Parzyszek1-50/+141
The register allocator can split a live interval of a register into a set of smaller intervals. After the allocation of registers is complete, the rewriter will modify the IR to replace virtual registers with the corres- ponding physical registers. At this stage, if a register corresponding to a subregister of a virtual register is used, the rewriter will check if that subregister is undefined, and if so, it will add the <undef> flag to the machine operand. The function verifying liveness of the subregis- ter would assume that it is undefined, unless any of the subranges of the live interval proves otherwise. The problem is that the live intervals created during splitting do not have any subranges, even if the original parent interval did. This could result in the <undef> flag placed on a register that is actually defined. Differential Revision: http://reviews.llvm.org/D21189 llvm-svn: 279625
2016-05-20LiveIntervalAnalysis: Rework constructMainRangeFromSubranges()Matthias Braun1-1/+17
We now use LiveRangeCalc::extendToUses() instead of a specially designed algorithm in constructMainRangeFromSubranges(): - The original motivation for constructMainRangeFromSubranges() were differences between the main liverange and subranges because of hidden dead definitions. This case however cannot happen anymore with the DetectDeadLaneMasks pass in place. - It simplifies the code. - This fixes a longstanding bug where we did not properly create new SSA values on merging control flow (the MachineVerifier missed most of these cases). - Move constructMainRangeFromSubranges() to LiveIntervalAnalysis and LiveRangeCalc to better match the implementation/available helper functions. This re-applies r269016. The fixes from r270290 and r270259 should avoid the machine verifier problems this time. llvm-svn: 270291
2016-05-12Revert "LiveIntervalAnalysis: Rework constructMainRangeFromSubranges()"Tom Stellard1-17/+1
This reverts commit r269016 and also the follow-up commit r269020. This patch caused PR27705. llvm-svn: 269344
2016-05-10LiveIntervalAnalysis: Rework constructMainRangeFromSubranges()Matthias Braun1-1/+17
We now use LiveRangeCalc::extendToUses() instead of a specially designed algorithm in constructMainRangeFromSubranges(): - The original motivation for constructMainRangeFromSubranges() were differences between the main liverange and subranges because of hidden dead definitions. This case however cannot happen anymore with the DetectDeadLaneMasks pass in place. - It simplifies the code. - This fixes a longstanding bug where we did not properly create new SSA values on merging control flow (the MachineVerifier missed most of these cases). - Move constructMainRangeFromSubranges() to LiveIntervalAnalysis and LiveRangeCalc to better match the implementation/available helper functions. llvm-svn: 269016
2016-02-27CodeGen: Take MachineInstr& in SlotIndexes and LiveIntervals, NFCDuncan P. N. Exon Smith1-6/+6
Take MachineInstr by reference instead of by pointer in SlotIndexes and the SlotIndex wrappers in LiveIntervals. The MachineInstrs here are never null, so this cleans up the API a bit. It also incidentally removes a few implicit conversions from MachineInstrBundleIterator to MachineInstr* (see PR26753). At a couple of call sites it was convenient to convert to a range-based for loop over MachineBasicBlock::instr_begin/instr_end, so I added MachineBasicBlock::instrs. llvm-svn: 262115
2015-09-25TargetRegisterInfo: Add typedef unsigned LaneBitmask and use it where ↵Matthias Braun1-7/+8
apropriate; NFC llvm-svn: 248623
2015-05-11LiveRangeCalc: Improve error messages on malformed IRMatthias Braun1-1/+7
llvm-svn: 237008
2015-03-19Do not track subregister liveness when it brings no benefitsMatthias Braun1-2/+2
Some subregisters are only to indicate different access sizes, while not providing any way to actually divide the register up into multiple disjunct parts. Avoid tracking subregister liveness in these cases as it is not beneficial. Differential Revision: http://reviews.llvm.org/D8429 llvm-svn: 232695
2015-02-20LiveRangeCalc: Don't start liveranges of PHI instruction at the block begin.Matthias Braun1-5/+2
Summary: Letting them begin at the PHI instruction slightly simplifies the code but more importantly avoids breaking the assumption that live ranges starting at the block begin are also live at the end of the predecessor blocks. The MachineVerifier checks that but was apparently never run in the few instances where liveranges are calculated for machine-SSA functions. Reviewers: qcolombet Subscribers: llvm-commits Differential Revision: http://reviews.llvm.org/D7779 llvm-svn: 230093
2015-02-18LiveRangeCalc: Rename some parameters from kill to use, NFC.Matthias Braun1-19/+19
Those parameters did not necessarily describe kill points but just uses. llvm-svn: 229601
2014-12-24LiveInterval: Introduce createMainRangeFromSubranges().Matthias Braun1-7/+12
This function constructs the main liverange by merging all subranges if subregister liveness tracking is available. This should be slightly faster to compute instead of performing the liveness calculation again for the main range. More importantly it avoids cases where the main liverange would cover positions where no subrange was live. These cases happened for partial definitions where the actual defined part was dead and only the undefined parts used later. The register coalescing requires that every part covered by the main live range has at least one subrange live. I also expect this function to become usefull later for places where the subranges are modified in a way that it is hard to correctly fix the main liverange in the machine scheduler, we can simply reconstruct it from subranges then. llvm-svn: 224806
2014-12-16LiveRangeCalc: Rewrite subrange calculationMatthias Braun1-151/+108
This changes subrange calculation to calculate subranges sequentially instead of in parallel. The code is easier to understand that way and addresses the code review issues raised about LiveOutData being hard to understand/needing more comments by removing them :) llvm-svn: 224313
2014-12-15Revert "LiveRangeCalc: Rewrite subrange calculation"Matthias Braun1-102/+149
Revert until I find out why non-subreg enabled targets break. This reverts commit 6097277eefb9c5fb35a7f493c783ee1fd1b9d6a7. llvm-svn: 224278
2014-12-15LiveRangeCalc: Rewrite subrange calculationMatthias Braun1-149/+102
This changes subrange calculation to calculate subranges sequentially instead of in parallel. The code is easier to understand that way and addresses the code review issues raised about LiveOutData being hard to understand/needing more comments by removing them :) llvm-svn: 224272
2014-12-15LiveRangeCalc: use more range based for loops; NFCMatthias Braun1-20/+18
llvm-svn: 224263
2014-12-11LiveInterval: Use range based for loops for subregister ranges.Matthias Braun1-10/+10
llvm-svn: 223991
2014-12-10Silencing a -Wsequence-point warning, and the resulting undefined behavior. NFC.Aaron Ballman1-1/+1
llvm-svn: 223926
2014-12-10Add a flag to enable/disable subregister liveness.Matthias Braun1-2/+3
llvm-svn: 223884
2014-12-10LiveIntervalAnalysis: Compute subregister ranges.Matthias Braun1-60/+188
llvm-svn: 223878
2014-04-22[Modules] Remove potential ODR violations by sinking the DEBUG_TYPEChandler Carruth1-1/+2
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 Topper1-4/+4
instead of comparing to nullptr. llvm-svn: 206142
2014-03-17Switch a number of loops in lib/CodeGen over to range-based for-loops, now thatOwen Anderson1-10/+8
the MachineRegisterInfo iterators are compatible with it. llvm-svn: 204075
2014-03-13Phase 2 of the great MachineRegisterInfo cleanup. This time, we're changingOwen Anderson1-4/+4
operator* on the by-operand iterators to return a MachineOperand& rather than a MachineInstr&. At this point they almost behave like normal iterators! Again, this requires making some existing loops more verbose, but should pave the way for the big range-based for-loop cleanups in the future. llvm-svn: 203865
2014-03-02[C++11] Replace llvm::tie with std::tie.Benjamin Kramer1-4/+4
The old implementation is no longer needed in C++11. llvm-svn: 202644
2013-10-10Work on LiveRange instead of LiveInterval where possibleMatthias Braun1-30/+26
Also change some pointer arguments to references at some places where 0-pointers are not allowed. llvm-svn: 192396
2013-10-10Rename LiveRange to LiveInterval::SegmentMatthias Braun1-2/+2
The Segment struct contains a single interval; multiple instances of this struct are used to construct a live range, but the struct is not a live range by itself. llvm-svn: 192392
2013-02-20Copy single reaching defs directly into the LiveInterval.Jakob Stoklund Olesen1-34/+60
When findReachingDefs() finds that only one value can reach the basic block, just copy the work list of visited blocks directly into the live interval. Sort the block list and use a LiveRangeUpdater to make the bulk add fast. When multiple reaching defs are found, transfer the work list to the updateSSA() work list as before. Also use LiveRangeUpdater in updateLiveIns() following updateSSA(). This makes live interval analysis more than 3x faster on one huge test case. llvm-svn: 175685