This is an archive of the discontinued LLVM Phabricator instance.

[clang][dataflow] Allow disabling built-in transfer functions for CFG terminators
ClosedPublic

Authored by ymandel on Mar 15 2022, 7:01 AM.

Details

Summary

Terminators are handled specially in the transfer functions so we need an
additional check on whether the analysis has disabled built-in transfer
functions.

Diff Detail

Event Timeline

ymandel created this revision.Mar 15 2022, 7:01 AM
Herald added a project: Restricted Project. · View Herald TranscriptMar 15 2022, 7:01 AM
ymandel requested review of this revision.Mar 15 2022, 7:01 AM
Herald added a project: Restricted Project. · View Herald TranscriptMar 15 2022, 7:01 AM
sgatev accepted this revision.Mar 15 2022, 7:34 AM
This revision is now accepted and ready to land.Mar 15 2022, 7:34 AM
xazax.hun accepted this revision.Mar 15 2022, 7:45 AM

The change itself looks good. But out of curiosity, could you give me an example when we do not want to use the builtin transfer functions?

The change itself looks good. But out of curiosity, could you give me an example when we do not want to use the builtin transfer functions?

Sure! Pretty much any plain-vanilla dataflow analysis that sticks to its own lattice and doesn't care about the environment. The demo constant-propagation analyses are like this, but we have additional real analyses using the framework in this way. Examples include an analysis to detect raw pointers that could be unique pointers and one that detects missed opportunies to use std::move.

This revision was landed with ongoing or failed builds.Mar 15 2022, 8:11 AM
This revision was automatically updated to reflect the committed changes.

The change itself looks good. But out of curiosity, could you give me an example when we do not want to use the builtin transfer functions?

Sure! Pretty much any plain-vanilla dataflow analysis that sticks to its own lattice and doesn't care about the environment. The demo constant-propagation analyses are like this, but we have additional real analyses using the framework in this way. Examples include an analysis to detect raw pointers that could be unique pointers and one that detects missed opportunies to use std::move.

Makes sense! Although, I wonder if we would want an alternative API where the transfer function would not even get Env as an argument. So users could pick the right class to derive from for their needs and the decision whether use the built-in transfer functions would be compile time.

The change itself looks good. But out of curiosity, could you give me an example when we do not want to use the builtin transfer functions?

Sure! Pretty much any plain-vanilla dataflow analysis that sticks to its own lattice and doesn't care about the environment. The demo constant-propagation analyses are like this, but we have additional real analyses using the framework in this way. Examples include an analysis to detect raw pointers that could be unique pointers and one that detects missed opportunies to use std::move.

Makes sense! Although, I wonder if we would want an alternative API where the transfer function would not even get Env as an argument. So users could pick the right class to derive from for their needs and the decision whether use the built-in transfer functions would be compile time.

That would make sense. We definitely don't want to stick w/ the current setup. But, we've been thinking that we can split out Env and its transfer functions as a standalone "model" that users can choose to compose with their own (more specialized) model. I'm planning to send a patch shortly with an initial API for "models" (basically, a virtual API corresponding to DataflowAnalysis as of now).