summaryrefslogtreecommitdiff
path: root/llvm/lib/CodeGen/MachineVerifier.cpp
AgeCommit message (Collapse)Author
2025-05-22[LLVM][CodeGen] Add convenience accessors for MachineFunctionProperties ↵users/pcc/spr/main.elf-add-branch-to-branch-optimizationRahul Joshi
(#140002) Add per-property has<Prop>/set<Prop>/reset<Prop> functions to MachineFunctionProperties.
2025-03-23[CodeGen] Use *Set::insert_range (NFC) (#132651)Kazu Hirata
We can use *Set::insert_range to collapse: for (auto Elem : Range) Set.insert(E); down to: Set.insert_range(Range);
2025-03-22[llvm] Use *Set::insert_range (NFC) (#132509)Kazu Hirata
DenseSet, SmallPtrSet, SmallSet, SetVector, and StringSet recently gained C++23-style insert_range. This patch uses insert_range in conjunction with llvm::{predecessors,successors} and MachineBasicBlock::{predecessors,successors}.
2025-03-20[llvm] Use *Set::insert_range (NFC) (#132325)Kazu Hirata
DenseSet, SmallPtrSet, SmallSet, SetVector, and StringSet recently gained C++23-style insert_range. This patch replaces: Dest.insert(Src.begin(), Src.end()); with: Dest.insert_range(Src); This patch does not touch custom begin like succ_begin for now.
2025-03-20[Intrinsics] Add Intrinsic::getFnAttributes() (NFC) (#132029)Nikita Popov
Most places that call Intrinsic::getAttributes() are only interested in the function attributes, so add a separate function for that. The motivation for this is that I'd like to add the ability to specify range attributes on intrinsics, which requires knowing the function type. This avoids needing to know the type for most attribute queries.
2025-03-18[CodeGen][GlobalISel] Add a getVectorIdxWidth and getVectorIdxLLT. (#131526)David Green
From #106446, this adds a variant of getVectorIdxTy that returns an LLT. Many uses only look at the width, so a getVectorIdxWidth was added as the common base.
2025-03-04MachineVerifier: Print name of failing subregister index (#129491)Matt Arsenault
I'm not sure of a good example to test the "does not fully support" case.
2025-02-21[MachineVerifier] Use Register instead of unsigned for DenseSet key. NFC ↵Craig Topper
(#128234)
2025-02-05[MachineVerifier][NewPM] Add method to run MF through verifier. (#125701)Christudasan Devadasan
2025-01-30[CodeGen] Use non-static Register::virtRegIndex() instead of static ↵Craig Topper
Register::virtReg2Index. NFC (#125031) These are the the ones where we already had a Register object being used. Some places are still using unsigned which I did not convert.
2025-01-30MachineVerifier: Fix check for range type (#124894)Matt Arsenault
We need to permit scalar extending loads with range annotations. Fix expensive_checks failures after 11db7fb09b36e656a801117d6a2492133e9c2e46
2025-01-28[GlobalISel] Catching inconsistencies in load memory, result, and range ↵Renat Idrisov
metadata type (#121247) This is a fix for: https://github.com/llvm/llvm-project/issues/97290 Please let me know if that is the right way to address the issue. Thank you! --------- Co-authored-by: Renat Idrisov <parsifal-47@users.noreply.github.com> Co-authored-by: Matt Arsenault <arsenm2@gmail.com>
2025-01-24[CodeGen] Introduce a VirtRegOrUnit class to hold virtual reg or physical ↵Craig Topper
reg unit. NFC (#123768) LiveIntervals and MachineVerifier were previously using Register to store this, but reg units are different than physical registers. One important difference is that 0 is a valid reg unit number, but it is not a valid phyiscal register. This patch introduces a new VirtRegOrUnit class that is distinct from Register. It can be be converted to/from a virtual Register or a MCRegUnit. I've made all conversions explicit and used assertions to check the validity. I also fixed a place in MachineVerifier that was ignoring reg unit 0.
2025-01-21[CodeGen] Use MCRegister instead of MCPhysReg in RegisterMaskPair. NFC (#123688)Craig Topper
Update some other places to avoid implicit conversions this introduces, but I probably missed some.
2025-01-14MachineVerifier: Check stack protector is top-most in frame (#122635)Guy David
Mitigate against potential bugs that might place it elsewhere and render the mechanism useless.
2025-01-10Revert 86b1b0671cafd "MachineVerifier: Check stack protector is top-most in ↵Simon Pilgrim
frame" (#122444) Reverts llvm/llvm-project#121481 This is causing build failures on EXPENSIVE_CHECKS builds: https://lab.llvm.org/buildbot/#/builders/187/builds/3653 https://lab.llvm.org/buildbot/#/builders/16/builds/11758
2025-01-10MachineVerifier: Check stack protector is top-most in frame (#121481)Guy David
Somewhat paranoid, but mitigates potential bugs in the future that might place it elsewhere and render the mechanism useless.
2024-12-15[GISel] Improve MachineVerifier for G_SCMP/UCMP. (#120017)Craig Topper
-Ensure destination type is at least 2 bits. -Remove unnecessary check that both sources are the same type. The verifier already handles this generically.
2024-12-15[GISel] Remove unnecessary MachineVerifier checks for G_ABDS/G_ABDU. (#120014)Craig Topper
These are declared to use a single type index for all operands in GenericOpcodes.td and the verifier knows how to check that all operands with the same type index match.
2024-12-06[CodeGen][NewPM] Port LiveStacks analysis to NPM (#118778)Akshat Oke
2024-12-04[GlobalISel] Add G_ABDS and G_ABDU instructions (#118122)Thorsten Schütt
The DAG has the same instructions: the signed and unsigned absolute difference of it's input. For AArch64, they map to uabd and sabd for Neon and SVE. The Neon and SVE instructions will require custom patterns. They are pseudo opcodes and are not imported by the IRTranslator. We need combines to create them. PowerPC, ARM, and AArch64 have native instructions. /// i.e trunc(abs(sext(Op0) - sext(Op1))) becomes abds(Op0, Op1) /// or trunc(abs(zext(Op0) - zext(Op1))) becomes abdu(Op0, Op1) For GlobalISel, we are going to write the combines in MIR patterns. see: llvm/test/CodeGen/AArch64/abd-combine.ll - [ ] combine into abd - [ ] legalize and add td patterns
2024-11-25[RISCV][MachineVerifier] Use RegUnit for register liveness checking (#115980)Piyou Chen
For the RISC-V target, V14_V15 are not subregisters of v14m4, even though they share some registers. Currently, the MachineVerifier reports an error when checking register liveness for segment load/store operations. This patch adds additional register liveness checking, using RegUnit instead of subregisters, to prevent this error.
2024-11-11[GlobalISel] Add G_STEP_VECTOR instruction (#115598)Thorsten Schütt
aka llvm.stepvector Intrinsic
2024-11-08[GlobalISel][AArch64] Allow vector ptr to int unmerges (#115228)David Green
Vector pointer -> scalar integer unmerges are already legal. This loosens the verifier check for vector-of-pointers -> vectors.
2024-10-11[MachineVerifier] Report errors from one thread at a time (#111605)Ellis Hoag
Create the `ReportedErrors` class to track the number of reported errors during verification. The class will block reporting errors if some other thread is currently reporting an error. I've encountered a case where there were many different verifications reporting errors at the same time on different threads. This ensures that we don't start printing the error from one case until we are completely done printing errors from other cases. Most of the time `AbortOnError = true` so we usually abort after reporting the first error. Depends on https://github.com/llvm/llvm-project/pull/111602.
2024-10-09[NFC] Format MachineVerifier.cpp to remove extra indentation (#111602)Ellis Hoag
Many structs in this class have the wrong indentation. To generate this diff, I touched the first line of each struct and then ran `git clang-format`. This will make blaming more difficult, but this autoformatting is difficult to avoid triggering. I think it's best to push this as one NFC PR.
2024-09-24llvm-reduce: Don't print verifier failed machine functions (#109673)Matt Arsenault
This produces far too much terminal output, particularly for the instruction reduction. Since it doesn't consider the liveness of of the instructions it's deleting, it produces quite a lot of verifier errors.
2024-09-24LiveInterval: Make verify functions return bool (#109672)Matt Arsenault
This will allow the MachineVerifier to check these properties instead of just asserting
2024-09-18[MachineVerifier] Improve checks for G_INSERT_SUBVECTOR. (#109209)Craig Topper
-Improve messages. -Remove redundant checks that are handled in generic code. -Add check that the subvector is smaller than the vector. -Add checks that subvector is smaller than the vector.
2024-09-18[MachineVerifier] Improve G_EXTRACT_SUBVECTOR checking (#109202)Craig Topper
Check that the destination of G_EXTRACT_SUBVECTOR is smaller than the source. Improve wording of error messages.
2024-09-17[MachineVerifier] Fix bug in MachineVerifier for G_INSERT_SUBVECTOR (#109048)Michael Maitland
2024-09-17[GISEL] Fix bugs and clarify spec of G_EXTRACT_SUBVECTOR (#108848)Michael Maitland
The implementation was missing the fact that `G_EXTRACT_SUBVECTOR` destination and source vector can be different types. Also fix a bug in the MIR builder for `G_EXTRACT_SUBVECTOR` to generate the correct opcode. Clarify the G_EXTRACT_SUBVECTOR specification.
2024-08-29[GISel][RISCV] Correctly handle scalable vector shuffles of pointer vectors ↵Craig Topper
in IRTranslator. (#106580)
2024-08-20llvm.lround: Update verifier to validate support of vector types. (#98950)Sumanth Gundapaneni
Both IRVerifier and Machine Verifier are updated
2024-07-18[GlobalIsel] Add G_SCMP and G_UCMP instructions (#98894)Thorsten Schütt
https://github.com/llvm/llvm-project/pull/83227
2024-07-15[CodeGen][NewPM] Port `MachineVerifier` to new pass manager (#98628)paperchalice
- Add `MachineVerifierPass`. - Use complete `MachineVerifierPass` in `VerifyInstrumentation` if possible. `LiveStacksAnalysis` will be added in future, all other analyses are done.
2024-07-10[CodeGen][NewPM] Port `LiveIntervals` to new pass manager (#98118)paperchalice
- Add `LiveIntervalsAnalysis`. - Add `LiveIntervalsPrinterPass`. - Use `LiveIntervalsWrapperPass` in legacy pass manager. - Use `std::unique_ptr` instead of raw pointer for `LICalc`, so destructor and default move constructor can handle it correctly. This would be the last analysis required by `PHIElimination`.
2024-07-09[CodeGen][NewPM] Port `SlotIndexes` to new pass manager (#97941)paperchalice
- Add `SlotIndexesAnalysis`. - Add `SlotIndexesPrinterPass`. - Use `SlotIndexesWrapperPass` in legacy pass.
2024-07-09[CodeGen][NewPM] Port `LiveVariables` to new pass manager (#97880)paperchalice
- Port `LiveVariables` to new pass manager. - Convert to `LiveVariablesWrapperPass` in legacy pass manager.
2024-06-28[PAC][AArch64] Lower ptrauth constants in code (#96879)Daniil Kovalev
This re-applies #94241 after fixing buildbot failure, see https://lab.llvm.org/buildbot/#/builders/51/builds/570 According to standard, `constexpr` variables and `const` variables initialized with constant expressions can be used in lambdas w/o capturing - see https://en.cppreference.com/w/cpp/language/lambda. However, MSVC used on buildkite seems to ignore that rule and does not allow using such uncaptured variables in lambdas: we have "error C3493: 'Mask16' cannot be implicitly captured because no default capture mode has been specified" - see https://buildkite.com/llvm-project/github-pull-requests/builds/73238 Explicitly capturing such a variable, however, makes buildbot fail with "error: lambda capture 'Mask16' is not required to be captured for this use [-Werror,-Wunused-lambda-capture]" - see https://lab.llvm.org/buildbot/#/builders/51/builds/570. Fix both cases by using `0xffff` value directly instead of giving a name to it. Original PR description below. Depends on #94240. Define the following pseudos for lowering ptrauth constants in code: - non-`extern_weak`: - no GOT load needed: `MOVaddrPAC` - similar to `MOVaddr`, with added PAC; - GOT load needed: `LOADgotPAC` - similar to `LOADgot`, with added PAC; - `extern_weak`: `LOADauthptrstatic` - similar to `LOADgot`, but use a special stub slot named `sym$auth_ptr$key$disc` filled by dynamic linker during relocation resolving instead of a GOT slot. --------- Co-authored-by: Ahmed Bougacha <ahmed@bougacha.org>
2024-06-27Revert "[PAC][AArch64] Lower ptrauth constants in code (#94241)" (#96865)Daniil Kovalev
This reverts #94241. See buildbot failure https://lab.llvm.org/buildbot/#/builders/51/builds/570
2024-06-27[PAC][AArch64] Lower ptrauth constants in code (#94241)Daniil Kovalev
Depends on #94240. Define the following pseudos for lowering ptrauth constants in code: - non-`extern_weak`: - no GOT load needed: `MOVaddrPAC` - similar to `MOVaddr`, with added PAC; - GOT load needed: `LOADgotPAC` - similar to `LOADgot`, with added PAC; - `extern_weak`: `LOADauthptrstatic` - similar to `LOADgot`, but use a special stub slot named `sym$auth_ptr$key$disc` filled by dynamic linker during relocation resolving instead of a GOT slot. --------- Co-authored-by: Ahmed Bougacha <ahmed@bougacha.org>
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-04-08[AArch64][GlobalISel] Legalize Insert vector element (#81453)David Green
This attempts to standardize and extend some of the insert vector element lowering. Most notably: - More types are handled by splitting illegal vectors. - The index type for G_INSERT_VECTOR_ELT is canonicalized to TLI.getVectorIdxTy(), similar to extact_vector_element. - Some of the existing patterns now have the index type specified to make sure they can apply to GISel too. - The C++ selection code has been removed, relying on tablegen patterns. - G_INSERT_VECTOR_ELT with small GPR input elements are pre-selected to use a i32 type, allowing the existing patterns to apply. - Variable index inserts are lowered in post-legalizer lowering, expanding into a stack store and reload.
2024-04-01[GISEL] G_SPLAT_VECTOR can take a splat that is larger than the vector ↵Michael Maitland
element (#86974) This is what SelectionDAG does. We'd like to reuse SelectionDAG patterns.
2024-03-26[GISEL][NFC] Use getElementCount instead of getNumElements in more placesMichael Maitland
These cases in particular are done as a precommit to support legalization, regbank selection, and instruction selection for extends, splat vectors, and integer compares in #85938.
2024-03-23[GlobalISel] Introduce G_TRAP, G_DEBUGTRAP, G_UBSANTRAP (#84941)Evgenii Kudriashov
Here we introduce three new GMIR instructions to cover a set of trap intrinsics. The idea behind it is that generic intrinsics shouldn't be used with G_INTRINSIC opcode. These new instructions can match perfectly with existing trap ISD nodes. It allows X86, AArch64, RISCV and Mips to reuse SelectionDAG patterns for selection and avoid manual selection. However AMDGPU is an exception. It selects traps during legalization regardless SelectionDAG or GlobalISel. Since there are not many places where traps are used, this change attempts to clean up all the usages of G_INTRINSIC with trap intrinsics. So, there is no stage when both G_TRAP and G_INTRINSIC_W_SIDE_EFFECTS(@llvm.trap) are allowed.
2024-03-21Reapply "Move assertion for AdjustsStack from PEI to MachineVerifier (#85698)"Jonas Paulsson
- The check is now actually done in both PEI and the MachineVerifier. - More .mir tests trivially updated with "adjustsStack: true" as needed.
2024-03-20Revert "Move assertion for AdjustsStack from PEI to MachineVerifier. (#85698)"Jonas Paulsson
This reverts commit 05bde30585710a51592eee0a6cf6df8184d09c92. Reverting due to verifier complaints with expensive checks on build-bot.
2024-03-20Move assertion for AdjustsStack from PEI to MachineVerifier. (#85698)Jonas Paulsson
Have the verifier report a missing AdjustsStack flag rather than waiting until PEI asserts.