[llvm] [LLVMContext] Add OB_align assume bundle op ID. (PR #158078)

Florian Hahn via llvm-commits llvm-commits at lists.llvm.org
Wed Sep 24 08:16:47 PDT 2025


https://github.com/fhahn updated https://github.com/llvm/llvm-project/pull/158078

>From 3fe2bc61e49632ebda2a8b949bfa219111ad8a60 Mon Sep 17 00:00:00 2001
From: Florian Hahn <flo at fhahn.com>
Date: Thu, 11 Sep 2025 14:43:13 +0100
Subject: [PATCH 1/2] [LLVMContext] Add OB_align assume bundle op ID.

Assume operand bundles are emitted in a few more places now, including
used in various places in libc++. Add a dedicated ID for them.
---
 llvm/include/llvm/IR/LLVMContext.h                      | 2 ++
 llvm/lib/IR/LLVMContext.cpp                             | 4 +++-
 llvm/lib/Transforms/Scalar/AlignmentFromAssumptions.cpp | 2 +-
 3 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/llvm/include/llvm/IR/LLVMContext.h b/llvm/include/llvm/IR/LLVMContext.h
index 852a3a4e2f638..5972dcb637dfa 100644
--- a/llvm/include/llvm/IR/LLVMContext.h
+++ b/llvm/include/llvm/IR/LLVMContext.h
@@ -97,6 +97,8 @@ class LLVMContext {
     OB_ptrauth = 7,                // "ptrauth"
     OB_kcfi = 8,                   // "kcfi"
     OB_convergencectrl = 9,        // "convergencectrl"
+    OB_align = 10,                 // "align"
+    OB_LastBundleID = OB_align     // Marker for last bundle ID
   };
 
   /// getMDKindID - Return a unique non-zero ID for the specified metadata kind.
diff --git a/llvm/lib/IR/LLVMContext.cpp b/llvm/lib/IR/LLVMContext.cpp
index 57532cd491dd6..335c210c10e1a 100644
--- a/llvm/lib/IR/LLVMContext.cpp
+++ b/llvm/lib/IR/LLVMContext.cpp
@@ -53,6 +53,8 @@ static StringRef knownBundleName(unsigned BundleTagID) {
     return "kcfi";
   case LLVMContext::OB_convergencectrl:
     return "convergencectrl";
+  case LLVMContext::OB_align:
+    return "align";
   default:
     llvm_unreachable("unknown bundle id");
   }
@@ -76,7 +78,7 @@ LLVMContext::LLVMContext() : pImpl(new LLVMContextImpl(*this)) {
   }
 
   for (unsigned BundleTagID = LLVMContext::OB_deopt;
-       BundleTagID <= LLVMContext::OB_convergencectrl; ++BundleTagID) {
+       BundleTagID <= LLVMContext::OB_LastBundleID; ++BundleTagID) {
     [[maybe_unused]] const auto *Entry =
         pImpl->getOrInsertBundleTag(knownBundleName(BundleTagID));
     assert(Entry->second == BundleTagID && "operand bundle id drifted!");
diff --git a/llvm/lib/Transforms/Scalar/AlignmentFromAssumptions.cpp b/llvm/lib/Transforms/Scalar/AlignmentFromAssumptions.cpp
index 8555ef5c22f82..e54a2e54f9943 100644
--- a/llvm/lib/Transforms/Scalar/AlignmentFromAssumptions.cpp
+++ b/llvm/lib/Transforms/Scalar/AlignmentFromAssumptions.cpp
@@ -163,7 +163,7 @@ bool AlignmentFromAssumptionsPass::extractAlignmentInfo(CallInst *I,
                                                         const SCEV *&OffSCEV) {
   Type *Int64Ty = Type::getInt64Ty(I->getContext());
   OperandBundleUse AlignOB = I->getOperandBundleAt(Idx);
-  if (AlignOB.getTagName() != "align")
+  if (AlignOB.getTagID() != LLVMContext::OB_align)
     return false;
   assert(AlignOB.Inputs.size() >= 2);
   AAPtr = AlignOB.Inputs[0].get();

>From 54cd488f5d040da2d5aad1124fe13480e16548e1 Mon Sep 17 00:00:00 2001
From: Florian Hahn <flo at fhahn.com>
Date: Wed, 24 Sep 2025 16:13:50 +0100
Subject: [PATCH 2/2] !fixup update operand-bundles-bc-analyzer.ll

---
 llvm/test/Bitcode/operand-bundles-bc-analyzer.ll | 1 +
 1 file changed, 1 insertion(+)

diff --git a/llvm/test/Bitcode/operand-bundles-bc-analyzer.ll b/llvm/test/Bitcode/operand-bundles-bc-analyzer.ll
index d860104b9cb3d..5628e17b4936e 100644
--- a/llvm/test/Bitcode/operand-bundles-bc-analyzer.ll
+++ b/llvm/test/Bitcode/operand-bundles-bc-analyzer.ll
@@ -13,6 +13,7 @@
 ; CHECK-NEXT:    <OPERAND_BUNDLE_TAG
 ; CHECK-NEXT:    <OPERAND_BUNDLE_TAG
 ; CHECK-NEXT:    <OPERAND_BUNDLE_TAG
+; CHECK-NEXT:    <OPERAND_BUNDLE_TAG
 ; CHECK-NEXT:  </OPERAND_BUNDLE_TAGS_BLOCK
 
 ; CHECK:   <FUNCTION_BLOCK



More information about the llvm-commits mailing list