getOrInsertFunction issue

Dear community

I’m working on a compiler for a in-house DSP developped with LLVM 8.0.
Now I’m trying to migrate the LLVM base to the latest one (LLVM-13), but I proceed by steps and first I migrate to LLVM-9.0

In my code, I use the “getOrInsertFunction” method which crashes on LLVM9.0:

  • first call (‘insert’) → ok

  • second call on an existing funcion (‘get’) → the function exists but it seems that the Context environment is lost for the FunctionType variable (getContext is empty)

I checked that after the first call of ‘getOrInsertFunction’, the context is correct.

Has anyone faced this issue ? Is it resolved in a higher version of LLVM ?

Thank for your help !

Make sure that getOrInsertFunction does indeed return a function and not say a constexpr bitcast (which could happen if type of the function is different from what was used for the initial insert)