This is an archive of the discontinued LLVM Phabricator instance.

[llvm][PassSupport] don't require passes to be default constructible
ClosedPublic

Authored by nickdesaulniers on Dec 19 2022, 1:34 PM.

Details

Summary

Quite a few passes are not default constructible. In order to properly
support -{start|stop}-{before|after}= for these passes, we would like to
continue to use INITIALIZE_PASS, but not necessarily provide a default
constructor.

Delete the default constructors of classes derived from
SelectionDAGISel.

Diff Detail

Event Timeline

Herald added a project: Restricted Project. · View Herald TranscriptDec 19 2022, 1:34 PM
nickdesaulniers requested review of this revision.Dec 19 2022, 1:34 PM
Herald added a project: Restricted Project. · View Herald TranscriptDec 19 2022, 1:35 PM
nickdesaulniers edited the summary of this revision. (Show Details)
  • more AMDGPU fixes
arsenm added inline comments.Dec 19 2022, 1:48 PM
llvm/include/llvm/PassSupport.h
92

Should just be llvm_unreachable? Is this checked anywhere?

nickdesaulniers planned changes to this revision.Dec 19 2022, 1:51 PM

it builds, but tests crash pretty hard...

  • fix crashes (don't touch non-SelectionDAGISel derived classes)
nickdesaulniers marked an inline comment as done.
  • add llvm_unreachable
llvm/include/llvm/PassSupport.h
92

Looks like that would be called if you run the pass with opt and LPM: opt -<passname>.

efriedma added inline comments.Dec 19 2022, 2:36 PM
llvm/include/llvm/PassSupport.h
92

Please use report_fatal_error for codepaths that might actually be reachable.

llvm/lib/Target/AMDGPU/AMDGPUISelDAGToDAG.h
96–98

I don't think there's any point to explicitly deleting the default constructor (here and elsewhere); there's no implicitly-declared default constructor if there's an explicit constructor.

  • report_fatal_error
nickdesaulniers marked an inline comment as done.Dec 19 2022, 2:45 PM
nickdesaulniers added inline comments.
llvm/lib/Target/AMDGPU/AMDGPUISelDAGToDAG.h
96–98

@arsenm from discord:

really the default constructor should be deleted

@arsenm WDYT? (I don't care either way; but I'd prefer agreement between you and @efriedma on how I should proceed).

arsenm added inline comments.Dec 19 2022, 2:47 PM
llvm/lib/Target/AMDGPU/AMDGPUISelDAGToDAG.h
96–98

I don't particularly care as long as there's no way to default construct. = delete just makes it clear that you shouldn't add it

nickdesaulniers planned changes to this revision.Dec 19 2022, 2:51 PM
nickdesaulniers marked 2 inline comments as done.
nickdesaulniers added inline comments.
llvm/include/llvm/PassSupport.h
81–96

I can use C++14 std::enable_if_t to make this slightly more concise here.

llvm/lib/Target/AMDGPU/AMDGPUISelDAGToDAG.h
96–98

I also prefer being explicit rather than try to remember the rule of 5 or 7 or gang of 4 or whatever. Marking this thread as done, but please re-comment/re-open @efriedma if you feel strongly otherwise.

nickdesaulniers marked an inline comment as done.
  • replace with enable_if w/ enable_if_t (c++14)
  • git clang-format HEAD~
This revision is now accepted and ready to land.Dec 19 2022, 3:09 PM
arsenm added inline comments.Dec 20 2022, 11:10 AM
llvm/include/llvm/PassSupport.h
95

Dead return

  • delete dead return
nickdesaulniers marked an inline comment as done.Dec 20 2022, 1:46 PM
This revision was landed with ongoing or failed builds.Dec 20 2022, 2:08 PM
This revision was automatically updated to reflect the committed changes.