[llvm] [IR] Remove HasMetadata bit from instructions (PR #190651)

Nikita Popov via llvm-commits llvm-commits at lists.llvm.org
Mon Apr 6 12:07:33 PDT 2026


https://github.com/nikic created https://github.com/llvm/llvm-project/pull/190651

We were reserving one bit for a HasMetadata flag. However, this flag has long since been moved into Value itself, prior to being removed from there as well recently.

>From 7670d67e12f8043412c8eb829afb3a7b71e2f6ba Mon Sep 17 00:00:00 2001
From: Nikita Popov <nikita.ppv at gmail.com>
Date: Mon, 6 Apr 2026 21:02:32 +0200
Subject: [PATCH] [IR] Remove HasMetadata bit from instructions

We were reserving one bit for a HasMetadata flag. However, this
flag has long since been moved into Value itself, prior to being
removed from there as well recently.
---
 llvm/include/llvm/IR/Instruction.h | 19 +++----------------
 1 file changed, 3 insertions(+), 16 deletions(-)

diff --git a/llvm/include/llvm/IR/Instruction.h b/llvm/include/llvm/IR/Instruction.h
index be35f645009f5..0b57ad4d0a379 100644
--- a/llvm/include/llvm/IR/Instruction.h
+++ b/llvm/include/llvm/IR/Instruction.h
@@ -168,9 +168,9 @@ class Instruction : public User,
   LLVM_ABI void handleMarkerRemoval();
 
 protected:
-  // The 15 first bits of `Value::SubclassData` are available for subclasses of
+  // All 16 bits of `Value::SubclassData` are available for subclasses of
   // `Instruction` to use.
-  using OpaqueField = Bitfield::Element<uint16_t, 0, 15>;
+  using OpaqueField = Bitfield::Element<uint16_t, 0, 16>;
 
   // Template alias so that all Instruction storing alignment use the same
   // definiton.
@@ -190,11 +190,6 @@ class Instruction : public User,
       typename Bitfield::Element<AtomicOrdering, Offset, 3,
                                  AtomicOrdering::LAST>;
 
-private:
-  // The last bit is used to store whether the instruction has metadata attached
-  // or not.
-  using HasMetadataField = Bitfield::Element<bool, 15, 1>;
-
 protected:
   LLVM_ABI ~Instruction(); // Use deleteValue() to delete a generic Instruction.
 
@@ -1097,24 +1092,16 @@ class Instruction : public User,
   }
 
 protected:
-  // Instruction subclasses can stick up to 15 bits of stuff into the
+  // Instruction subclasses can stick up to 16 bits of stuff into the
   // SubclassData field of instruction with these members.
 
   template <typename BitfieldElement>
   typename BitfieldElement::Type getSubclassData() const {
-    static_assert(
-        std::is_same<BitfieldElement, HasMetadataField>::value ||
-            !Bitfield::isOverlapping<BitfieldElement, HasMetadataField>(),
-        "Must not overlap with the metadata bit");
     return Bitfield::get<BitfieldElement>(getSubclassDataFromValue());
   }
 
   template <typename BitfieldElement>
   void setSubclassData(typename BitfieldElement::Type Value) {
-    static_assert(
-        std::is_same<BitfieldElement, HasMetadataField>::value ||
-            !Bitfield::isOverlapping<BitfieldElement, HasMetadataField>(),
-        "Must not overlap with the metadata bit");
     auto Storage = getSubclassDataFromValue();
     Bitfield::set<BitfieldElement>(Storage, Value);
     setValueSubclassData(Storage);



More information about the llvm-commits mailing list