31
31
32
32
using namespace llvm ;
33
33
34
+ static constexpr StringRef knownBundleName (unsigned BundleTagID) {
35
+ switch (BundleTagID) {
36
+ case LLVMContext::OB_deopt:
37
+ return " deopt" ;
38
+ case LLVMContext::OB_funclet:
39
+ return " funclet" ;
40
+ case LLVMContext::OB_gc_transition:
41
+ return " gc-transition" ;
42
+ case LLVMContext::OB_cfguardtarget:
43
+ return " cfguardtarget" ;
44
+ case LLVMContext::OB_preallocated:
45
+ return " preallocated" ;
46
+ case LLVMContext::OB_gc_live:
47
+ return " gc-live" ;
48
+ case LLVMContext::OB_clang_arc_attachedcall:
49
+ return " clang.arc.attachedcall" ;
50
+ case LLVMContext::OB_ptrauth:
51
+ return " ptrauth" ;
52
+ case LLVMContext::OB_kcfi:
53
+ return " kcfi" ;
54
+ case LLVMContext::OB_convergencectrl:
55
+ return " convergencectrl" ;
56
+ default :
57
+ llvm_unreachable (" unknown bundle id" );
58
+ }
59
+
60
+ llvm_unreachable (" covered switch" );
61
+ }
62
+
34
63
LLVMContext::LLVMContext () : pImpl(new LLVMContextImpl(*this )) {
35
64
// Create the fixed metadata kinds. This is done in the same order as the
36
65
// MD_* enum values so that they correspond.
@@ -46,56 +75,12 @@ LLVMContext::LLVMContext() : pImpl(new LLVMContextImpl(*this)) {
46
75
(void )ID;
47
76
}
48
77
49
- auto *DeoptEntry = pImpl->getOrInsertBundleTag (" deopt" );
50
- assert (DeoptEntry->second == LLVMContext::OB_deopt &&
51
- " deopt operand bundle id drifted!" );
52
- (void )DeoptEntry;
53
-
54
- auto *FuncletEntry = pImpl->getOrInsertBundleTag (" funclet" );
55
- assert (FuncletEntry->second == LLVMContext::OB_funclet &&
56
- " funclet operand bundle id drifted!" );
57
- (void )FuncletEntry;
58
-
59
- auto *GCTransitionEntry = pImpl->getOrInsertBundleTag (" gc-transition" );
60
- assert (GCTransitionEntry->second == LLVMContext::OB_gc_transition &&
61
- " gc-transition operand bundle id drifted!" );
62
- (void )GCTransitionEntry;
63
-
64
- auto *CFGuardTargetEntry = pImpl->getOrInsertBundleTag (" cfguardtarget" );
65
- assert (CFGuardTargetEntry->second == LLVMContext::OB_cfguardtarget &&
66
- " cfguardtarget operand bundle id drifted!" );
67
- (void )CFGuardTargetEntry;
68
-
69
- auto *PreallocatedEntry = pImpl->getOrInsertBundleTag (" preallocated" );
70
- assert (PreallocatedEntry->second == LLVMContext::OB_preallocated &&
71
- " preallocated operand bundle id drifted!" );
72
- (void )PreallocatedEntry;
73
-
74
- auto *GCLiveEntry = pImpl->getOrInsertBundleTag (" gc-live" );
75
- assert (GCLiveEntry->second == LLVMContext::OB_gc_live &&
76
- " gc-transition operand bundle id drifted!" );
77
- (void )GCLiveEntry;
78
-
79
- auto *ClangAttachedCall =
80
- pImpl->getOrInsertBundleTag (" clang.arc.attachedcall" );
81
- assert (ClangAttachedCall->second == LLVMContext::OB_clang_arc_attachedcall &&
82
- " clang.arc.attachedcall operand bundle id drifted!" );
83
- (void )ClangAttachedCall;
84
-
85
- auto *PtrauthEntry = pImpl->getOrInsertBundleTag (" ptrauth" );
86
- assert (PtrauthEntry->second == LLVMContext::OB_ptrauth &&
87
- " ptrauth operand bundle id drifted!" );
88
- (void )PtrauthEntry;
89
-
90
- auto *KCFIEntry = pImpl->getOrInsertBundleTag (" kcfi" );
91
- assert (KCFIEntry->second == LLVMContext::OB_kcfi &&
92
- " kcfi operand bundle id drifted!" );
93
- (void )KCFIEntry;
94
-
95
- auto *ConvergenceCtrlEntry = pImpl->getOrInsertBundleTag (" convergencectrl" );
96
- assert (ConvergenceCtrlEntry->second == LLVMContext::OB_convergencectrl &&
97
- " convergencectrl operand bundle id drifted!" );
98
- (void )ConvergenceCtrlEntry;
78
+ for (unsigned BundleTagID = LLVMContext::OB_deopt;
79
+ BundleTagID <= LLVMContext::OB_convergencectrl; ++BundleTagID) {
80
+ [[maybe_unused]] const auto *Entry =
81
+ pImpl->getOrInsertBundleTag (knownBundleName (BundleTagID));
82
+ assert (Entry->second == BundleTagID && " operand bundle id drifted!" );
83
+ }
99
84
100
85
SyncScope::ID SingleThreadSSID =
101
86
pImpl->getOrInsertSyncScopeID (" singlethread" );
0 commit comments