[llvm] [BOLT] Use direct storage for Label annotations. NFCI. (PR #70147)

Job Noorman via llvm-commits llvm-commits at lists.llvm.org
Wed Oct 25 00:33:47 PDT 2023


================
@@ -269,15 +269,17 @@ bool MCPlusBuilder::clearOffset(MCInst &Inst) {
 }
 
 std::optional<MCSymbol *> MCPlusBuilder::getLabel(const MCInst &Inst) const {
-  if (auto Label = tryGetAnnotationAs<MCSymbol *>(Inst, MCAnnotation::kLabel))
-    return *Label;
-  return std::nullopt;
+  std::optional<int64_t> Label =
+      getAnnotationOpValue(Inst, MCAnnotation::kLabel);
+  if (!Label)
+    return std::nullopt;
+
+  return reinterpret_cast<MCSymbol *>(*Label);
 }
 
-bool MCPlusBuilder::setLabel(MCInst &Inst, MCSymbol *Label,
-                             AllocatorIdTy AllocatorId) {
-  getOrCreateAnnotationAs<MCSymbol *>(Inst, MCAnnotation::kLabel, AllocatorId) =
-      Label;
+bool MCPlusBuilder::setLabel(MCInst &Inst, MCSymbol *Label) {
----------------
mtvec wrote:

Why was `AllocatorId` removed? Don't we still need to pass it to `setAnnotationOpValue`?

https://github.com/llvm/llvm-project/pull/70147


More information about the llvm-commits mailing list