Stream: cranelift

Topic: Dumping basic block contents


view this post on Zulip Piotr (Jan 04 2025 at 19:50):

Hi there, is there a way to dump the contents of a block to stdout? dbg!(block) only seems to print the id of the block.

view this post on Zulip bjorn3 (Jan 05 2025 at 15:01):

I don't think there is. There is dbg!(func) to print the entire function though.

view this post on Zulip bjorn3 (Jan 05 2025 at 15:02):

And you can manually iterate over the instrunctions in a block and print them individually.

view this post on Zulip Piotr (Jan 05 2025 at 17:55):

Will do, thank you for the information!

view this post on Zulip fitzgen (he/him) (Jan 14 2025 at 19:40):

fwiw, factoring out the print-one-block logic from the print-the-whole-function method into its own method would be cool to have, if you have the appetite for that kind of thing

view this post on Zulip blazzy (Jan 31 2025 at 05:06):

Am I right in saying this hypothetical function would not be an implementation of fmt::Display for block? Since a block doesn't have enough context on its own to display anything useful. What would the method be called.

view this post on Zulip bjorn3 (Jan 31 2025 at 11:18):

Correct. Maybe a display_block method on Function which accepts a Block as argument amd returns a type that borrows from Function and implements Display would work?


Last updated: Feb 27 2025 at 23:03 UTC