Re: [EXTERNAL] Re: Display opcodes?

543 views
Skip to first unread message

Matt Godbolt

unread,
Sep 16, 2021, 12:16:39 PM9/16/21
to Dan Jump, compiler-explo...@googlegroups.com
Hi Dan, (and CC'ing the development group in case folks have any further comments)

As I mentioned we don't support it for MSVC compilers. I realise it's a bit weird, but on non-MSVC we ask the compiler to output asm directly by default, which is why you see the assembly instructions but not the opcodes (because it hasn't been assembled). This gives us the highest fidelity results: assembling and then disassembling loses information, as you can imagine. If you enable "binary mode" then we compile and link the executable, and then disassemble it to get the opcodes (for those platforms where we can generate binaries, and then disassemble them).

Visual Studio can show these when debugging, for example. 

Agreed: visual studio is working on the compiled, linked binary. We don't output this - we show the compiler's textual output (as above). To support this we need to compile to binary and then disassemble.

I suspect you'd have to implement the lookup yourself?

We have nothing to look up, unfortunately. We don't want to assemble the files ourselves: that's the compiler and toolchain's job :)  So, we'll need help from MS to get the compilers in a state where we can generate .obj files (or .exe) and then disassemble them. The bug I linked mentions a /GL option, but I don't know what that is.

I'm really glad you're able to use Compiler Explorer to check stuff out! That's one of its goals :)

For binary size stuff, see the github bug and/or if you have any sway internally, you can speak with Tim Myers who is in charge of MS's side of things for the Windows-based compilers.

Cheers, Matt :)





On Thu, Sep 16, 2021 at 10:56 AM Dan Jump <Dan....@microsoft.com> wrote:
Hi Matt,

Yes, I see the assembly instructions, but I'm not seeing the op codes (e.g. E8 C4) for each one. Visual Studio can show these when debugging, for example. I suspect you'd have to implement the lookup yourself?

I run a team in Office that (among other things) keeps up with C++ developments and how those should apply in Office. Office builds for Android and Apple so we use clang there, and in general, we leverage clang for tooling scenarios such as tidy. So I usually just use clang on godbolt - it's better supported, usually sufficient for figuring things out, and if the code works on clang, it usually works on msvc :)

Thanks,
Dan

From: Matt Godbolt <ma...@godbolt.org>
Sent: Thursday, September 16, 2021 8:39 AM
To: Dan Jump <Dan....@microsoft.com>
Subject: [EXTERNAL] Re: Display opcodes?
 
Hi Dan!

Yes - pick the "compile to binary" option off the menu to see the opcodes on supported compilers: https://godbolt.org/z/MYYnxbTes

Unfortunately, MSVC compilers aren't supported in this mode. Given your email address, I imagine this is what you're after. MS actually run our Windows instances (see www.godbolt.ms for example) and collaborate with us to get MS-specific features. We don't have much expertise or experience with Windows compilers, so a lot of the features work only our Linux-based open source compilers, but we of course want to cater to as many OSes and compilers as possible!

We have an issue filed for this: https://github.com/compiler-explorer/compiler-explorer/issues/2485 - maybe you have some ideas how to move forward?

Thanks, Matt :)

On Thu, Sep 16, 2021 at 10:15 AM Dan Jump <Dan....@microsoft.com> wrote:
Hi Matt,

Thanks for the great work on godbolt. Is there an option to see the assembly opcodes? It's mostly for curiosity sake about the size of operations.

Dan


--
Matt
(he/him)


--
Matt
(he/him)

Dan Jump

unread,
Sep 16, 2021, 12:48:56 PM9/16/21
to Matt Godbolt, compiler-explo...@googlegroups.com
Thanks for the extra details here Matt - that makes sense. I totally glossed over 'compile to binary' as "I'm already doing that", but in fact, I was not! I see the opcodes on clang now which is super helpful.

Dan


From: Matt Godbolt <ma...@godbolt.org>
Sent: Thursday, September 16, 2021 9:16 AM
To: Dan Jump <Dan....@microsoft.com>
Cc: compiler-explo...@googlegroups.com <compiler-explo...@googlegroups.com>
Subject: Re: [EXTERNAL] Re: Display opcodes?
 

Matt Godbolt

unread,
Sep 16, 2021, 1:14:23 PM9/16/21
to Dan Jump, compiler-explo...@googlegroups.com
Awesome stuff!! Our binary output could do with some work - but it's there.

Thanks for letting us know it worked out in the end :)

--matt
--
Matt
(he/him)
Reply all
Reply to author
Forward
0 new messages