problem with DwarfEHPrepare::InsertUnwindResumeCalls in multiple JIT context?

Hi, I was wondering if there are any known issues with DwarfEHPrepare::InsertUnwindResumeCalls when using JIT? It appears that the block of code below in this function doesn’t correctly handle the case where the rewind function is removed from the module by some other pass (when its unused for instance), and multiple functions are JITed. The RewindFunction variable will get set once, then when the rewind function is removed it never gets updated. Is this just an unsupported use case of calling the JIT multiple times, or am I missing something? Thanks!


if (!RewindFunction) {

LLVMContext &Ctx = Resumes[0]->getContext();

FunctionType *FTy = FunctionType::get(Type::getVoidTy(Ctx),

Type::getInt8PtrTy(Ctx), false);

const char *RewindName = TLI->getLibcallName(RTLIB::UNWIND_RESUME);

RewindFunction = F->getParent()->getOrInsertFunction(RewindName, FTy);


Hi Damien, the pass wasn't expecting the module to be changing underneath it.
It should be easy enough to tweak it to add the declaration whenever it is
needed. Please send a patch or open a bug report.

Ciao, Duncan.