[PATCH] D142188: [ORC] Fix in-process lookup of symbols without GlobalPrefix
Lang Hames via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Jan 23 10:31:51 PST 2023
lhames added a comment.
This change won't work for other platforms at the moment. E.g. On Darwin where the global prefix is `_` an ORC lookup (which uses mangled names) for `[ "foo", "_foo" ]` should return `[ nullptr, <addr of _foo> ]`, but with this patch it will return `[ <addr of foo>, <addr of foo> ]`.
`GlobalPrefix` was always a bit of a hack -- I think we want to make this a generalized demangle function that returns a `std::optional<std::string>`, then we can write:
for (auto &KV : Symbols) {
auto &Name = KV.first;
if ((*Name).empty())
continue;
if (Allow && !Allow(Name))
continue;
auto DemangledName = Demangle(Name);
if (!DemangledName)
continue;
if (void *Addr = Dylib.getAddressOfSymbol(DemangledName->c_str())) {
NewSymbols[Name] = JITEvaluatedSymbol(
static_cast<JITTargetAddress>(reinterpret_cast<uintptr_t>(Addr)),
JITSymbolFlags::Exported);
}
}
On windows the demangler can conditionally drop the `?`, and on Darwin it can require the `_` prefix (returning std::noneopt` when it's not present.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D142188/new/
https://reviews.llvm.org/D142188
More information about the llvm-commits
mailing list