aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/CodeGen/MIRParser/MIParser.cpp
AgeCommit message (Collapse)AuthorFilesLines
2025-07-30[GISel] Introduce MIFlags::InBounds (#150900)Fabian Ritter1-1/+4
This flag applies to G_PTR_ADD instructions and indicates that the operation implements an inbounds getelementptr operation, i.e., the pointer operand is in bounds wrt. the allocated object it is based on, and the arithmetic does not change that. It is set when the IRTranslator lowers inbounds GEPs (currently only in some cases, to be extended with a future PR), and in the (build|materialize)ObjectPtrOffset functions. Inbounds information is useful in ISel when we have instructions that perform address computations whose intermediate steps must be in the same memory region as the final result. A follow-up patch will start using it for AMDGPU's flat memory instructions, where the immediate offset must not affect the memory aperture of the address. This is analogous to a concurrent effort in SDAG: #131862 (related: #140017, #141725). For SWDEV-516125.
2025-07-29[AMDGPU] Add NoaliasAddrSpace to AAMDnodes (#149247)Shoreshen1-1/+6
This is the following PR of https://github.com/llvm/llvm-project/pull/136553 which calculate NoaliasAddrSpace. This PR carries the info calculated into MIR by adding it into AAMDnodes
2025-05-26[llvm] Value-initialize values with *Map::try_emplace (NFC) (#141522)Kazu Hirata1-2/+2
try_emplace value-initializes values, so we do not need to pass nullptr to try_emplace when the value types are raw pointers or std::unique_ptr<T>.
2025-05-08[KeyInstr] Add MIR parser support (#133494)Orlando Cazalet-Hyams1-1/+25
RFC: https://discourse.llvm.org/t/rfc-improving-is-stmt-placement-for-better-interactive-debugging/82668
2025-05-08[CodeGen] Parse nusw flag (#138856)Pierre van Houtryve1-0/+3
Fixes #127781
2025-03-02[CodeGen] Use Register::id() to avoid implicit cast. NFCCraig Topper1-2/+2
2025-02-10[NFC][LLVM] Remove unused `TargetIntrinsicInfo` class (#126003)Rahul Joshi1-7/+1
Remove `TargetIntrinsicInfo` class as its practically unused (its pure virtual with no subclasses) and its references in the code.
2025-02-01[MIParser] Don't use Register to hold Dwarf register numbers. NFC (#125263)Craig Topper1-4/+4
2025-01-20[MIRParser] Avoid repeated map lookups (NFC) (#123561)Kazu Hirata1-2/+3
2024-11-12[CodeGen] Remove unused includes (NFC) (#115996)Kazu Hirata1-1/+0
Identified with misc-include-cleaner.
2024-10-30[GlobalISel] Import samesign flag (#114267)Thorsten Schütt1-1/+4
Credits: https://github.com/llvm/llvm-project/pull/111419 Fixes icmp-flags.mir First attempt: https://github.com/llvm/llvm-project/pull/113090 Revert: https://github.com/llvm/llvm-project/pull/114256
2024-10-30Revert "[GlobalISel] Import samesign flag" (#114256)Thorsten Schütt1-4/+1
Reverts llvm/llvm-project#113090
2024-10-30[GlobalISel] Import samesign flag (#113090)Thorsten Schütt1-1/+4
Credits: https://github.com/llvm/llvm-project/pull/111419
2024-10-28[AArch64][Libunwind] Add Support for FEAT_PAuthLR DWARF Instruction (#112171)Jack Styles1-0/+5
As part of FEAT_PAuthLR, a new DWARF Frame Instruction was introduced, `DW_CFA_AARCH64_negate_ra_state_with_pc`. This instructs Libunwind that the PC has been used with the signing instruction. This change includes three commits - Libunwind support for the newly introduced DWARF Instruction - CodeGen Support for the DWARF Instructions - Reversing the changes made in #96377. Due to `DW_CFA_AARCH64_negate_ra_state_with_pc`'s requirements to be placed immediately after the signing instruction, this would mean the CFI Instruction location was not consistent with the generated location when not using FEAT_PAuthLR. The commit reverses the changes and makes the location consistent across the different branch protection options. While this does have a code size effect, this is a negligible one. For the ABI information, see here: https://github.com/ARM-software/abi-aa/blob/853286c7ab66048e4b819682ce17f567b77a0291/aadwarf64/aadwarf64.rst#id23
2024-10-14[MIR] Add missing noteNewVirtualRegister callbacks (#111634)Akshat Oke1-0/+1
The delegates' callback isn't invoked on parsing new virtual registers. There are two places in the serialization where new virtual registers can be discovered: in register infos and in instructions.
2024-10-14[MIR] Serialize virtual register flags (#110228)Akshat Oke1-0/+10
[MIR] Serialize virtual register flags This introduces target-specific vreg flag serialization. Flags are represented as `uint8_t` and the `TargetRegisterInfo` override provides methods `getVRegFlagValue` to deserialize and `getVRegFlagsOfReg` to serialize.
2024-09-30[NFC] Move intrinsic related functions to Intrinsic namespace (#110125)Rahul Joshi1-1/+1
Move static functions `Function::lookupIntrinsicID` and `Function::isTargetIntrinsic` to Intrinsic namespace.
2024-09-25Reapply "Deprecate the `-fbasic-block-sections=labels` option." (#110039)Rahman Lavaee1-8/+1
This reapplies commit 1911a50fae8a441b445eb835b98950710d28fc88 with a minor fix in lld/ELF/LTO.cpp which sets Options.BBAddrMap when `--lto-basic-block-sections=labels` is passed.
2024-09-25Revert "Deprecate the `-fbasic-block-sections=labels` option. (#107494)"Kazu Hirata1-1/+8
This reverts commit 1911a50fae8a441b445eb835b98950710d28fc88. Several bots are failing: https://lab.llvm.org/buildbot/#/builders/190/builds/6519 https://lab.llvm.org/buildbot/#/builders/3/builds/5248 https://lab.llvm.org/buildbot/#/builders/18/builds/4463
2024-09-25Deprecate the `-fbasic-block-sections=labels` option. (#107494)Rahman Lavaee1-8/+1
This feature is supported via the newer option `-fbasic-block-address-map`. Using the old option still works by delegating to the newer option, while a warning is printed to show deprecation.
2024-09-19[LLVM] Use {} instead of std::nullopt to initialize empty ArrayRef (#109133)Jay Foad1-2/+2
It is almost always simpler to use {} instead of std::nullopt to initialize an empty ArrayRef. This patch changes all occurrences I could find in LLVM itself. In future the ArrayRef(std::nullopt_t) constructor could be deprecated or removed.
2024-08-25[llvm] Prefer StringRef::substr to StringRef::slice (NFC) (#105943)Kazu Hirata1-2/+2
S.substr(N) is simpler than S.slice(N, StringRef::npos) and S.slice(N, S.size()). Also, substr is probably better recognizable than slice thanks to std::string_view::substr.
2024-07-31[MIR] Remove separate Size variable from parseMachineMemoryOperand. NFC ↵Craig Topper1-6/+5
(#101453) Size is updated in sync with MemoryType. Instead of maintaining a separate Size, use the size from MemoryType where needed.
2024-07-31[RISCV][GlobalISel] Legalize Scalable Vector Loads and Stores (#84965)Jiahan Xie1-1/+1
This patch supports legalizing load and store instruction for scalable vectors in RISCV
2024-07-10[MIR] Replace bespoke DIExpression parserScott Linder1-42/+8
Resolve FIXME by using the LLParser implementation of parseDIExpression from the MIParser.
2024-06-25[LLVM][MIR] Support parsing bfloat immediates in MIR parser (#96010)Stephen Chou1-0/+1
Adds support in MIR parser for parsing bfloat immediates, and adds a test for this.
2024-03-26[CodeGen] Add nneg and disjoint flags (#86650)Thorsten Schütt1-1/+7
MachineInstr learned the new flags.
2024-03-18[GlobalISel] convergence control tokens and intrinsics (#67006)Sameer Sahasrabuddhe1-5/+8
[GlobalISel] Implement convergence control tokens and intrinsics in GMIR In the IR translator, convert the LLVM token type to LLT::token(), which is an alias for the s0 type. These show up as implicit uses on convergent operations. Differential Revision: https://reviews.llvm.org/D158147
2024-01-31[AsmParser] Support non-consecutive global value numbers (#80013)Nikita Popov1-2/+2
https://github.com/llvm/llvm-project/pull/78171 added support for non-consecutive local value numbers. This extends the support for global value numbers (for globals and functions). This means that it is now possible to delete an unnamed global definition/declaration without breaking the IR. This is a lot less common than unnamed local values, but it seems like something we should support for consistency. (Unnamed globals are used a lot in Rust though.)
2024-01-25[llvm] Move CodeGenTypes library to its own directory (#79444)Nico Weber1-1/+1
Finally addresses https://reviews.llvm.org/D148769#4311232 :) No behavior change.
2023-12-04[CodeGen] Split off PseudoSourceValueManager into separate header (NFC) (#73327)Nikita Popov1-0/+1
Most users of PseudoSourceValue.h only need PseudoSourceValue, not the PseudoSourceValueManager. However, this header pulls in some very expensive dependencies like ValueMap.h, which is only used for the manager. Split off the manager into a separate header and include it only where used.
2023-11-30MachineVerifier: Reject extra non-register operands on instructions (#73758)Matt Arsenault1-12/+3
We were allowing extra immediate arguments, and only bothering to check if registers were implicit or not. Also consolidate extra operand checks in verifier, to make this testable. We had 3 different places checking if you were trying to build an instruction with more operands than allowed by the definition. We had an assertion in addOperand, a direct check in the MIRParser to avoid the assertion, and the machine verifier checks. Remove the assert and parser check so the verifier can provide a consistent verification experience, which will also handle instructions modified in place.
2023-11-02[CodeGen][MIR] Support parsing of scalable vectors in MIR (#70893)Michael Maitland1-8/+26
This patch builds on the support for vectors by adding ability to parse scalable vectors in MIR and updates error messages to reflect that ability.
2023-10-27[BasicBlockSections] Apply path cloning with -basic-block-sections. (#68860)Rahman Lavaee1-6/+12
https://github.com/llvm/llvm-project/commit/28b912687900bc0a67cd61c374fce296b09963c4 introduced the path cloning format in the basic-block-sections profile. This PR validates and applies path clonings. A path cloning is valid if all of these conditions hold: 1. All bb ids in the path are mapped to existing blocks. 2. Each two consecutive bb ids in the path have a successor relationship in the CFG. 3. The path does not include a block with indirect branches, except possibly as the last block. Applying a path cloning involves cloning all blocks in the path (except the first one) and setting up their branches. Once all clonings are applied, the cluster information is used to guide block layout in the modified function.
2023-08-20[GlobalISel] introduce MIFlag::NoConvergentSameer Sahasrabuddhe1-0/+5
Some opcodes in MIR are defined to be convergent by the target by setting IsConvergent in the corresponding TD file. For example, in AMDGPU, the opcodes G_SI_CALL and G_INTRINSIC* are marked as convergent. But this is too conservative, since calls to functions that do not execute convergent operations should not be marked convergent. This information is available in LLVM IR. The new flag MIFlag::NoConvergent now allows the IR translator to mark an instruction as not performing any convergent operations. It is relevant only on occurrences of opcodes that are marked isConvergent in the target. Differential Revision: https://reviews.llvm.org/D157475
2023-07-27[CodeGen] Store call frame size in MachineBasicBlockJay Foad1-0/+19
Record the call frame size on entry to each basic block. This is usually zero except when a basic block has been split in the middle of a call sequence. This simplifies PEI::replaceFrameIndices which previously had to visit basic blocks in a specific order and had special handling for unreachable blocks. More importantly it paves the way for an equally simple implementation of a backwards version of replaceFrameIndices, which is required to fully convert PrologEpilogInserter to backwards register scavenging, which is preferred because it does not rely on accurate kill flags. Differential Revision: https://reviews.llvm.org/D156113
2023-07-13Revert "[CodeGen] Store SP adjustment in MachineBasicBlock. NFCI."Oliver Stannard1-19/+0
This reverts commit 58d1eaa3b6ce4f7285c51f83faff7a3ac374c746.
2023-07-12[CodeGen] Store SP adjustment in MachineBasicBlock. NFCI.Jay Foad1-0/+19
Record the SP adjustment on entry to each basic block. This is almost always zero except on targets like ARM which can split a basic block in the middle of a call sequence. This simplifies PEI::replaceFrameIndices which previously had to visit basic blocks in a specific order and had special handling for unreachable blocks. More importantly it paves the way for an equally simple implementation of a backwards version of replaceFrameIndices, which is required to fully convert PrologEpilogInserter to backwards register scavenging, which is preferred because it does not rely on accurate kill flags. Differential Revision: https://reviews.llvm.org/D154281
2023-06-26[MC] Add SMLoc to MCCFIInstructionFangrui Song1-1/+1
to help debug and report better diagnostics for functions like relaxDwarfCallFrameFragment (D153167). In MCStreamer, some emitCFI* functions already take a SMLoc argument. Add a SMLoc argument to the remaining functions that generate a MCCFIInstruction.
2023-06-01[SDAG] Preserve unpredictable metadata, teach X86CmovConversion to respect ↵Dávid Bolvanský1-1/+4
this metadata Sometimes an developer would like to have more control over cmov vs branch. We have unpredictable metadata in LLVM IR, but currently it is ignored by X86 backend. Propagate this metadata and avoid cmov->branch conversion in X86CmovConversion for cmov with this metadata. Example: ``` int MaxIndex(int n, int *a) { int t = 0; for (int i = 1; i < n; i++) { // cmov is converted to branch by X86CmovConversion if (a[i] > a[t]) t = i; } return t; } int MaxIndex2(int n, int *a) { int t = 0; for (int i = 1; i < n; i++) { // cmov is preserved if (__builtin_unpredictable(a[i] > a[t])) t = i; } return t; } ``` Reviewed By: nikic Differential Revision: https://reviews.llvm.org/D118118
2023-05-14[Coverity] Fix unchecked return value, NFCPhoebe Wang1-3/+5
2023-05-03Restore CodeGen/LowLevelType from `Support`NAKAMURA Takumi1-1/+1
This is rework of; - D30046 (LLT) Since I have introduced `llvm-min-tblgen` as D146352, `llvm-tblgen` may depend on `CodeGen`. `LowLevlType.h` originally belonged to `CodeGen`. Almost all userse are still under `CodeGen` or `Target`. I think `CodeGen` is the right place to put `LowLevelType.h`. `MachineValueType.h` may be moved as well. (later, D149024) I have made many modules depend on `CodeGen`. It is consistent but inefficient. It will be split out later, D148769 Besides, I had to isolate MVT and LLT in modmap, since `llvm::PredicateInfo` clashes between `TableGen/CodeGenSchedule.h` and `Transforms/Utils/PredicateInfo.h`. (I think better to introduce namespace llvm::TableGen) Depends on D145937, D146352, and D148768. Differential Revision: https://reviews.llvm.org/D148767
2023-02-19Use APInt::getSignificantBits instead of APInt::getMinSignedBits (NFC)Kazu Hirata1-2/+2
Note that getMinSignedBits has been soft-deprecated in favor of getSignificantBits.
2023-01-23[MC] Define and use MCInstrDesc implicit_uses and implicit_defs. NFC.Jay Foad1-8/+4
The new methods return a range for easier iteration. Use them everywhere instead of getImplicitUses, getNumImplicitUses, getImplicitDefs and getNumImplicitDefs. A future patch will remove the old methods. In some use cases the new methods are less efficient because they always have to scan the whole uses/defs array to count its length, but that will be fixed in a future patch by storing the number of implicit uses/defs explicitly in MCInstrDesc. At that point there will be no need to 0-terminate the arrays. Differential Revision: https://reviews.llvm.org/D142215
2023-01-20[APSInt] Fix bug in APSInt mentioned in ↵Peter Rong1-2/+5
https://github.com/llvm/llvm-project/issues/59515 Also provide a `tryExtValue()` API like APInt did in D139683 Reviewed By: RKSimon, efriedma Differential Revision: https://reviews.llvm.org/D140059
2023-01-17[Propeller] Use Fixed MBB ID instead of volatile MachineBasicBlock::Number.Rahman Lavaee1-0/+25
Let Propeller use specialized IDs for basic blocks, instead of MBB number. This allows optimizations not just prior to asm-printer, but throughout the entire codegen. This patch only implements the functionality under the new `LLVM_BB_ADDR_MAP` version, but the old version is still being used. A later patch will change the used version. ####Background Today Propeller uses machine basic block (MBB) numbers, which already exist, to map native assembly to machine IR. This is done as follows. - Basic block addresses are captured and dumped into the `LLVM_BB_ADDR_MAP` section just before the AsmPrinter pass which writes out object files. This ensures that we have a mapping that is close to assembly. - Profiling mapping works by taking a virtual address of an instruction and looking up the `LLVM_BB_ADDR_MAP` section to find the MBB number it corresponds to. - While this works well today, we need to do better when we scale Propeller to target other Machine IR optimizations like spill code optimization. Register allocation happens earlier in the Machine IR pipeline and we need an annotation mechanism that is valid at that point. - The current scheme will not work in this scenario because the MBB number of a particular basic block is not fixed and changes over the course of codegen (via renumbering, adding, and removing the basic blocks). - In other words, the volatile MBB numbers do not provide a one-to-one correspondence throughout the lifetime of Machine IR. Profile annotation using MBB numbers is restricted to a fixed point; only valid at the exact point where it was dumped. - Further, the object file can only be dumped before AsmPrinter and cannot be dumped at an arbitrary point in the Machine IR pass pipeline. Hence, MBB numbers are not suitable and we need something else. ####Solution We propose using fixed unique incremental MBB IDs for basic blocks instead of volatile MBB numbers. These IDs are assigned upon the creation of machine basic blocks. We modify `MachineFunction::CreateMachineBasicBlock` to assign the fixed ID to every newly created basic block. It assigns `MachineFunction::NextMBBID` to the MBB ID and then increments it, which ensures having unique IDs. To ensure correct profile attribution, multiple equivalent compilations must generate the same Propeller IDs. This is guaranteed as long as the MachineFunction passes run in the same order. Since the `NextBBID` variable is scoped to `MachineFunction`, interleaving of codegen for different functions won't cause any inconsistencies. The new encoding is generated under the new version number 2 and we keep backward-compatibility with older versions. ####Impact on Size of the `LLVM_BB_ADDR_MAP` Section Emitting the Propeller ID results in a 23% increase in the size of the `LLVM_BB_ADDR_MAP` section for the clang binary. Reviewed By: tmsriram Differential Revision: https://reviews.llvm.org/D100808
2023-01-13[CodeGen] Remove uses of Register::isPhysicalRegister/isVirtualRegister. NFCCraig Topper1-5/+5
Use isPhysical/isVirtual methods. Reviewed By: foad Differential Revision: https://reviews.llvm.org/D141715
2023-01-06[DebugInfo][NFC] Add new MachineOperand type and change DBG_INSTR_REF syntaxStephen Tozer1-0/+34
This patch makes two notable changes to the MIR debug info representation, which result in different MIR output but identical final DWARF output (NFC w.r.t. the full compilation). The two changes are: * The introduction of a new MachineOperand type, MO_DbgInstrRef, which consists of two unsigned numbers that are used to index an instruction and an output operand within that instruction, having a meaning identical to first two operands of the current DBG_INSTR_REF instruction. This operand is only used in DBG_INSTR_REF (see below). * A change in syntax for the DBG_INSTR_REF instruction, shuffling the operands to make it resemble DBG_VALUE_LIST instead of DBG_VALUE, and replacing the first two operands with a single MO_DbgInstrRef-type operand. This patch is the first of a set that will allow DBG_INSTR_REF instructions to refer to multiple machine locations in the same manner as DBG_VALUE_LIST. Reviewed By: jmorse Differential Revision: https://reviews.llvm.org/D129372
2023-01-05Fix typosLuke Drummond1-1/+1
I found one typo of "implemnt", then some more. s/implemnt/implement/g
2023-01-04[MC] Consistently use MCInstrDesc::getImplicitUses and getImplicitDefs. NFC.Jay Foad1-2/+2