Python 中止llvmlite代码生成

Python 中止llvmlite代码生成,python,llvm,llvm-ir,llvmlite,Python,Llvm,Llvm Ir,Llvmlite,我正在使用llvmlite和Python生成llvmir代码。我只在一个给定的模块中为许多函数生成代码。问题是,当发生异常时,当为其中一个函数生成代码时,整个模块代码生成过程都会损坏。我想要一种从异常中恢复的方法,在采取其他操作之前对模块说:“嘿,完全忘记那个函数”。例如: # Create function func = ir.Function(module, functype, funcname) # Create the entry BB in the function and set

我正在使用llvmlite和Python生成llvmir代码。我只在一个给定的模块中为许多函数生成代码。问题是,当发生异常时,当为其中一个函数生成代码时,整个模块代码生成过程都会损坏。我想要一种从异常中恢复的方法,在采取其他操作之前对模块说:“嘿,完全忘记那个函数”。例如:

# Create function
func = ir.Function(module, functype, funcname)

# Create the entry BB in the function and set a new builder to it.
bb_entry = func.append_basic_block('entry')
builder = ir.IRBuilder(bb_entry)

try:
  # Generate code for func with the builder ...

except:
  # Oops, a problem occured while generating code
  # Remove func from module : How to do that ?
  del module.globals[funcname] # does not work...
有什么帮助吗