[LLVMdev] Calling PassManager on previously JITed Modules

Stephen Kyle stephenckyle at googlemail.com
Mon Nov 8 13:22:03 PST 2010


Hi,

Has anyone had any success with running different PassManagers on
llvm::Modules they've already JITed and are executing?

In detail:

1) getting the IR, in form of an llvm::Module
2) calling PassManager->run() on the module
3) calling getFunction() and getPointerToFunction() to JIT the module
4) executing the JITed code using the function pointer received in step 3

and then what I want to do is:

5) using a different PassManager with different (more time-consuming)
Passes, call run() on the module again
6) call getFunction() and getPointerToFunction() again
7) use the new function pointer to execute the JITed code instead.

As an added complication, different threads may be performing the
initial compilation or reoptimisation, but before we consider this, is
there any reason why the above shouldn't work?

When I do it, I occasionally get assertion errors such as:

<more path...>/RELEASE_28/include/llvm/ADT/APInt.h:819: bool
llvm::APInt::operator==(const llvm::APInt&) const: Assertion `BitWidth
== RHS.BitWidth && "Comparison requires equal bit widths"' failed.
Stack dump:
0.	Running pass 'Function Pass Manager' on module 'lib0000'.
1.	Running pass 'Combine redundant instructions' on function '<func name>'
Aborted

or

RELEASE_28/lib/VMCore/LeaksContext.h:50: void
llvm::LeakDetectorImpl<T>::addGarbage(const T*) [with T =
llvm::Value]: Assertion `Ts.count(o) == 0 && "Object already in set!"'
failed.
Stack dump:
0.	Running pass 'Function Pass Manager' on module 'lib000d'.
1.	Running pass 'Combine redundant instructions' on function '<func name>'
Aborted

It only happens sometimes, so this would imply some kind of race
condition between the compliation and reoptimisation threads, but I'm
definitely not trying to run a PassManager on a module which is
currently being JITed, so perhaps something about the module is being
corrupted by the call to the JIT? Hopefully the above assertion checks
indicate something obvious to someone...?

Cheers,
Stephen



More information about the llvm-dev mailing list