Files
Giacomo Vercesi de75d94597 {Pipe,Analysis}Run: release Python GIL
Move out of the `runPipe`/`runAnalysis` functions the logic that
extracts the container from the vector type. This logic is now
delegated to `containerVectorToTuple` which converts the vector type to
a tuple of references. This allows python's `run{Pipe,Analysis}` to
safely call `nanobind::gil_scoped_release` which releases the GIL for
the entire duration of the `runPipe`/`runAnalysis` execution.
2025-11-26 14:59:43 +01:00

40 lines
1.2 KiB
C++

#pragma once
//
// This file is distributed under the MIT License. See LICENSE.md for details.
//
#include <utility>
#include "llvm/Support/Error.h"
#include "revng/PipeboxCommon/Common.h"
#include "revng/PipeboxCommon/Concepts.h"
#include "revng/PipeboxCommon/Helpers/Helpers.h"
#include "revng/PipeboxCommon/Model.h"
namespace revng::pypeline::helpers {
/// Helper function that allows running an analysis, deals with unpacking the
/// container list to multiple parameters that will be passed to the run
/// function to of the Analysis.
template<IsAnalysis T, typename... Args>
inline llvm::Error runAnalysis(T &Analysis,
Model &TheModel,
const Request &Incoming,
llvm::StringRef Configuration,
std::tuple<Args...> &Containers) {
using Traits = AnalysisRunTraits<T>;
revng_assert(Incoming.size() == Traits::ContainerCount);
using CT = Traits::ContainerTypes;
return compile_time::callWithIndexSequence<CT>([&]<size_t... I>() {
return Analysis.run(TheModel,
Incoming,
Configuration,
std::get<I>(Containers)...);
});
}
} // namespace revng::pypeline::helpers