[lld] [lld][WebAssembly] Allow `--trace-symbol` to work with symbols with custom import names (PR #96119)

Sam Clegg via llvm-commits llvm-commits at lists.llvm.org
Thu Jun 20 10:01:58 PDT 2024


================
@@ -828,9 +842,20 @@ bool SymbolTable::getFunctionVariant(Symbol* sym, const WasmSignature *sig,
 // Set a flag for --trace-symbol so that we can print out a log message
 // if a new symbol with the same name is inserted into the symbol table.
 void SymbolTable::trace(StringRef name) {
+  tracingEnabled = true;
   symMap.insert({CachedHashStringRef(name), -1});
 }
 
+bool SymbolTable::isTraced(StringRef name) {
+  // Early exit in the default case to avoid symbol hashmap lookup.
+  if (!tracingEnabled)
+    return false;
+  auto it = symMap.find(CachedHashStringRef(name));
+  if (it == symMap.end())
+    return false;
+  return it->second == -1 || symVector[it->second]->traced;
----------------
sbc100 wrote:

`-1` is what `--trace-symbol` flags inserts into this map before any symbols actually exist:

https://github.com/llvm/llvm-project/blob/0ec567c370df86893a22bf59d2716f6e553ca63b/lld/wasm/SymbolTable.cpp#L828-L832

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


More information about the llvm-commits mailing list