[MemProf] Clean up MemProf instrumentation pass invocation
authorTeresa Johnson <tejohnson@google.com>
Fri, 26 May 2023 22:07:24 +0000 (15:07 -0700)
committerTeresa Johnson <tejohnson@google.com>
Sat, 27 May 2023 00:38:49 +0000 (17:38 -0700)
commitf354e971b09c244147ff59eb65b34487755598c0
tree4ff51d9900549c7f2eb03849b031a399f6930f8a
parentb1b04ed96ac92d77ebb6de1ef8522f62ae4f517f
[MemProf] Clean up MemProf instrumentation pass invocation

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.

Differential Revision: https://reviews.llvm.org/D151593
clang/lib/CodeGen/BackendUtil.cpp
llvm/lib/Passes/PassBuilderPipelines.cpp