Stream: cranelift

Topic: FunctionBuilder vs FunctionBuilderContext


view this post on Zulip Chris Clark (Jun 06 2023 at 03:30):

I heard or read somehwere that FunctionBuilderContext is supposed to be reusable, it has various things like target. The separation between these three Function, FunctionBuilder, and FunctionBuilderContext is designed to make things at the function level, so it can be highly parallelized.

In order to reset its state, it says I need to call FunctionBuilder::finalize()

This function states:

Declare that translation of the current function is complete.
This resets the state of the FunctionBuilderContext in preparation to be used for another function.

Am I misunderstanding this, or can I not use multiple FunctionBuilders at the same time on FunctionBuilderContext. The wording "in preparation to be used for another function" implies that without that preparation, it wouldn't be usable for another function, as it contains singleton items for that function its building.

If so, how would I parallelize this at the function level?

view this post on Zulip bjorn3 (Jun 06 2023 at 05:45):

If you want to parallelize, you have to use a separate FunctionBuilderContext for each thread.


Last updated: Dec 23 2024 at 12:05 UTC