2

我正在使用 llvmlite 和 Python 生成 llvm IR 代码。我在一个给定的模块中为许多函数生成代码。问题是,当发生异常时,在为其中一个函数生成代码时,整个模块代码生成被破坏。我想要一种从异常中恢复的方法,方法是在采取其他行动之前对模块说:“嘿,完全忘记那个功能”。例如:

# 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...

有什么帮助吗?

4

0 回答 0