summaryrefslogtreecommitdiff
path: root/llvm/lib/CodeGen/MachineLICM.cpp
AgeCommit message (Collapse)Author
2025-05-24[CodeGen] Remove unused includes (NFC) (#141320)Kazu Hirata
These are identified by misc-include-cleaner. I've filtered out those that break builds. Also, I'm staying away from llvm-config.h, config.h, and Compiler.h, which likely cause platform- or compiler-specific build failures.
2025-04-26[CodeGen] Use `TRI::regunits()` (NFC) (#137356)Sergei Barannikov
2025-04-25[MachineLICM] Recognize registers clobbered at EH landing pad entry (#122446)Ulrich Weigand
EH landing pad entry implicitly clobbers target-specific exception pointer and exception selector registers. The post-RA MachineLICM pass needs to take these into account when deciding whether to hoist an instruction out of the loop that initializes one of these registers. Fixes: https://github.com/llvm/llvm-project/issues/122315
2025-04-15[MachineLICM] Remove CurPreheader parameter that is always nullptr (#135554)Sergei Barannikov
Also, rename `getCurPreheader` -> `getOrCreatePreheader` to make it clear that this method may alter CFG. Update `Changed` if the method modified a loop by splitting a critical edge (this change is not strictly NFC). The removed parameter was probably intended to save compile time by not trying to a critical edge after the first attempt has failed, but it is only tried once per loop. PR: https://github.com/llvm/llvm-project/pull/135554
2025-04-13[CodeGen] Use llvm::append_range (NFC) (#135567)Kazu Hirata
2025-03-02[MachineLICM] Use Register. NFCCraig Topper
2025-01-13[aarch64][win] Update Called Globals info when updating Call Site info (#122762)Daniel Paoliello
Fixes the "use after poison" issue introduced by #121516 (see <https://github.com/llvm/llvm-project/pull/121516#issuecomment-2585912395>). The root cause of this issue is that #121516 introduced "Called Global" information for call instructions modeling how "Call Site" info is stored in the machine function, HOWEVER it didn't copy the copy/move/erase operations for call site information. The fix is to rename and update the existing copy/move/erase functions so they also take care of Called Global info.
2025-01-10Revert "[MachineLICM] Use `RegisterClassInfo::getRegPressureSetLimit` (#119826)"Nikita Popov
This reverts commit b4e17d4a314ed87ff6b40b4b05397d4b25b6636a. This causes a large compile-time regression.
2025-01-09[MachineLICM] Use `RegisterClassInfo::getRegPressureSetLimit` (#119826)Pengcheng Wang
`RegisterClassInfo::getRegPressureSetLimit` is a wrapper of `TargetRegisterInfo::getRegPressureSetLimit` with some logics to adjust the limit by removing reserved registers. It seems that we shouldn't use `TargetRegisterInfo::getRegPressureSetLimit` directly, just like the comment "This limit must be adjusted dynamically for reserved registers" said. Separate from https://github.com/llvm/llvm-project/pull/118787
2024-12-13Reapply "[DomTreeUpdater] Move critical edge splitting code to updater" ↵paperchalice
(#119547) This relands commit #115111. Use traditional way to update post dominator tree, i.e. break critical edge splitting into insert, insert, delete sequence. When splitting critical edges, the post dominator tree may change its root node, and `setNewRoot` only works in normal dominator tree... See https://github.com/llvm/llvm-project/blob/6c7e5827eda26990e872eb7c3f0d7866ee3c3171/llvm/include/llvm/Support/GenericDomTree.h#L684-L687
2024-12-11Revert "[DomTreeUpdater] Move critical edge splitting code to updater" (#119512)paperchalice
Reverts llvm/llvm-project#115111 Causes #119511
2024-12-11[DomTreeUpdater] Move critical edge splitting code to updater (#115111)paperchalice
Support critical edge splitting in dominator tree updater. Continue the work in #100856. Compile time check: https://llvm-compile-time-tracker.com/compare.php?from=87c35d782795b54911b3e3a91a5b738d4d870e55&to=42b3e5623a9ab4c3648564dc0926b36f3b438a3a&stat=instructions%3Au
2024-11-21[MachineLICM] Don't allow hoisting invariant loads across mem barrier. (#116987)Florian Hahn
The improvements in 63917e1 / #70796 do not check for memory barriers/unmodelled sideeffects, which means we may incorrectly hoist loads across memory barriers. Fix this by checking any machine instruction in the loop is a load-fold barrier. PR: https://github.com/llvm/llvm-project/pull/116987
2024-11-21[DebugInfo][InstrRef][MIR][GlobalIsel][MachineLICM] NFC Use std::move to ↵abhishek-kaushik22
avoid copying (#116935)
2024-11-12[CodeGen] Remove unused includes (NFC) (#115996)Kazu Hirata
Identified with misc-include-cleaner.
2024-11-09[Instrumentation] Support `MachineFunction` in `OptNoneInstrumentation` ↵paperchalice
(#115471) Support `MachineFunction` in `OptNoneInstrumentation`, also add `isRequired` to all necessary passes.
2024-11-05[NFC] Use `std::move` to avoid copy (#113080)abhishek-kaushik22
2024-10-25[CodeGen][NFC] Properly split MachineLICM and EarlyMachineLICM (#113573)Gaëtan Bossu
Both are based on MachineLICMBase, and the functionality there is "switched" based on a PreRegAlloc flag. This commit is simply about trusting the original value of that flag, defined by the `MachineLICM` and `EarlyMachineLICM` classes. The `PreRegAlloc` flag used to be overwritten it based on MRI.isSSA(), which is un-reliable due to how it is inferred by the MIRParser. I see that we can now define isSSA in MIR (thanks @gargaroff ), meaning the fix isn’t really needed anymore, but redefining that flag still feels wrong. Note that I'm looking into upstreaming more changes to MachineLICM, see [the discourse thread](https://discourse.llvm.org/t/extending-post-regalloc-machinelicm/82725).
2024-09-30[MachineLICM] Avoid repeated hash lookups (NFC) (#110452)Kazu Hirata
2024-09-26[NFC] Reapply 3f37c517f, SmallDenseMap speedupsJeremy Morse
This time with 100% more building unit tests. Original commit message follows. [NFC] Switch a number of DenseMaps to SmallDenseMaps for speedup (#109417) If we use SmallDenseMaps instead of DenseMaps at these locations, we get a substantial speedup because there's less spurious malloc traffic. Discovered by instrumenting DenseMap with some accounting code, then selecting sites where we'll get the most bang for our buck.
2024-09-25Revert "[NFC] Switch a number of DenseMaps to SmallDenseMaps for speedup ↵Jeremy Morse
(#109417)" This reverts commit 3f37c517fbc40531571f8b9f951a8610b4789cd6. Lo and behold, I missed a unit test
2024-09-25[NFC] Switch a number of DenseMaps to SmallDenseMaps for speedup (#109417)Jeremy Morse
If we use SmallDenseMaps instead of DenseMaps at these locations, we get a substantial speedup because there's less spurious malloc traffic. Discovered by instrumenting DenseMap with some accounting code, then selecting sites where we'll get the most bang for our buck.
2024-09-20[NewPM][CodeGen] Port MachineLICM to NPM (#107376)Akshat Oke
2024-07-26[CodeGen] Remove AA parameter of isSafeToMove (#100691)Pengcheng Wang
This `AA` parameter is not used and for most uses they just pass a nullptr. The use of `AA` was removed since 8d0383e.
2024-07-24[llvm][MachineLICM] Fix a comment typo. NFCJon Roelofs
2024-07-12[CodeGen][NewPM] Port `machine-block-freq` to new pass manager (#98317)paperchalice
- Add `MachineBlockFrequencyAnalysis`. - Add `MachineBlockFrequencyPrinterPass`. - Use `MachineBlockFrequencyInfoWrapperPass` in legacy pass manager. - `LazyMachineBlockFrequencyInfo::print` is empty, drop it due to new pass manager migration.
2024-07-11Revert "[CodeGen] Remove `applySplitCriticalEdges` in `MachineDominatorTree` ↵Nikita Popov
(#97055)" This reverts commit c5e5088033fed170068d818c54af6862e449b545. Causes large compile-time regressions.
2024-07-11[CodeGen] Remove `applySplitCriticalEdges` in `MachineDominatorTree` (#97055)paperchalice
Summary: - Remove wrappers in `MachineDominatorTree`. - Remove `MachineDominatorTree` update code in `MachineBasicBlock::SplitCriticalEdge`. - Use `MachineDomTreeUpdater` in passes which call `MachineBasicBlock::SplitCriticalEdge` and preserve `MachineDominatorTreeWrapperPass` or CFG analyses. Commit abea99f65a97248974c02a5544eaf25fc4240056 introduced related methods in 2014. Now we have SemiNCA based dominator tree in 2017 and dominator tree updater, the solution adopted here seems a bit outdated.
2024-07-09[CodeGen][NewPM] Port `machine-loops` to new pass manager (#97793)paperchalice
- Add `MachineLoopAnalysis`. - Add `MachineLoopPrinterPass`. - Convert to `MachineLoopInfoWrapperPass` in legacy pass manager.
2024-06-20[MachineLICM] Work-around Incomplete RegUnits (#95926)Pierre van Houtryve
Reverts the behavior introduced by 770393b while keeping the refactored code. Fixes a miscompile on AArch64, at the cost of a small regression on AMDGPU. #96146 opened to investigate the issue
2024-06-17[CodeGen] Do not include $noreg in any regmask operands. NFCI. (#95775)Jay Foad
Saying that a call preserves $noreg seems weird and required a workaround in MachineLICM.
2024-06-17[MachineLICM] Correctly Apply Register Masks (#95746)Pierre van Houtryve
Fix regression introduced in d4b8b72
2024-06-12[NFC][MachineLICM] Use SmallDenseSet instead of SmallSet (#95201)Pierre van Houtryve
All values are small so no reason to ever use SmallSet really. In large programs we'll end up using std::set which is extremely slow compared to DenseSet. This brings a decent speedup to the pass in large programs.
2024-06-11[CodeGen][NewPM] Split `MachineDominatorTree` into a concrete analysis ↵paperchalice
result (#94571) Prepare for new pass manager version of `MachineDominatorTreeAnalysis`. We may need a machine dominator tree version of `DomTreeUpdater` to handle `SplitCriticalEdge` in some CodeGen passes.
2024-06-11[CodeGen][MachineLICM] Use RegUnits in HoistRegionPostRA (#94608)Pierre van Houtryve
Those BitVectors get expensive on targets like AMDGPU with thousands of registers, and RegAliasIterator is also expensive. We can move all liveness calculations to use RegUnits instead to speed it up for targets where RegAliasIterator is expensive, like AMDGPU. On targets where RegAliasIterator is cheap, this alternative can be a little more expensive, but I believe the tradeoff is worth it.
2024-05-29[MachineLICM] Hoist copies of constant physical register (#93285)Pengcheng Wang
Previously, we just check if the source is a virtual register and this prevents some potential hoists. We can see some improvements in AArch64/RISCV tests.
2024-05-01MachineLICM: Allow hoisting REG_SEQUENCE (#90638)Matt Arsenault
2024-04-30MachineLICM: Remove unnecessary isReg checksMatt Arsenault
COPY operands are always registers.
2024-02-27[MachineLICM] Hoist COPY instruction only when user can be hoisted (#81735)michaelselehov
befa925acac8fd6a9266e introduced preliminary hoisting of COPY instructions when the user of the COPY is inside the same loop. That optimization appeared to be too aggressive and hoisted too many COPY's greatly increasing register pressure causing performance regressions for AMDGPU target. This is intended to fix the regression by hoisting COPY instruction only if either: - User of COPY can be hoisted (other args are invariant) or - Hoisting COPY doesn't bring high register pressure
2023-11-27[MachineLICM] Fix incorrect CSE on hoisted const load (#73007)Igor Kirillov
When hoisting an invariant load, we should not combine it with an existing load through common subexpression elimination (CSE). This is because there might be memory-changing instructions between the existing load and the end of the block entering the loop. Fixes https://github.com/llvm/llvm-project/issues/72855
2023-11-20[MachineLICM][AArch64] Hoist COPY instructions with other uses in the loop ↵Rin
(#71403) When there is a COPY instruction in the loop with other uses, we want to hoist the COPY, which in turn leads to the users being hoisted as well. Co-authored-by David Green : David.Green@arm.com
2023-11-16[MachineLICM] Allow hoisting loads from invariant address (#70796)Igor Kirillov
Sometimes, loads can appear in a loop after the LICM pass is executed the final time. For example, ExpandMemCmp pass creates loads in a loop, and one of the operands may be an invariant address. This patch extends the pre-regalloc stage MachineLICM by allowing to hoist invariant loads from loops that don't have any stores or calls and allows load reorderings.
2023-10-09Revert "[MachineLICM] Relax overlay conservative PHI check (#67186)" (#68580)Hendrik Greving
This reverts commit 71a8d2e3064fcb3ff76565e6e8529613f90aa51b.
2023-10-09[MachineLICM] Relax overlay conservative PHI check (#67186)Hendrik Greving
Skip LICM if PHI belongs to the current loop, e.g. is in the loop's header. This prevents LICM from bailing for CFGs like L1: R = LoopInvariant // can be LICM'd BR L1 L2: PHI(R, ..) BR L2
2023-09-28[MachineLICM] Clear subregister kill flags (#67240)Karl-Johan Karlsson
When hosting a loop invariant instruction the resulting register must be live in all the basic blocks of the loop body and the killed flags of the register must be cleared. Before this patch killed flags of subregister to a hoisted superregister was not cleared in the loop body. This was found in an out of tree target, but the testcase mlicm-stack-write-check.mir was modified to trigger the case.
2023-09-26[MachineLICM] Handle SubloopsJingu Kang
It is a re-commit from reverted commit 3454cf67bd0a650097dc6ca99874a34e1d59b500. Following discussion on https://reviews.llvm.org/D154205, make MachineLICM pass handle subloops with only visiting outermost loop's blocks once. Differential Revision: https://reviews.llvm.org/D154205
2023-09-15Revert "[MachineLICM] Handle Subloops"Benjamin Kramer
This reverts commit 5ec9699c4d1f165364586d825baef434e2c110b4. It accesses MI after it has been hoisted.
2023-09-14[MachineLICM] Handle SubloopsJingu Kang
Following discussion on https://reviews.llvm.org/D154205, make MachineLICM pass handle subloops with only visiting outermost loop's blocks once. Differential Revision: https://reviews.llvm.org/D154205
2023-08-13[MachineLICM][WinEH] Don't hoist register reloads out of funcletsKarl-Johan Johnsson
This fixes https://github.com/llvm/llvm-project/issues/60766 With MSVC style exception-handling (funclets), no registers are alive when entering the funclet so they must be reloaded from the stack. MachineLICM can sometimes hoist such reloads out of the funclet which is not correct, the register will have been clobbered when entering the funclet. This can happen in any loop that contains a try-catch. This has been tested on x86_64-pc-window-msvc. I'm not sure if funclets work the same on the other windows archs. Reviewed By: rnk, arsenm Differential Revision: https://reviews.llvm.org/D153337
2023-08-01[CodeGen] Make use of isSubRegisterEq and isSuperRegisterEq. NFC.Jay Foad