Easy to read Golang assembly output?

后端 未结 5 1763
猫巷女王i
猫巷女王i 2020-12-24 06:13

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; hopeful

5条回答
  •  执笔经年
    2020-12-24 06:51

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

       go tool compile -S file.go > file.s
      
    2. You can disable the optimization with -N:

       go tool compile -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.

提交回复
热议问题