This is an archive of the discontinued LLVM Phabricator instance.

[clang][dataflow] Fix `Environment::join`'s handling of flow condition merging
ClosedPublic

Authored by ymandel on Apr 20 2022, 9:54 AM.

Details

Summary

The current implementation mutates the environment as it performs the
join. However, that interferes with the call to the model's merge operation,
which can modify MergedEnv. Since any modifications are assumed to apply to
the post-join environment, providing the same environment for both is
incorrect. This mismatch is a particular concern for joining the flow
conditions, where modifications in the old environment may not be propagated to
the new one.

Diff Detail

Event Timeline

ymandel created this revision.Apr 20 2022, 9:54 AM
Herald added a project: Restricted Project. · View Herald TranscriptApr 20 2022, 9:54 AM
ymandel requested review of this revision.Apr 20 2022, 9:54 AM
Herald added a project: Restricted Project. · View Herald TranscriptApr 20 2022, 9:54 AM
ymandel retitled this revision from [clang][dataflow] Fix join implementation to handle flow conditions correctly. to [clang][dataflow] Fix `Environment::join`'s handling of flow condition merging.Apr 20 2022, 11:04 AM
ymandel edited the summary of this revision. (Show Details)Apr 20 2022, 11:10 AM
xazax.hun accepted this revision.Apr 20 2022, 12:52 PM
xazax.hun added inline comments.
clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp
69

Typo: Val2.

72–73

Would it make sense to make Env1 const?

This revision is now accepted and ready to land.Apr 20 2022, 12:52 PM
ymandel updated this revision to Diff 424045.Apr 20 2022, 3:11 PM

address review comments

ymandel marked 2 inline comments as done.Apr 20 2022, 3:12 PM

Thanks!

sgatev accepted this revision.Apr 24 2022, 11:05 PM
sgatev added inline comments.
clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp
334–335

This comment is no longer relevant, right?

clang/unittests/Analysis/FlowSensitive/TypeErasedDataflowAnalysisTest.cpp
299
340–344
356

That's guaranteed to be false in compareEquivalent.

364–368
414
422

Add /*[[p3]]*/ after this statement and ensure that the value is implied in the "else" branch.

ymandel updated this revision to Diff 424909.Apr 25 2022, 7:56 AM

address comments

ymandel marked 7 inline comments as done.Apr 25 2022, 7:57 AM
ymandel added inline comments.
clang/unittests/Analysis/FlowSensitive/TypeErasedDataflowAnalysisTest.cpp
356

I thought just Val1 == Val2 was guaranteed false? Also, I see that the variable naming could be confusing, so I've renamed.

sgatev accepted this revision.Apr 25 2022, 8:03 AM
sgatev added inline comments.
clang/unittests/Analysis/FlowSensitive/TypeErasedDataflowAnalysisTest.cpp
356

Right. I think I misread it. Having IsSet1 == IsSet2 here makes sense to me. Though, if the test only needs the second part, I suggest removing this to simplify the setup.

ymandel updated this revision to Diff 424916.Apr 25 2022, 8:06 AM
ymandel marked an inline comment as done.

address comments

ymandel marked an inline comment as done.Apr 25 2022, 8:06 AM
ymandel added inline comments.
clang/unittests/Analysis/FlowSensitive/TypeErasedDataflowAnalysisTest.cpp
356

agreed. done

This revision was landed with ongoing or failed builds.Apr 25 2022, 8:07 AM
This revision was automatically updated to reflect the committed changes.
ymandel marked an inline comment as done.