To avoid potential memory leaks, this PR defers the ModuleOp cloning until after the verification check. If the check fails, the moduleVariant might not be properly deallocated(original implementation), leading to a memory leak. Therefore, this PR ensures that the clone operation is only performed after a successful check. It is part of https://github.com/llvm/llvm-project/pull/189353.
Multi-Level Intermediate Representation
See https://mlir.llvm.org/ for more information.