This is an archive of the discontinued LLVM Phabricator instance.

[clang][dataflow] Add `create<T>()` methods to `Environment` and `DataflowAnalysisContext`.
ClosedPublic

Authored by mboehme on Mar 30 2023, 11:58 PM.

Details

Summary

These methods provide a less verbose way of allocating StorageLocations and
Values than the existing takeOwnership(make_unique(...)) pattern.

In addition, because allocation of StorageLocations and Values now happens
within the DataflowAnalysisContext, the create<T>() open up the possibility
of using BumpPtrAllocator to allocate these objects if it turns out this
helps performance.

Diff Detail

Event Timeline

mboehme created this revision.Mar 30 2023, 11:58 PM
Herald added a project: Restricted Project. · View Herald Transcript
mboehme requested review of this revision.Mar 30 2023, 11:58 PM
Herald added a project: Restricted Project. · View Herald TranscriptMar 30 2023, 11:58 PM
Herald added a subscriber: cfe-commits. · View Herald Transcript
xazax.hun accepted this revision.Mar 31 2023, 8:44 AM
xazax.hun added inline comments.
clang/include/clang/Analysis/FlowSensitive/DataflowAnalysisContext.h
100

Would emplace back work? That returns a reference to the just emplaced element saving us the call to back making the code a bit more concise.

clang/include/clang/Analysis/FlowSensitive/DataflowEnvironment.h
328

Just curious, what is the reason for repeating the enable_if here in addition to the one in the called function? Do we get better error messages?

This revision is now accepted and ready to land.Mar 31 2023, 8:44 AM
mboehme updated this revision to Diff 510416.Apr 3 2023, 12:28 AM

Changes in response to review comments

mboehme marked an inline comment as done.Apr 3 2023, 12:33 AM
mboehme added inline comments.
clang/include/clang/Analysis/FlowSensitive/DataflowAnalysisContext.h
100

Nice -- thanks for the suggestion! Done.

clang/include/clang/Analysis/FlowSensitive/DataflowEnvironment.h
328

Yes, the idea is:

  • We get error messages from the interface of create() rather than the implementation
  • The enable_if documents intent. (The comment above states this intent too, but it's always nicer to have the code itself state the intent if possible.)
gribozavr2 accepted this revision.Apr 3 2023, 4:28 AM
ymandel accepted this revision.Apr 3 2023, 6:44 AM

Thanks!

clang/include/clang/Analysis/FlowSensitive/DataflowAnalysisContext.h
215–217

Is there any reason for this function anymore or should we deprecate it (and the Top version below)? Especially in this object which only used internally and not by clients -- the extra two characters don't seem to justify a function.

mboehme updated this revision to Diff 510496.Apr 3 2023, 7:45 AM
mboehme marked an inline comment as done.

Changes in response to review comments

mboehme marked an inline comment as done.Apr 3 2023, 7:47 AM
mboehme added inline comments.
clang/include/clang/Analysis/FlowSensitive/DataflowAnalysisContext.h
215–217

I had wondered the same thing. I've added LLVM_DEPRECATED to both.

(I'm not changing callers in this patch because I'd like to avoid expanding the size of the patch.)

This revision was automatically updated to reflect the committed changes.
mboehme marked an inline comment as done.