-
Notifications
You must be signed in to change notification settings - Fork 14.3k
LLVMContext: Cleanup registration of known bundle IDs #120359
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
LLVMContext: Cleanup registration of known bundle IDs #120359
Conversation
@llvm/pr-subscribers-llvm-ir Author: Matt Arsenault (arsenm) ChangesFull diff: https://github.com/llvm/llvm-project/pull/120359.diff 1 Files Affected:
diff --git a/llvm/lib/IR/LLVMContext.cpp b/llvm/lib/IR/LLVMContext.cpp
index eb51a751bfa088..0a90bcbf323e8b 100644
--- a/llvm/lib/IR/LLVMContext.cpp
+++ b/llvm/lib/IR/LLVMContext.cpp
@@ -31,6 +31,35 @@
using namespace llvm;
+static constexpr StringRef knownBundleName(unsigned BundleTagID) {
+ switch (BundleTagID) {
+ case LLVMContext::OB_deopt:
+ return "deopt";
+ case LLVMContext::OB_funclet:
+ return "funclet";
+ case LLVMContext::OB_gc_transition:
+ return "gc-transition";
+ case LLVMContext::OB_cfguardtarget:
+ return "cfguardtarget";
+ case LLVMContext::OB_preallocated:
+ return "preallocated";
+ case LLVMContext::OB_gc_live:
+ return "gc-live";
+ case LLVMContext::OB_clang_arc_attachedcall:
+ return "clang.arc.attachedcall";
+ case LLVMContext::OB_ptrauth:
+ return "ptrauth";
+ case LLVMContext::OB_kcfi:
+ return "kcfi";
+ case LLVMContext::OB_convergencectrl:
+ return "convergencectrl";
+ default:
+ return "";
+ }
+
+ llvm_unreachable("covered switch");
+}
+
LLVMContext::LLVMContext() : pImpl(new LLVMContextImpl(*this)) {
// Create the fixed metadata kinds. This is done in the same order as the
// MD_* enum values so that they correspond.
@@ -46,56 +75,12 @@ LLVMContext::LLVMContext() : pImpl(new LLVMContextImpl(*this)) {
(void)ID;
}
- auto *DeoptEntry = pImpl->getOrInsertBundleTag("deopt");
- assert(DeoptEntry->second == LLVMContext::OB_deopt &&
- "deopt operand bundle id drifted!");
- (void)DeoptEntry;
-
- auto *FuncletEntry = pImpl->getOrInsertBundleTag("funclet");
- assert(FuncletEntry->second == LLVMContext::OB_funclet &&
- "funclet operand bundle id drifted!");
- (void)FuncletEntry;
-
- auto *GCTransitionEntry = pImpl->getOrInsertBundleTag("gc-transition");
- assert(GCTransitionEntry->second == LLVMContext::OB_gc_transition &&
- "gc-transition operand bundle id drifted!");
- (void)GCTransitionEntry;
-
- auto *CFGuardTargetEntry = pImpl->getOrInsertBundleTag("cfguardtarget");
- assert(CFGuardTargetEntry->second == LLVMContext::OB_cfguardtarget &&
- "cfguardtarget operand bundle id drifted!");
- (void)CFGuardTargetEntry;
-
- auto *PreallocatedEntry = pImpl->getOrInsertBundleTag("preallocated");
- assert(PreallocatedEntry->second == LLVMContext::OB_preallocated &&
- "preallocated operand bundle id drifted!");
- (void)PreallocatedEntry;
-
- auto *GCLiveEntry = pImpl->getOrInsertBundleTag("gc-live");
- assert(GCLiveEntry->second == LLVMContext::OB_gc_live &&
- "gc-transition operand bundle id drifted!");
- (void)GCLiveEntry;
-
- auto *ClangAttachedCall =
- pImpl->getOrInsertBundleTag("clang.arc.attachedcall");
- assert(ClangAttachedCall->second == LLVMContext::OB_clang_arc_attachedcall &&
- "clang.arc.attachedcall operand bundle id drifted!");
- (void)ClangAttachedCall;
-
- auto *PtrauthEntry = pImpl->getOrInsertBundleTag("ptrauth");
- assert(PtrauthEntry->second == LLVMContext::OB_ptrauth &&
- "ptrauth operand bundle id drifted!");
- (void)PtrauthEntry;
-
- auto *KCFIEntry = pImpl->getOrInsertBundleTag("kcfi");
- assert(KCFIEntry->second == LLVMContext::OB_kcfi &&
- "kcfi operand bundle id drifted!");
- (void)KCFIEntry;
-
- auto *ConvergenceCtrlEntry = pImpl->getOrInsertBundleTag("convergencectrl");
- assert(ConvergenceCtrlEntry->second == LLVMContext::OB_convergencectrl &&
- "convergencectrl operand bundle id drifted!");
- (void)ConvergenceCtrlEntry;
+ for (unsigned BundleTagID = LLVMContext::OB_deopt;
+ BundleTagID <= LLVMContext::OB_convergencectrl; ++BundleTagID) {
+ [[maybe_unused]] const auto *Entry =
+ pImpl->getOrInsertBundleTag(knownBundleName(BundleTagID));
+ assert(Entry->second == BundleTagID && "operand bundle id drifted!");
+ }
SyncScope::ID SingleThreadSSID =
pImpl->getOrInsertSyncScopeID("singlethread");
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
llvm/lib/IR/LLVMContext.cpp
Outdated
case LLVMContext::OB_convergencectrl: | ||
return "convergencectrl"; | ||
default: | ||
return ""; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor nit: can this be llvm_unreachable
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, as it is now. I was debating surfacing this to a public query for the name but I don't know if it would be of any use
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/140/builds/13302 Here is the relevant piece of the build log for the reference
|
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/116/builds/7898 Here is the relevant piece of the build log for the reference
|
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/59/builds/10006 Here is the relevant piece of the build log for the reference
|
No description provided.