Skip to content

[Exegesis] Do not assume the size and layout of the assembled snippet #79636

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 2 commits into from
Jan 26, 2024
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
19 changes: 14 additions & 5 deletions llvm/tools/llvm-exegesis/lib/Assembler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -365,11 +365,20 @@ Expected<ExecutableFunction> ExecutableFunction::create(

auto SymbolSizes = object::computeSymbolSizes(*ObjectFileHolder.getBinary());
// Get the size of the function that we want to call into (with the name of
// FunctionID). This should always be the third symbol returned by
// calculateSymbolSizes.
assert(SymbolSizes.size() == 3);
assert(cantFail(std::get<0>(SymbolSizes[2]).getName()) == FunctionID);
uintptr_t CodeSize = std::get<1>(SymbolSizes[2]);
// FunctionID).
auto SymbolIt = llvm::find_if(SymbolSizes, [&](const auto &Pair) {
auto SymbolName = Pair.first.getName();
if (SymbolName)
return *SymbolName == FunctionID;
// We should always succeed in finding the FunctionID, hence we suppress
// the error here and assert later on the search result, rather than
// propagating the Expected<> error back to the caller.
llvm::consumeError(SymbolName.takeError());
return false;
});
assert(SymbolIt != SymbolSizes.end() &&
"Cannot find the symbol for FunctionID");
uintptr_t CodeSize = SymbolIt->second;

auto EJITOrErr = orc::LLJITBuilder().create();
if (!EJITOrErr)
Expand Down