[llvm] [MachineInst] Increase LLVM_MI_FLAGS_BITS to 32 bits (PR #175542)
Mészáros Gergely via llvm-commits
llvm-commits at lists.llvm.org
Mon Jan 12 06:07:46 PST 2026
https://github.com/Maetveis created https://github.com/llvm/llvm-project/pull/175542
We have hit the limit of 24 bits for LLVM_MI_FLAGS_BITS in upstream. In our downstream target we are using additional bits, so we're hitting the "Flag is out of range" assertions in get/setFlag functions.
Increase LLVM_MI_FLAGS_BITS to 32 bits, and reorder the fields of MachineInstr to avoid extra padding and the subsequent increase in size.
>From 6bbe83e8f98ec306788956ad82faaf95f062a160 Mon Sep 17 00:00:00 2001
From: "Meszaros, Gergely" <gergely.meszaros at intel.com>
Date: Mon, 12 Jan 2026 13:43:08 +0000
Subject: [PATCH] [MachineInst] Increase LLVM_MI_FLAGS_BITS to 32 bits
We have hit the limit of 24 bits for LLVM_MI_FLAGS_BITS in upstream.
In our downstream target we are using additional bits, so we're hitting
the "Flag is out of range" assertions in get/setFlag functions.
Increase LLVM_MI_FLAGS_BITS to 32 bits, and reorder the fields of
MachineInstr to avoid extra padding and the subsequent increase in size.
---
llvm/include/llvm/CodeGen/MachineInstr.h | 20 ++++++++++----------
1 file changed, 10 insertions(+), 10 deletions(-)
diff --git a/llvm/include/llvm/CodeGen/MachineInstr.h b/llvm/include/llvm/CodeGen/MachineInstr.h
index b52205322819a..873cad4953541 100644
--- a/llvm/include/llvm/CodeGen/MachineInstr.h
+++ b/llvm/include/llvm/CodeGen/MachineInstr.h
@@ -136,7 +136,7 @@ class MachineInstr
MachineOperand *Operands = nullptr; // Pointer to the first operand.
#define LLVM_MI_NUMOPERANDS_BITS 24
-#define LLVM_MI_FLAGS_BITS 24
+#define LLVM_MI_FLAGS_BITS 32
#define LLVM_MI_ASMPRINTERFLAGS_BITS 8
/// Number of operands on instruction.
@@ -148,12 +148,19 @@ class MachineInstr
OperandCapacity CapOperands; // Capacity of the Operands array.
/// Various bits of additional information about the machine instruction.
- uint32_t Flags : LLVM_MI_FLAGS_BITS;
+ uint32_t Flags;
/// Various bits of information used by the AsmPrinter to emit helpful
/// comments. This is *not* semantic information. Do not use this for
/// anything other than to convey comment information to AsmPrinter.
- uint32_t AsmPrinterFlags : LLVM_MI_ASMPRINTERFLAGS_BITS;
+ uint8_t AsmPrinterFlags;
+
+ /// Cached opcode from MCID.
+ uint16_t Opcode;
+
+ /// Unique instruction number. Used by DBG_INSTR_REFs to refer to the values
+ /// defined by this instruction.
+ unsigned DebugInstrNum;
/// Internal implementation detail class that provides out-of-line storage for
/// extra info used by the machine instruction when this info cannot be stored
@@ -318,13 +325,6 @@ class MachineInstr
DebugLoc DbgLoc; // Source line information.
- /// Unique instruction number. Used by DBG_INSTR_REFs to refer to the values
- /// defined by this instruction.
- unsigned DebugInstrNum;
-
- /// Cached opcode from MCID.
- uint16_t Opcode;
-
// Intrusive list support
friend struct ilist_traits<MachineInstr>;
friend struct ilist_callback_traits<MachineBasicBlock>;
More information about the llvm-commits
mailing list