summaryrefslogtreecommitdiff
path: root/llvm/lib/CodeGen/LiveRangeCalc.cpp
AgeCommit message (Collapse)Author
2025-03-06[CodeGen] Use Register or MCRegister. NFCCraig Topper
2025-02-20Revert "[CodeGen] Remove static member function ↵Christopher Di Bella
Register::isPhysicalRegister. NFC" This reverts commit 5fadb3d680909ab30b37eb559f80046b5a17045e.
2025-02-20[CodeGen] Remove static member function Register::isPhysicalRegister. NFCCraig Topper
Prefer the nonstatic member by converting unsigned to Register instead.
2024-11-13[LiveRangeCalc] Fix isJointlyDominated (#116020)Jay Foad
Check that every path from the entry block to the use block passes through at least one def block. Previously we only checked that at least one path passed through a def block.
2024-11-12[CodeGen] Remove unused includes (NFC) (#115996)Kazu Hirata
Identified with misc-include-cleaner.
2024-09-25LiveRangeCalc: Pass output stream to verifyMatt Arsenault
Restores output on this failure after 71ca9fcb8dc9ea0e1e3a4a47820edc78c398a85e
2023-08-16[LiveRange] Fix inaccurate verification of live-in PhysRegsCarl Ritson
Fix verification that a PhysReg is live in to an MBB. isLiveIn does not handle reg units, so cannot identify when a register would be defined because its super register is partially defined. Additionally a PhysReg may be partial defined at block entry and then fully defined before any use. Reviewed By: foad, arsenm Differential Revision: https://reviews.llvm.org/D157086
2022-03-16Cleanup codegen includesserge-sans-paille
This is a (fixed) recommit of https://reviews.llvm.org/D121169 after: 1061034926 before: 1063332844 Discourse thread: https://discourse.llvm.org/t/include-what-you-use-include-cleanup Differential Revision: https://reviews.llvm.org/D121681
2022-03-10Revert "Cleanup codegen includes"Nico Weber
This reverts commit 7f230feeeac8a67b335f52bd2e900a05c6098f20. Breaks CodeGenCUDA/link-device-bitcode.cu in check-clang, and many LLVM tests, see comments on https://reviews.llvm.org/D121169
2022-03-10Cleanup codegen includesserge-sans-paille
after: 1061034926 before: 1063332844 Differential Revision: https://reviews.llvm.org/D121169
2021-01-29[llvm] Use llvm::lower_bound and llvm::upper_bound (NFC)Kazu Hirata
2020-04-10Split LiveRangeCalc in LiveRangeCalc/LiveIntervalCalc. NFCMarcello Maggioni
Summary: Refactor LiveRangeCalc such that it is now split into two classes The objective is to split all the "register specific" logic away from LiveRangeCalc. The two new classes created are: - LiveRangeCalc - is meant as a generic class to compute and modify live ranges in a generic way. This class should deal only with SlotIndices and VNInfo objects. - LiveIntervalCals - is meant to be equivalent to the old LiveRangeCalc. It computes the liveness virtual registers tracked by a LiveInterval object. With this refactoring LiveRangeCalc can be used to implement tracking of liveness of LiveRanges that represent other things than just registers. Subscribers: MatzeB, qcolombet, mgorny, hiraditya, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D76584
2019-10-17Move LiveRangeCalc header to publicily available position. NFCMarcello Maggioni
Differential Revision: https://reviews.llvm.org/D69078 llvm-svn: 375075
2019-08-01Finish moving TargetRegisterInfo::isVirtualRegister() and friends to ↵Daniel Sanders
llvm::Register as started by r367614. NFC llvm-svn: 367633
2019-03-26[LiveRange] Reset the VNIs when splitting subrangesQuentin Colombet
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 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-10-30Pass TRI to printRegMatt Arsenault
llvm-svn: 345553
2018-06-26Account for undef values from predecessors in extendSegmentsToUsesKrzysztof Parzyszek
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 Braun
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 Mistrih
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 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-08-24[CodeGen] Fix some Clang-tidy modernize-use-using and Include What You Use ↵Eugene Zelenko
warnings; other minor fixes (NFC). llvm-svn: 311703
2017-06-28Rangify loops, formatting changes, use bool instead of unsigned, NFCKrzysztof Parzyszek
llvm-svn: 306557
2017-06-28Missed a check for UndefVI in r306466Krzysztof Parzyszek
llvm-svn: 306553
2017-06-27Create a PHI value when merging with a known undef live-inKrzysztof Parzyszek
Differential Revision: https://reviews.llvm.org/D34640 llvm-svn: 306466
2017-06-27LiveRangeCalc: Slightly improve map usage; NFCMatthias Braun
- 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 Braun
- 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 Parzyszek
llvm-svn: 292446
2017-01-13Remove unused lambda captures. NFCMalcolm Parsons
llvm-svn: 291916
2016-12-16Implement LaneBitmask::any(), use it to replace !none(), NFCIKrzysztof Parzyszek
llvm-svn: 289974
2016-12-15Extract LaneBitmask into a separate typeKrzysztof Parzyszek
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 Braun
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 Arsenault
llvm-svn: 280583
2016-09-02Do not consider subreg defs as reads when computing subrange livenessKrzysztof Parzyszek
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 Parzyszek
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 Parzyszek
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 Braun
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 Stellard
This reverts commit r269016 and also the follow-up commit r269020. This patch caused PR27705. llvm-svn: 269344
2016-05-10LiveIntervalAnalysis: Rework constructMainRangeFromSubranges()Matthias Braun
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 Smith
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 Braun
apropriate; NFC llvm-svn: 248623
2015-05-11LiveRangeCalc: Improve error messages on malformed IRMatthias Braun
llvm-svn: 237008
2015-03-19Do not track subregister liveness when it brings no benefitsMatthias Braun
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 Braun
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 Braun
Those parameters did not necessarily describe kill points but just uses. llvm-svn: 229601
2014-12-24LiveInterval: Introduce createMainRangeFromSubranges().Matthias Braun
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 Braun
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 Braun
Revert until I find out why non-subreg enabled targets break. This reverts commit 6097277eefb9c5fb35a7f493c783ee1fd1b9d6a7. llvm-svn: 224278
2014-12-15LiveRangeCalc: Rewrite subrange calculationMatthias Braun
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