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

via llvm-commits llvm-commits at lists.llvm.org
Wed Oct 25 01:04:31 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) {
----------------
maksfb wrote:

Yes, you are absolutely right. I have a diff that refactors annotations in a way that `AllocatorId` will not be needed for `setLabel()`, but until then you might need `AllocatorId` depending on the use case.

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


More information about the llvm-commits mailing list