This is an archive of the discontinued LLVM Phabricator instance.

Added check if there are regions that do not implement the RegionBranchOpInterface.
ClosedPublic

Authored by dfki-jugr on Jan 13 2021, 2:54 AM.

Details

Summary

Add a check if regions do not implement the RegionBranchOpInterface. This is not
allowed in the current deallocation steps. Furthermore, we handle edge-cases,
where a single region is attached and the parent operation has no results.

This fixes: https://bugs.llvm.org/show_bug.cgi?id=48575

Diff Detail

Event Timeline

dfki-jugr created this revision.Jan 13 2021, 2:54 AM
dfki-jugr requested review of this revision.Jan 13 2021, 2:54 AM
herhut added inline comments.Jan 15 2021, 3:38 AM
mlir/lib/Transforms/BufferDeallocation.cpp
83

Naming: This does not check for control flow. It checks whether interfaces are present or whether the control flow is supported.

84

Would region.walk do what you want?

87

check that operation's with at least one region implement...

I did not check this but I am a little surprised that operations with inputs do not require this interface. How is the connection between an input and the uses inside of the succesor regions made in this case?

94

nit: use empty or getNumResults() == 0.

99

Consider not aborting early but reporting more cases?

539

This could be made slightly better by moving the emitError into the checkForControlFlow helper (and maybe call it validateControlFlowIsSupported or something). Then you could emit the error on the op that fails the check, which gives the user of this a more actionable error.

dfki-jugr added inline comments.Jan 18 2021, 2:19 AM
mlir/lib/Transforms/BufferDeallocation.cpp
84

We are wondering if the walk is recursive?
If yes, we could use region.walk.

87

In general, we would need to check the inputs if there are some uses inside the successor region.
Considering our implementation, we insert deallocations after the operation such that they are independent from the inputs.

dfki-jugr updated this revision to Diff 317519.Jan 19 2021, 4:05 AM

Addressed comments.

herhut accepted this revision.Jan 20 2021, 2:32 AM

Please fix comments.

mlir/lib/Transforms/BufferDeallocation.cpp
87

Nit: the comment is wrong. This does not check if the operation has at least one region and implements the interface, it checks if all operations that have at least one region implement the interface.

91

nit: since _in that case_ the

This revision is now accepted and ready to land.Jan 20 2021, 2:32 AM
This revision was landed with ongoing or failed builds.Jan 20 2021, 3:23 AM
This revision was automatically updated to reflect the committed changes.
dfki-jugr marked 4 inline comments as done.