It really does help a lot to understand what the compiler will actually turn your high level code into, because quite often the results are very surprising (or if only to be shocked about the amount of assembly code that's generated from a few lines of C++ template code). Comparing the differences in output between different compilers and optimization levels is also very useful.
It is pretty damn cool, though.
It’s sort of like how an algebraic graphing app is most useful for students, as opposed to working engineers.
Nowadays, with on-chip threading, ASM stack dumps are a lot less useful than they used to be. Really, for me, munged function names are what I use to figure out the general vicinity of a bug, which I then figure out, by examining the source.
Touches on a lot of good reasons why someone might still want to understand assembly in this day and age.
It's quite often easier to just slam something into godbolt than to do it locally with a temporary file and gcc -S.
And most importantly, you can check what your code would look like when compiled for 6502 or Z80 ;)
I do understand that it's nice to play with, and that it can have educational value. I would personally love to see WASM support, and a way to see e.g. LLVM intermediate code. But I'd want to see some more documentation on the website e.g. about the ABI so I know how the arguments of a function are passed in etc.
It isn't, because that's not what it's for. Besides, few people have optimizing assembly as a dayjob, and in that case you'd be writing it rather than reading it. Trying to juice a compiler into producing specific assembly output is frustrating and brittle. I suppose it's useful for seeing whether your autovectorisation has worked.
But the best use of godbolt - uniquely as a web tool - is to show other people what the output is.
(I wish more people would stop before saying "tool X is useless for workflow Y" and ask themselves what the intended workflow of tool X is. Not everything is for everybody, that would be impossible.)
> more documentation on the website e.g. about the ABI so I know how the arguments of a function are passed in etc
It just calls the underlying compiler executables. Consult their documentation.
We use it all the time, it's certainly not just a toy.
I have the luxury of having a build farm with a large range of compilers and platforms available, so I could use that to rig something like godbolt. But that'd be spending probably days on setting something up, + ongoing maintenance, instead of just using an existing thing that does the job? If I really were only doing this kind of thing, that'd probably be worth it to be able to customize etc. But I'm not. It being a service (and thus basically automatically a web tool) is a a valuable feature.
It's also a great tool to share and communicate results of such investigations. Again, easy for a web tool.
https://www.youtube.com/watch?v=kIoZDUd5DKw
As for LLVM IR output, just use the right clang command line options:
https://www.godbolt.org/z/r7f6TY
Likewise for WASM:
The story I heard, was that the author is one of these obsessive genius types, who was having a debate about compiler efficiency, so he wrote an entire compiler engine to prove his point.
I can understand that.
This is a great article. Being able to descend into machine code/assembly is a valuable “tool of last resort.”
Personally, I avoid that like the plague, but an OS developer probably still needs to do this (I developed system stuff, back in the Dawn Times).
I started off with Machine Code, so it’s been a long, strange trip, for me...