New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[BUG]: Go Control Flow Graph not correctly matched #6439
Comments
Thanks for reporting this!
|
Looking at the full asm dump of the default go program https://godbolt.org/z/zx1EvK8zd :
It seems there's little hope of parsing this dump programmatically - this one doesn't even contain labels for function name, let alone basic blocks. |
Following #6439: mark the go compiler `gc` as not supporting cfg. Also, don't pass argument to `isCfgCompiler` - the base-compiler implementation uses `this.compiler.instructionSet` anyway.
Hey, sorry for the slow response and thanks for taking a look. I was wondering how exactly godbolt runs the Go compiler to obtain the dump you showed without function names? I tried using Go 1.22.1 by setting the The UI shows it’s using the following compiler flags: But when I compile the square code like that, I get:
So I’m wondering if the function names get lost somewhere else or if I’m reproducing it wrong. Regarding the basic blocks, what would we need to change in Go to make that work? Just emit more labels in the assembly output? Thanks |
GO has a special parser implementation, it takes the functions and adds custom labels https://github.com/compiler-explorer/compiler-explorer/blob/main/lib/compilers/golang.ts#L152 - starting with I think based on that information, we can make a custom implementation for CFG |
@partouf is right of course, I missed the custom parser. |
Describe the bug
Hey folks! I recently saw Matt Godbolt’s talk about what’s new in compiler explorer and was delighted to learn about the Control Flow Graph.
Unfortunately, when looking at the Control Flow Graph of a Go function, it seems like each basic block is treated as its own function — I don’t know how this feature works in detail, but maybe these blocks are not correctly matched to the main function?
Steps to reproduce
Expected behavior
I would have expected more than 1 box and arrows between them.
Reproduction link
https://godbolt.org/z/Ed8xYo7M1
Screenshots
Operating System
No response
Browser version
Google Chrome 124
The text was updated successfully, but these errors were encountered: