This is an archive of the discontinued LLVM Phabricator instance.

[MemProf] Clean up MemProf instrumentation pass invocation
ClosedPublic

Authored by tejohnson on May 26 2023, 3:12 PM.

Details

Summary

First, removes the invocation of the memprof instrumentation passes from
the end of the module simplification pass builder, where it doesn't
really belong. However, it turns out that this was never being invoked,
as it is guarded by an internal option not used anywhere (even tests).

These passes are actually added via clang under the -fmemory-profile
option. Changed this to add via the EP callback interface, similar to
the sanitizer passes. They are added to the EP for the end of the
optimization pipeline, which is roughly where they were being added
already (end of the pre-LTO link pipelines and non-LTO optimization
pipeline).

Ideally we should plumb the output file through to LLVM and set it up
there, so I have added a TODO.

Diff Detail

Event Timeline

tejohnson created this revision.May 26 2023, 3:12 PM
Herald added a project: Restricted Project. · View Herald TranscriptMay 26 2023, 3:12 PM
tejohnson requested review of this revision.May 26 2023, 3:12 PM
Herald added projects: Restricted Project, Restricted Project. · View Herald TranscriptMay 26 2023, 3:12 PM
vitalybuka added inline comments.
clang/lib/CodeGen/BackendUtil.cpp
995

if this is registerOptimizerLastEPCallback, it can be next to other sanitizers, in addSanitizers()

tejohnson added inline comments.May 26 2023, 3:18 PM
clang/lib/CodeGen/BackendUtil.cpp
995

It could be, but while it uses the sanitizer common support, it isn't logically a sanitizer. Is there an advantage to setting it up there?

vitalybuka added inline comments.May 26 2023, 3:25 PM
clang/lib/CodeGen/BackendUtil.cpp
995

no advantages.
it has runtime similar to sanitizer, so I rather thing about this as sanitizer :)

vitalybuka accepted this revision.May 26 2023, 3:29 PM

Either way is fine

This revision is now accepted and ready to land.May 26 2023, 3:29 PM
tejohnson added inline comments.May 26 2023, 3:51 PM
clang/lib/CodeGen/BackendUtil.cpp
995

Ok thanks. I think I would prefer to keep it separate, and hopefully soon address the TODO here.

This revision was landed with ongoing or failed builds.May 26 2023, 5:39 PM
This revision was automatically updated to reflect the committed changes.