Stream: cranelift

Topic: modification of cached clif


view this post on Zulip Riccardo D'Ambrosio (Jul 11 2021 at 03:17):

Is it possible to modify cached clif easily? I am making something which needs to have extremely fast compilation times, like, sub-5ms, and it would be nice if it was possible to modify clif on the fly so i dont have to regenerate it fully every time. The thing im compiling is a node graph so every value is part of its own little thing, so what would be the best way to go about this? Do i make a basic block for every node then regenerate those on the fly or can i just say "this value is an iconst, change it to this pls"?

view this post on Zulip Riccardo D'Ambrosio (Jul 11 2021 at 03:18):

does cranelift perform badly if i give it a lot (20, 50, even 100) of basic blocks? because i think nodes mapping to basic blocks would work really well, and i could compile nodes in parallel too (assuming cranelift would allow me to create basic blocks then append them)

view this post on Zulip bjorn3 (Jul 11 2021 at 09:08):

You can clone a Function before compilation if you want to change and recompile it. Using many basic blocks should work fine. It is not possible to write to a single function from multiple threads at the same time.

view this post on Zulip Riccardo D'Ambrosio (Jul 11 2021 at 15:51):

I see, in that case ill probably just make the node -> LIR transformation multithreaded since i have other backends and not just cranelift. @bjorn3 how would i actually modify the clif inside functions however? i dont see any functions for modifying existing instructions, although i prob missed them

view this post on Zulip Riccardo D'Ambrosio (Jul 11 2021 at 15:55):

oh i see, i think i can just modify the dataflow graph

view this post on Zulip Riccardo D'Ambrosio (Jul 11 2021 at 15:56):

ooh the constant map seems extremely helpful since most of the changes to the node graph will be changes to constants, so i can just change that on the fly


Last updated: Dec 23 2024 at 12:05 UTC