This is an archive of the discontinued LLVM Phabricator instance.

[mlir] Allow data flow analysis of non-control flow branch arguments
ClosedPublic

Authored by krzysz00 on Apr 19 2022, 10:51 AM.

Details

Summary

This commit adds the visitNonControlFlowArguments method to
DataFlowAnalysis, allowing analyses to provide lattice values for the
arguments to a RegionSuccessor block that aren't directly tied to an
op's inputs. For example, integer range interface can use this method
to infer bounds for the step values in loops.

This method has a default implementation that keeps the old behavior
of assigning a pessimistic fixedpoint state to all such arguments.

Diff Detail

Event Timeline

krzysz00 created this revision.Apr 19 2022, 10:51 AM
Herald added a project: Restricted Project. · View Herald TranscriptApr 19 2022, 10:51 AM
krzysz00 requested review of this revision.Apr 19 2022, 10:51 AM
Mogball added inline comments.
mlir/include/mlir/Analysis/DataFlowAnalysis.h
368

This should be moved to the source file.

368

Name this one successor and regionPtr region

rriddle requested changes to this revision.Apr 19 2022, 11:53 AM

Can you please add a test case that exercises this?

This revision now requires changes to proceed.Apr 19 2022, 11:53 AM

@rriddle Do you have thoughts on what such a testcase would look like? The method overall is exercised by the integer range analysis, and the only other available dataflow analysis is SCCP, which doesn't look into region arguments at all (from the looks of it)

You can write a dummy test pass that just prints some text.

krzysz00 updated this revision to Diff 424242.Apr 21 2022, 10:11 AM

Add test for data flow pass and default branch argument methods

krzysz00 marked 2 inline comments as done and an inline comment as not done.Apr 21 2022, 10:12 AM

I've gone and added the test, hopefully this'll do it

mlir/include/mlir/Analysis/DataFlowAnalysis.h
368

This can't be moved to the source file - templates.

Mogball added inline comments.Apr 21 2022, 5:10 PM
mlir/include/mlir/Analysis/DataFlowAnalysis.h
257–260

The default implementation comes later

368

ah, right you are

370
377
mlir/lib/Analysis/DataFlowAnalysis.cpp
524
mlir/test/lib/Analysis/TestDataFlow.cpp
24

move this to the bottom

39
46

why is this necessary?

krzysz00 updated this revision to Diff 424588.Apr 22 2022, 1:01 PM
krzysz00 marked 5 inline comments as done.

Address review comments

krzysz00 added inline comments.Apr 22 2022, 1:02 PM
mlir/test/lib/Analysis/TestDataFlow.cpp
46

The base class has a virtual destructor, is why I think this is here.

I was following the lead of the SCCP pass on this.

Mogball accepted this revision.Apr 24 2022, 11:20 AM
Mogball added inline comments.
mlir/include/mlir/Analysis/DataFlowAnalysis.h
253–257

And can you make the same edits to the copy-pasted doc in the default implementation below?

mlir/lib/Analysis/DataFlowAnalysis.cpp
526–529

Could you add an assert that the lattice values of block arguments that aren't aliases by control flow have values to ensure implementation correctness?

mlir/test/lib/Analysis/TestDataFlow.cpp
46

I'm 90% sure this isn't needed :O

79

Can you implement visitNonControlFlowArguments in the test pass and do something different?

rriddle accepted this revision.Apr 24 2022, 12:13 PM

LG with Jeff's comments resolved.

mlir/lib/Analysis/DataFlowAnalysis.cpp
583–589

Can you split this functor out into a separate variable? the formatting here it quite weird.

This revision is now accepted and ready to land.Apr 24 2022, 12:13 PM
krzysz00 marked 4 inline comments as done.Apr 25 2022, 11:32 AM
krzysz00 updated this revision to Diff 424985.Apr 25 2022, 11:33 AM

Address review feedback, fire off tests before landing