Run Coverage pass before other *San passes under new pass manager, round 2
authorArthur Eubanks <aeubanks@google.com>
Thu, 28 May 2020 06:12:36 +0000 (23:12 -0700)
committerArthur Eubanks <aeubanks@google.com>
Fri, 29 May 2020 00:04:47 +0000 (17:04 -0700)
commit1285e8bcac2c54ddd924ffb813b2b187467ac2a6
treed0568a7fbb5d7c26d2607b64b85097bbec303a37
parentfd1c894a4a3690b2e500bfdf71194e9cc3f1b399
Run Coverage pass before other *San passes under new pass manager, round 2

Summary:
This was attempted once before in https://reviews.llvm.org/D79698, but
was reverted due to the coverage pass running in the wrong part of the
pipeline. This commit puts it in the same place as the other sanitizers.

This changes PassBuilder.OptimizerLastEPCallbacks to work on a
ModulePassManager instead of a FunctionPassManager. That is because
SanitizerCoverage cannot (easily) be split into a module pass and a
function pass like some of the other sanitizers since in its current
implementation it conditionally inserts module constructors based on
whether or not it successfully modified functions.

This fixes compiler-rt/test/msan/coverage-levels.cpp under the new pass
manager (last check-msan test).

Currently sanitizers + LTO don't work together under the new pass
manager, so I removed tests that checked that this combination works for
sancov.

Subscribers: hiraditya, cfe-commits, llvm-commits

Tags: #clang, #llvm

Differential Revision: https://reviews.llvm.org/D80692
clang/lib/CodeGen/BackendUtil.cpp
clang/test/CodeGen/sancov-new-pm.c
llvm/include/llvm/Passes/PassBuilder.h
llvm/lib/Passes/PassBuilder.cpp
llvm/tools/opt/NewPMDriver.cpp