Recently I worked on a couple of WebKit bugs where being able to inspect the compiled assembly output was useful. In situations like these, compiler explorer is a good tool to have in your toolbox.

The first bug was around empty switch statements in generated code. The opcode_generator.rb ruby script consumes the AirOpcode.opcodes file and generates a AirOpcodeGenerated.h header file. AirOpcodeGenerated.h contained code that looked like this:

switch (argIndex) {

Which is effectively a no-op. This code compiles in clang generating a jmp instruction to a label on the next line. This code doesn’t compile in MSVC with flags /Wall /WX, because /Wall generates a warning for a switch statement with no case labels, and /WX treats all compiler warnings as errors:

<source>(6): error C2220: the following warning is treated as an error
<source>(6): warning C4065: switch statement contains 'default' but no 'case' labels

The compiler explorer was useful here to see that there was a very slight benefit to other platforms by making this change for Windows - removing a no-op jmp instruction.

The second bug was around implementing a Signals interface for Windows. While Windows has interrupt signal handling, I couldn’t see a way to be able to recover from a SIGSEGV and continue execution at a specified point. Luckily I found a suggestion from Yusuke Suzuki on an earlier related bug:

The same interface needs to be implemented on Windows with vectored exception handlers.

So I did that, however when writing a test for it I wasn’t sure what to set the program counter to when returning, such that I advanced the program counter past the code that generated the AccessFault. I might’ve been able to use Labels as Values if WebKit was built using clang on all platforms, but MSVC is used on Windows (for now). So I used compiler explorer to determine how much to add to the program counter. It was also handy when my code to generate an access fault wasn’t working - the compiler was optimizing away my unused variable, which was obvious once I ran it through compiler explorer.

I haven’t used it for languages other than C and C++, though it looks like it supports a bunch of other languages. Might be a useful addition to your toolbox.