
Compiler Explorer - kercker
https://gcc.godbolt.org/#compilers:!((compiler:g6,options:%27-Os+-xc%27,sourcez:MQSwdgxgNgrgJgUwAQB4DOAXATuA5gOgAsA%2BAKFElkVUznAyLIunmRShAFsQM1HTyiAGbhkAZTFIAFGhAAvBAHshM%2BQgD6GAJRbBCEWGQBBADIBJAOIA5abIXLVCzVoC0ARl3BhopAHkrAKKSUo4a2u4A9ACqAMIAEkYASuoAskYAGp7ehkhxlnHB/kFIAFTSsQnJaekRAEwA1B5Z%2Bj4JYgBaAYm%2BUgAeWtJ9rkWSAGRIAH5DSON5FgW6pABuiiBwpZwInBCEWFIQimCYSCtrpWhYEAA0SPRI10h2YUhgugDepACQB0cYSDBHEC4QzrHYAQyw5yQAF5HpcANxfCAw6QA2TAhCgwgQrQQRGfISKSFSeGDGD0AAO2GcaBmSFMlisA1G4zAM3GJVpAEJYXjHvV6jcwC4XFp8SAhNI2SyoTz7gMPp9vodjk9NKUAO74z5qv4AaxRI1K921hOJGpR%2BxVf1O6xKWjQpLAxGhEnZSC5bU63SkJQ1AD09WKkBqBUKXK6xGKvgSibZLT9jrbSlotS93ZyPbzSWgwy8RdHPgBfL5YBAYGBYNlsgD80mT9tpAC4kAAGRFFoAA%3D%3D)),filterAsm:(commentOnly:!t,directives:!t,labels:!t),version:3
======
mattgodbolt
It's not very discoverable but there are sister sites for Rust, Go and D:

[https://rust.godbolt.org/](https://rust.godbolt.org/)
[https://go.godbolt.org/](https://go.godbolt.org/)
[https://d.godbolt.org/](https://d.godbolt.org/)

~~~
adamnemecek
are you planning one for swift?

~~~
pjmlp
IBM already provides one.

[https://swiftlang.ng.bluemix.net/?cm_mmc=developerWorks-_-
dW...](https://swiftlang.ng.bluemix.net/?cm_mmc=developerWorks-_-dWdevcenter-
_-swift-_-
lp&cm_mc_uid=86948701270814292766071&cm_mc_sid_50200000=1462951841#/repl)

They are investing into it.

[https://developer.ibm.com/swift/](https://developer.ibm.com/swift/)

I am expecting a Swift EE any day. :)

~~~
adamnemecek
that seems to be running the code, i'm interested in something showing
assembly. i realize that i can run the commands myself but the gcc explorer is
very interactive which i like.

~~~
alblue
I created SILInspector to do some demos for a presentation:

[https://github.com/alblue/SILInspector](https://github.com/alblue/SILInspector)

You can switch between the various stages of the Swift compiler including
assembly.

I did a talk for Swift London recently which was recoded: should be at
[https://m.youtube.com/channel/UC5ypB3f_gdQm2qJ4gmjYkJg](https://m.youtube.com/channel/UC5ypB3f_gdQm2qJ4gmjYkJg)
at some point.

~~~
alblue
The video of SILInspector (and background on SIL) is at
[https://m.youtube.com/watch?v=NH-qIKOoKgA](https://m.youtube.com/watch?v=NH-
qIKOoKgA)

~~~
adamnemecek
This looks dank

------
znpy
I would like to point out that compiler explorer is very easy to extend with
other toolchains and that Matt Godbolt is a very nice person.

I extended Godbolt's Gcc Explorer adding other toolchains (Motorola 68000 and
MIPS, built with crosstools-ng) beside the standard AMD64 one, and released as
a Docker image.

I did this because... I had to read and write M68k code for a class, and
having GCC generate code for me (with -O0 and the colourisation feature) was
the easiest way to get some code to read, besides the very basic examples)

In case you have to work with MIPS or M68K, you can find my "version" here:
[https://hub.docker.com/r/esantoro/acso-
explorer/](https://hub.docker.com/r/esantoro/acso-explorer/)

IIRC, the bundled gcc is version 4.9.something

------
aappleby
This is a fabulous tool for exploring micro-optimizations across a range of
CPUs.

I've used it for investigating how some inner loops get pipelined across AVR,
ARM+Thumb, ARM32, ARM64, PowerPC, x86-32, and x86-64 processors.

------
rryan
This site is so handy -- if it's useful to you too please Flattr the author so
they can continue to host it. It's been a helpful tool to be able to link
people to code+assembly when trying to convince people not to "optimize" code
in code reviews :).

------
willvarfar
Excellent!

LLVM used to have an online compiler page but IIRC they took it down due to
security concerns.

Of course I have a couple of suggestions ;) :

What this needs is synchronized scrolling ala
[http://stackoverflow.com/questions/21410675/getting-the-
orig...](http://stackoverflow.com/questions/21410675/getting-the-original-
variable-name-for-an-llvm-value)

And would be nice if it can show intermediate steps (the AST, the IR) in
parallel or show different optimisation levels beside each other too.

~~~
mattgodbolt
Please feel free to file some suggestions at
[https://github.com/mattgodbolt/gcc-
explorer/issues](https://github.com/mattgodbolt/gcc-explorer/issues) :)

------
teraflop
Some of the examples are broken because they use C++ language constructs but
they're being compiled as C code, which leads to error messages like:

    
    
      13 : error: 'static_cast' undeclared (first use in this function)
         input = static_cast<int*>(__builtin_assume_aligned(input, 64));
                 ^

~~~
ygra
Remove the -xc option. But agreed, it'd be nice if that kind of thing would be
automatic, at least for the supplied examples.

~~~
mattgodbolt
The supplied examples by design don't override the settings you've chosen:
this lets you play independently with the text and the settings. It seems the
original link here on HN was to a canned example with settings for C, which I
think caused the confusion.

------
mrich
Suggestion: Add a switch to show C/C++ code lines next to the created
assembly. This is very helpful for learning.

In gdb you can get this with disassemble /m, or with objdump -S.

Helped me a lot in the past.

~~~
masklinn
The "colourise" option does that, kind-of.

------
amelius
Suggestion: make the opcodes clickable, leading the user to the documentation
of the opcode.

~~~
exDM69
A slight problem with that is that the definitive documentation for the
opcodes are gigantic PDF manuals that may be hard to obtain for some
architectures (e.g. ARM-ARM).

There are some assembly opcode reference manuals on the internet but they're
of varying quality and typically cover only one instruction set per site.

~~~
i336_
If this site steps up and offers to provide an easily searchable documentation
interface, I imagine people will immediately help out keeping the docs up to
date.

------
tempodox
Great tool! I sometimes do the same locally to check out language behaviour,
but most of the time it's just one compiler. This tool lets me see compiler
differences and the evolution between compiler versions. Nice.

------
gravypod
I've used this to help friends fudge their CS homework in a CS class.

It's an assembly class that's impossible since you aren't taught, so they can
write their labs in C and decompile it to make it easy.

~~~
Shoop
Isn't compiler generated assembly really easy to tell apart from hand written
assembly?

~~~
userbinator
_Good_ handwritten Asm is extremely different from compiler output. For a
class that is likely to be "mimic what a compiler does" (which isn't the point
of using Asm, but I digress...), probably not.

~~~
gravypod
Well, there are two types of students who pass this class:

a) Those who know someone who took it. b) Those who have a chegg account.

