[llvm] [MC] Eliminate two symbol-related hash maps (PR #95464)
Fangrui Song via llvm-commits
llvm-commits at lists.llvm.org
Thu Jun 13 18:03:27 PDT 2024
================
@@ -0,0 +1,45 @@
+//===-- llvm/MC/MCSymbolTableEntry.h - Symbol table entry -------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_MC_MCSYMBOLTABLEENTRY_H
+#define LLVM_MC_MCSYMBOLTABLEENTRY_H
+
+#include "llvm/ADT/StringMapEntry.h"
+
+namespace llvm {
+
+class MCSymbol;
+
+/// The value for an entry in the symbol table of an MCContext.
+///
+/// This is in a separate file, because MCSymbol uses MCSymbolTableEntry (see
+/// below) to reuse the name that is stored in the symbol table.
+struct MCSymbolTableValue {
+ /// The symbol associated with the name, if any.
+ MCSymbol *Symbol = nullptr;
+
+ /// The next ID to dole out to an unnamed assembler temporary symbol with
+ /// the prefix (symbol table key).
+ unsigned NextUniqueID = 0;
+
+ /// Whether the name associated with this value is used for a symbol. This is
+ /// not necessarily true: sometimes, we use a symbol table value without an
+ /// associated symbol for accessing NextUniqueID when a suffix is added to a
+ /// name. However, Used might be true even if Symbol is nullptr: temporary
+ /// named symbols are not added to the symbol table.
+ bool Used = false;
+};
+
+/// MCContext stores MCSymbolTableValue in a string map. To avoid redundant
----------------
MaskRay wrote:
Should the comment be moved to MCSymbol.h? Or leave here just a comment like "See MCSymbol::operator new".
https://github.com/llvm/llvm-project/pull/95464
More information about the llvm-commits
mailing list