diff options
author | Jon Roelofs <jonathan_roelofs@apple.com> | 2023-06-26 10:31:57 -0700 |
---|---|---|
committer | Jon Roelofs <jonathan_roelofs@apple.com> | 2023-06-28 10:32:40 -0700 |
commit | 703c08362adcc7990fa5ddc444c41c5efdccbc2b (patch) | |
tree | d90f8805b5207b3f79d6e6231c01e0ec7dc053cd /llvm/lib/CodeGen/MachineInstr.cpp | |
parent | d7d4aa539c0d2f80c080a3b1e0fa45a78d5e9bfc (diff) | |
download | llvm-703c08362adcc7990fa5ddc444c41c5efdccbc2b.zip llvm-703c08362adcc7990fa5ddc444c41c5efdccbc2b.tar.gz llvm-703c08362adcc7990fa5ddc444c41c5efdccbc2b.tar.bz2 |
[MachineInst] Bump NumOperands back up to 24bits
In https://reviews.llvm.org/D149445, it was lowered from 32 to 16bits, which
broke an internal project of ours. The relevant code being compiled is a fairly
large nested switch that results in a PHI node with 65k+ operands, which can't
easily be turned into a table for perf reasons.
This change unifies `NumOperands`, `Flags`, and `AsmPrinterFlags` into a packed
7-byte struct, which `CapOperands` can follow as the 8th byte, rounding it up
to a nice alignment before the `Info` field.
rdar://111217742&109362033
Differential revision: https://reviews.llvm.org/D153791
Diffstat (limited to 'llvm/lib/CodeGen/MachineInstr.cpp')
-rw-r--r-- | llvm/lib/CodeGen/MachineInstr.cpp | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/llvm/lib/CodeGen/MachineInstr.cpp b/llvm/lib/CodeGen/MachineInstr.cpp index 400e76f..a930948 100644 --- a/llvm/lib/CodeGen/MachineInstr.cpp +++ b/llvm/lib/CodeGen/MachineInstr.cpp @@ -96,7 +96,8 @@ void MachineInstr::addImplicitDefUseOperands(MachineFunction &MF) { /// the MCInstrDesc. MachineInstr::MachineInstr(MachineFunction &MF, const MCInstrDesc &TID, DebugLoc DL, bool NoImp) - : MCID(&TID), DbgLoc(std::move(DL)), DebugInstrNum(0) { + : MCID(&TID), NumOperands(0), Flags(0), AsmPrinterFlags(0), + DbgLoc(std::move(DL)), DebugInstrNum(0) { assert(DbgLoc.hasTrivialDestructor() && "Expected trivial destructor"); // Reserve space for the expected number of operands. @@ -114,8 +115,8 @@ MachineInstr::MachineInstr(MachineFunction &MF, const MCInstrDesc &TID, /// Does not copy the number from debug instruction numbering, to preserve /// uniqueness. MachineInstr::MachineInstr(MachineFunction &MF, const MachineInstr &MI) - : MCID(&MI.getDesc()), Info(MI.Info), DbgLoc(MI.getDebugLoc()), - DebugInstrNum(0) { + : MCID(&MI.getDesc()), NumOperands(0), Flags(0), AsmPrinterFlags(0), + Info(MI.Info), DbgLoc(MI.getDebugLoc()), DebugInstrNum(0) { assert(DbgLoc.hasTrivialDestructor() && "Expected trivial destructor"); CapOperands = OperandCapacity::get(MI.getNumOperands()); @@ -192,7 +193,8 @@ static void moveOperands(MachineOperand *Dst, MachineOperand *Src, /// an explicit operand it is added at the end of the explicit operand list /// (before the first implicit operand). void MachineInstr::addOperand(MachineFunction &MF, const MachineOperand &Op) { - assert(NumOperands < USHRT_MAX && "Cannot add more operands."); + assert(isUInt<LLVM_MI_NUMOPERANDS_BITS>(NumOperands + 1) && + "Cannot add more operands."); assert(MCID && "Cannot add operands before providing an instr descriptor"); // Check if we're adding one of our existing operands. |