aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Target
diff options
context:
space:
mode:
authoraengelke <engelke@in.tum.de>2024-06-20 11:36:11 +0200
committerGitHub <noreply@github.com>2024-06-20 11:36:11 +0200
commitc1a7c5ac73af92316426deed5f8f10f33f729ad2 (patch)
tree267c89e4ae2b34b97035a1fd6a7ec8f44ec7eec8 /llvm/lib/Target
parent919c547130cfd1cd75ccf148cbf2334b27b2f37f (diff)
downloadllvm-c1a7c5ac73af92316426deed5f8f10f33f729ad2.zip
llvm-c1a7c5ac73af92316426deed5f8f10f33f729ad2.tar.gz
llvm-c1a7c5ac73af92316426deed5f8f10f33f729ad2.tar.bz2
[MC] Eliminate two symbol-related hash maps (#95464)
Previously, a symbol insertion requires (at least) three hash table operations: - Lookup/create entry in Symbols (main symbol table) - Lookup NextUniqueID to deduplicate identical temporary labels - Add entry to UsedNames, which is also used to serve as storage for the symbol name in the MCSymbol. All three lookups are done with the same name, so combining these into a single table reduces the number of lookups to one. Thus, a pointer to a symbol table entry can be passed to createSymbol to avoid a duplicate lookup of the same name. The new symbol table entry value is placed in a separate header to avoid including MCContext in MCSymbol or vice versa.
Diffstat (limited to 'llvm/lib/Target')
-rw-r--r--llvm/lib/Target/WebAssembly/WebAssemblyAsmPrinter.cpp4
1 files changed, 2 insertions, 2 deletions
diff --git a/llvm/lib/Target/WebAssembly/WebAssemblyAsmPrinter.cpp b/llvm/lib/Target/WebAssembly/WebAssemblyAsmPrinter.cpp
index 0b7ec6e..b0a97c7 100644
--- a/llvm/lib/Target/WebAssembly/WebAssemblyAsmPrinter.cpp
+++ b/llvm/lib/Target/WebAssembly/WebAssemblyAsmPrinter.cpp
@@ -319,8 +319,8 @@ void WebAssemblyAsmPrinter::emitDecls(const Module &M) {
// Emit .globaltype, .tagtype, or .tabletype declarations for extern
// declarations, i.e. those that have only been declared (but not defined)
// in the current module
- auto Sym = cast<MCSymbolWasm>(It.getValue());
- if (!Sym->isDefined())
+ auto Sym = cast_or_null<MCSymbolWasm>(It.getValue().Symbol);
+ if (Sym && !Sym->isDefined())
emitSymbolType(Sym);
}