Skip to content
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

assembly data flow graph #1158

Open
Trass3r opened this issue Nov 7, 2018 · 5 comments
Open

assembly data flow graph #1158

Trass3r opened this issue Nov 7, 2018 · 5 comments

Comments

@Trass3r
Copy link

Trass3r commented Nov 7, 2018

I just discovered the llvm-mca integration, that's awesome!
With the -timeline option you do get an idea of the instruction dependency chains:
https://godbolt.org/z/-cMrJI

But it would be nicer if there was a graph like the following, just on an MCInst level:
https://github.com/k3ut0i/llvm-dataflow-graphs
flow graph

@mattgodbolt
Copy link
Member

Agreed: I'd ideally love to parse llvm-mca output, or better still have it output parseable JSON of what happened. Then I can use any number of graph library layouts to try and show the information.

We already have CFG: https://godbolt.org/z/dFqf4H

@Trass3r
Copy link
Author

Trass3r commented Nov 8, 2018

Yeah though the current CFG code is quite ad-hoc, parsing the assembly manually.
It should ideally be implemented inside of llvm along the lines of opt -dot-cfg or in a tool based on the llvm API like https://github.com/pfalcon/graph-llvm-ir or the one mentioned above. There is also a node-llvm binding.

Edit: I quickly hacked dot file emission into mca for a simple execution order visualization:

L1:
    movapd xmm1, [esi+eax]
    mulpd  xmm1, xmm2     
    movapd xmm0, [edi+eax]
    subpd  xmm0, xmm1     
    movapd [edi+eax], xmm0
    add eax, 16           
    cmp eax, ecx
    jz L1

image

@OfekShilon
Copy link
Member

Please note that

opt -passes="view-cfg" -cfg-func-name=<func> <ll filename> -disable-output

produces better graphs - colors encoding regions. Maybe useful.

@jeremy-rifkin
Copy link
Member

@OfekShilon Is there an equivalent of this for data flow? It looks like opt is generating a control flow graph here

@OfekShilon
Copy link
Member

@OfekShilon Is there an equivalent of this for data flow? It looks like opt is generating a control flow graph here

No ,sorry. I was lead hear by a link from the suggestion regarding cfg + data-dep, and saw that the start of the discussion touched on cfg so thought I'd comment here.

Please note that IR cfg (as the opt passes dot-cfg or view-cfg emit) is not strictly equivalent to assembly cfg (which is already available). Personally I think both are useful.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Development

No branches or pull requests

4 participants