forked from OSchip/llvm-project
Remove misused RAII gil_scoped_release/gil_scoped_acquire: without name they don't have any effect
I'm not sure what is the right fix here, but adding a name to all these lead to many segfaults. Reviewed By: stellaraccident Differential Revision: https://reviews.llvm.org/D116506
This commit is contained in:
parent
29120a5130
commit
a5a24c9370
|
@ -868,7 +868,6 @@ void PyOperationBase::print(py::object fileObject, bool binary,
|
|||
mlirOpPrintingFlagsPrintGenericOpForm(flags);
|
||||
|
||||
PyFileAccumulator accum(fileObject, binary);
|
||||
py::gil_scoped_release();
|
||||
mlirOperationPrintWithFlags(operation, flags, accum.getCallback(),
|
||||
accum.getUserData());
|
||||
mlirOpPrintingFlagsDestroy(flags);
|
||||
|
|
|
@ -35,7 +35,6 @@ PyGlobals::PyGlobals() {
|
|||
PyGlobals::~PyGlobals() { instance = nullptr; }
|
||||
|
||||
void PyGlobals::loadDialectModule(llvm::StringRef dialectNamespace) {
|
||||
py::gil_scoped_acquire();
|
||||
if (loadedDialectModulesCache.contains(dialectNamespace))
|
||||
return;
|
||||
// Since re-entrancy is possible, make a copy of the search prefixes.
|
||||
|
@ -46,7 +45,6 @@ void PyGlobals::loadDialectModule(llvm::StringRef dialectNamespace) {
|
|||
moduleName.append(dialectNamespace.data(), dialectNamespace.size());
|
||||
|
||||
try {
|
||||
py::gil_scoped_release();
|
||||
loaded = py::module::import(moduleName.c_str());
|
||||
} catch (py::error_already_set &e) {
|
||||
if (e.matches(PyExc_ModuleNotFoundError)) {
|
||||
|
@ -64,7 +62,6 @@ void PyGlobals::loadDialectModule(llvm::StringRef dialectNamespace) {
|
|||
|
||||
void PyGlobals::registerDialectImpl(const std::string &dialectNamespace,
|
||||
py::object pyClass) {
|
||||
py::gil_scoped_acquire();
|
||||
py::object &found = dialectClassMap[dialectNamespace];
|
||||
if (found) {
|
||||
throw SetPyError(PyExc_RuntimeError, llvm::Twine("Dialect namespace '") +
|
||||
|
@ -77,7 +74,6 @@ void PyGlobals::registerDialectImpl(const std::string &dialectNamespace,
|
|||
void PyGlobals::registerOperationImpl(const std::string &operationName,
|
||||
py::object pyClass,
|
||||
py::object rawOpViewClass) {
|
||||
py::gil_scoped_acquire();
|
||||
py::object &found = operationClassMap[operationName];
|
||||
if (found) {
|
||||
throw SetPyError(PyExc_RuntimeError, llvm::Twine("Operation '") +
|
||||
|
@ -90,7 +86,6 @@ void PyGlobals::registerOperationImpl(const std::string &operationName,
|
|||
|
||||
llvm::Optional<py::object>
|
||||
PyGlobals::lookupDialectClass(const std::string &dialectNamespace) {
|
||||
py::gil_scoped_acquire();
|
||||
loadDialectModule(dialectNamespace);
|
||||
// Fast match against the class map first (common case).
|
||||
const auto foundIt = dialectClassMap.find(dialectNamespace);
|
||||
|
@ -109,7 +104,6 @@ PyGlobals::lookupDialectClass(const std::string &dialectNamespace) {
|
|||
llvm::Optional<pybind11::object>
|
||||
PyGlobals::lookupRawOpViewClass(llvm::StringRef operationName) {
|
||||
{
|
||||
py::gil_scoped_acquire();
|
||||
auto foundIt = rawOpViewClassMapCache.find(operationName);
|
||||
if (foundIt != rawOpViewClassMapCache.end()) {
|
||||
if (foundIt->second.is_none())
|
||||
|
@ -126,7 +120,6 @@ PyGlobals::lookupRawOpViewClass(llvm::StringRef operationName) {
|
|||
|
||||
// Attempt to find from the canonical map and cache.
|
||||
{
|
||||
py::gil_scoped_acquire();
|
||||
auto foundIt = rawOpViewClassMap.find(operationName);
|
||||
if (foundIt != rawOpViewClassMap.end()) {
|
||||
if (foundIt->second.is_none())
|
||||
|
@ -143,7 +136,6 @@ PyGlobals::lookupRawOpViewClass(llvm::StringRef operationName) {
|
|||
}
|
||||
|
||||
void PyGlobals::clearImportCache() {
|
||||
py::gil_scoped_acquire();
|
||||
loadedDialectModulesCache.clear();
|
||||
rawOpViewClassMapCache.clear();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue