4 ms·
Godbolt is a fun tool: https://godbolt.org/ https://godbolt.org/ The story I heard, was that the author is one of these obsessive genius types, who was having
by ChrisMarshallNY 6y ago
Godbolt is a fun tool: https://godbolt.org/ https://godbolt.org/
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...
- flohofwoe 6y agoIMHO you don't have to be obsessive to use godbolt.org in your daily work, neither should it be a "tool of last resort". 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.
- ChrisMarshallNY 6y agoI consider Godbolt to be an educational and “thinking cap” tool, as opposed to a critical path optimization tool. 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.
- amelius 6y agoI don't understand this tool. My compiler has a flag for generating assembly output. That should be sufficient, no? Also, it more accurately reflects what my compiler actually generates given all the other flags.
- flohofwoe 6y agoAn important feature of godbolt is quickly comparing the output and language feature support of different compilers, or different versions of the same compiler (e.g. what versions of MSVC support a specific C99 feature, or which new C++ feature is safe to use across clang, gcc and MSVC). And most importantly, you can check what your code would look like when compiled for 6502 or Z80 ;)
- amelius 6y agoI see, but I'm not convinced a web-tool is the best way to go about it if optimizing assembly is part of one's dayjob. 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.
- flohofwoe 6y agoThere's a few nice hidden features presented in Matt Godbolt's talk here: https://www.youtube.com/watch?v=kIoZDUd5DKw 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 https://www.godbolt.org/z/r7f6TY Likewise for WASM: https://www.godbolt.org/z/Kr6G3K https://www.godbolt.org/z/Kr6G3K
- pjc50 6y ago> I'm not convinced a web-tool is the best way to go about it if optimizing assembly is one's dayjob. 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.
- mumblemumble 6y agoThere was a great interview with Matt Godbolt on the CoRecursive podcast: https://corecursive.com/to-the-assembly/ https://corecursive.com/to-the-assembly/ Touches on a lot of good reasons why someone might still want to understand assembly in this day and age.