2

I am generating llvm IR code using llvmlite and Python. I generate code for many functions inside just one given module. The problem is that when an Exception occurs, while the code is generated for one of those functions, the whole module code generation gets corrupted. I would like a way to recover from the Exception by saying to the module : "Hey, forget that function altogether" before taking other actions. For example:

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

Any help?

Frederic
  • 1,580
  • 15
  • 15

0 Answers0