易于阅读Golang汇编输出? [英] Easy to read Golang assembly output?

查看:157
本文介绍了易于阅读Golang汇编输出?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我感兴趣的检查标准去编译器的x86汇编输出,看看我的code是真的被转化为合理有效组装code;我们希望,通过分析和研究汇编输出,我能得到一个线索,在那里/我应该如何重写我的围棋code的最高性能。但是,当我检查code。使用-S标志,围棋吐出一个烂摊子!我想两件事情:


  1. 有没有办法让编译器去转储汇编输出到文件中,而不是仅仅把它打印出来的终端?


  2. 此外,有没有一种方法,使围棋编译器分离出组装code到单独的功能,具有标签?我知道有些功能可能被内联,因此不会出现在组装code。我所看到的知道的是组装的只是一个同质的blob这几乎是不可能理解。



解决方案

  1. 您可以将输出重定向到一个像这样的文件:

     去工具6克-S file.go> file.s


  2. 您可以禁用与-N优化:

     去工具6克-S -N file.go


另外,你可以使用gccgo:

  gccgo -S -O0 -masm =英特尔test.go

,这将产生test.s.你可以用-O0 / 1/2/3玩玩看不同的优化。

I'm interested in examining the x86 assembly output of the standard Go compiler to see if my code is really being converted into reasonably efficient assembly code; hopefully, by profiling and examining the assembly output, I could get a clue as to where/how I should rewrite my Go code for maximum performance. But when I examine the code using the -S flag, Go spits out a mess! I'd like two things:

  1. Is there a way to make the Go compiler dump the assembly output into a file, not just print it out on Terminal?

  2. Also, is there a way to make the Go compiler separate out the assembly code into separate functions, with labels? I know some functions may be inlined and hence not appear in the assembly code. What I'm seeing know is just a homogenous blob of assembly which is almost impossible to understand.

解决方案

  1. You can redirect the output to a file like this:

    go tool 6g -S file.go > file.s
    

  2. You can disable the optimization with -N:

    go tool 6g -S -N file.go
    

Alternatively, you can use gccgo:

gccgo -S -O0 -masm=intel test.go

which will generate test.s. You can play with the -O0/1/2/3 to see the different optimizations.

这篇关于易于阅读Golang汇编输出?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆