Skip to content

Conversation

@fhahn
Copy link
Contributor

@fhahn fhahn commented Sep 11, 2025

Assume operand bundles are emitted in a few more places now, including used in various places in libc++. Add a dedicated ID for them.

@llvmbot
Copy link
Member

llvmbot commented Sep 11, 2025

@llvm/pr-subscribers-llvm-transforms

Author: Florian Hahn (fhahn)

Changes

Assume operand bundles are emitted in a few more places now, including used in various places in libc++. Add a dedicated ID for them.


Full diff: https://github.com/llvm/llvm-project/pull/158078.diff

3 Files Affected:

  • (modified) llvm/include/llvm/IR/LLVMContext.h (+2)
  • (modified) llvm/lib/IR/LLVMContext.cpp (+3-1)
  • (modified) llvm/lib/Transforms/Scalar/AlignmentFromAssumptions.cpp (+1-1)
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();

@llvmbot
Copy link
Member

llvmbot commented Sep 11, 2025

@llvm/pr-subscribers-llvm-ir

Author: Florian Hahn (fhahn)

Changes

Assume operand bundles are emitted in a few more places now, including used in various places in libc++. Add a dedicated ID for them.


Full diff: https://github.com/llvm/llvm-project/pull/158078.diff

3 Files Affected:

  • (modified) llvm/include/llvm/IR/LLVMContext.h (+2)
  • (modified) llvm/lib/IR/LLVMContext.cpp (+3-1)
  • (modified) llvm/lib/Transforms/Scalar/AlignmentFromAssumptions.cpp (+1-1)
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();

Copy link
Contributor

@arsenm arsenm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is a bitcode compatibility test needed for this?

Copy link
Contributor

@nikic nikic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM with test/Bitcode/operand-bundles-bc-analyzer.ll updated.

Assume operand bundles are emitted in a few more places now, including
used in various places in libc++. Add a dedicated ID for them.
@fhahn fhahn enabled auto-merge (squash) September 24, 2025 15:23
@fhahn
Copy link
Contributor Author

fhahn commented Sep 24, 2025

Is a bitcode compatibility test needed for this?

I don't think this changes the bitcode format

@fhahn fhahn merged commit 4d4cb75 into llvm:main Sep 24, 2025
9 checks passed
llvm-sync bot pushed a commit to arm/arm-toolchain that referenced this pull request Sep 24, 2025
Assume operand bundles are emitted in a few more places now, including
used in various places in libc++. Add a dedicated ID for them.

PR: llvm/llvm-project#158078
mahesh-attarde pushed a commit to mahesh-attarde/llvm-project that referenced this pull request Oct 3, 2025
Assume operand bundles are emitted in a few more places now, including
used in various places in libc++. Add a dedicated ID for them.

PR: llvm#158078
@fhahn fhahn deleted the align-bundle-id branch October 11, 2025 09:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants