This is an archive of the discontinued LLVM Phabricator instance.

[mlir] Make topologicalSort consider op regions
ClosedPublic

Authored by ThomasRaoux on Nov 8 2021, 10:47 AM.

Details

Summary

When doing topological sort we need to make sure an op is scheduled before any of the ops within its regions.

Diff Detail

Event Timeline

ThomasRaoux created this revision.Nov 8 2021, 10:47 AM
ThomasRaoux requested review of this revision.Nov 8 2021, 10:47 AM
Herald added a project: Restricted Project. · View Herald TranscriptNov 8 2021, 10:47 AM

Is this something that you can make visible with a test somehow?

Is this something that you can make visible with a test somehow?

I have a following patch using this, I can combine it or do you think it should be tested independently of any other user? I would need to add some test pass for this and somehow test slicing/sorting individually.

Can you stack up the dependent change in Phabricator?

mlir/lib/Analysis/SliceAnalysis.cpp
170–171

Reading the code a bit more now, this seems like a recursive algorithm on use-def chain?
Seems like a ticking bomb for a stack overflow (we call this out in the list here: https://mlir.llvm.org/getting_started/DeveloperGuide/#style-guide )

This really should be iterative instead.

Remove recursion and add a test for topological sort

Is this something that you can make visible with a test somehow?

So I ended up adding a test pass just for this. Let me know what you think.

mlir/lib/Analysis/SliceAnalysis.cpp
170–171

Changed it to be iterative.

rriddle added inline comments.Nov 9 2021, 6:33 PM
mlir/lib/Analysis/SliceAnalysis.cpp
173–175

nit: drop trivial braces

181–184

Address review comments

ThomasRaoux marked 2 inline comments as done.Nov 9 2021, 6:48 PM
mehdi_amini accepted this revision.Nov 9 2021, 10:04 PM

Thanks!

This revision is now accepted and ready to land.Nov 9 2021, 10:04 PM