Skip to content

[MC] Avoid repeated hash lookups (NFC) #123698

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions llvm/lib/MC/WasmObjectWriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -746,10 +746,11 @@ static void addData(SmallVectorImpl<char> &DataBytes,
uint32_t
WasmObjectWriter::getRelocationIndexValue(const WasmRelocationEntry &RelEntry) {
if (RelEntry.Type == wasm::R_WASM_TYPE_INDEX_LEB) {
if (!TypeIndices.count(RelEntry.Symbol))
auto It = TypeIndices.find(RelEntry.Symbol);
if (It == TypeIndices.end())
report_fatal_error("symbol not found in type index space: " +
RelEntry.Symbol->getName());
return TypeIndices[RelEntry.Symbol];
return It->second;
}

return RelEntry.Symbol->getIndex();
Expand Down
Loading