Closed giann closed 1 year ago
Sorry for the delay with the answer.
Yes, the crash is expected. MIR_finish means finish all work with mir and all generated code.
MIR_finish frees all memory allocated by MIR including memory for the generated code.
Alright so followup question: i'm generating a function in which a constant is a reference to another function that also needs to be generated. How can i do that? Do i use several contexts?
No. you do not need use different contexts. They are mostly for independent parallel working MIR usage.
The best and simplest way to see how to do this is to look at mir-tests/run-test.c code.
Basically put the functions into one or two different modules, load module(s), link them using regular or lazy generator interface.
For the regular interface, linking will do all loaded functions generation and MIR_gen will return address of already generated function code.
For lazy interface, MIR_gen will generate code for given function only and code for functions called from given function will be generated on-the-fly (on the 1st call) and called automatically after that.
I have functions pointer returned by
MIR_gen
. If I try to call them after callingMIR_finish
they will crash. Is this intended/normal?