[NewPM][Sancov] Make Sancov a Module Pass instead of 2 Passes
authorLeonard Chan <leonardchan@google.com>
Wed, 4 Sep 2019 20:30:29 +0000 (20:30 +0000)
committerLeonard Chan <leonardchan@google.com>
Wed, 4 Sep 2019 20:30:29 +0000 (20:30 +0000)
commiteca01b031d44da54239d9956ba0acc7cf2f7798b
tree2ff56b11f8d7c54de8a6d19e9e61153ad68fabaf
parent40e3760472eae18919f4be8906869701db8f8f03
[NewPM][Sancov] Make Sancov a Module Pass instead of 2 Passes

This patch merges the sancov module and funciton passes into one module pass.

The reason for this is because we ran into an out of memory error when
attempting to run asan fuzzer on some protobufs (pc.cc files). I traced the OOM
error to the destructor of SanitizerCoverage where we only call
appendTo[Compiler]Used which calls appendToUsedList. I'm not sure where precisely
in appendToUsedList causes the OOM, but I am able to confirm that it's calling
this function *repeatedly* that causes the OOM. (I hacked sancov a bit such that
I can still create and destroy a new sancov on every function run, but only call
appendToUsedList after all functions in the module have finished. This passes, but
when I make it such that appendToUsedList is called on every sancov destruction,
we hit OOM.)

I don't think the OOM is from just adding to the SmallSet and SmallVector inside
appendToUsedList since in either case for a given module, they'll have the same
max size. I suspect that when the existing llvm.compiler.used global is erased,
the memory behind it isn't freed. I could be wrong on this though.

This patch works around the OOM issue by just calling appendToUsedList at the
end of every module run instead of function run. The same amount of constants
still get added to llvm.compiler.used, abd we make the pass usage and logic
simpler by not having any inter-pass dependencies.

Differential Revision: https://reviews.llvm.org/D66988

llvm-svn: 370971
37 files changed:
clang/lib/CodeGen/BackendUtil.cpp
llvm/include/llvm/InitializePasses.h
llvm/include/llvm/Transforms/Instrumentation/SanitizerCoverage.h
llvm/lib/Passes/PassRegistry.def
llvm/lib/Transforms/Instrumentation/Instrumentation.cpp
llvm/lib/Transforms/Instrumentation/SanitizerCoverage.cpp
llvm/test/Instrumentation/SanitizerCoverage/abort-in-entry-block.ll
llvm/test/Instrumentation/SanitizerCoverage/backedge-pruning.ll
llvm/test/Instrumentation/SanitizerCoverage/chains.ll
llvm/test/Instrumentation/SanitizerCoverage/cmp-tracing-api-x86_32.ll
llvm/test/Instrumentation/SanitizerCoverage/cmp-tracing-api-x86_64.ll
llvm/test/Instrumentation/SanitizerCoverage/cmp-tracing.ll
llvm/test/Instrumentation/SanitizerCoverage/coff-comdat.ll
llvm/test/Instrumentation/SanitizerCoverage/coff-pc-table-inline-8bit-counters.ll
llvm/test/Instrumentation/SanitizerCoverage/coff-used-ctor.ll
llvm/test/Instrumentation/SanitizerCoverage/const-cmp-tracing.ll
llvm/test/Instrumentation/SanitizerCoverage/coverage-dbg.ll
llvm/test/Instrumentation/SanitizerCoverage/coverage.ll
llvm/test/Instrumentation/SanitizerCoverage/coverage2-dbg.ll
llvm/test/Instrumentation/SanitizerCoverage/div-tracing.ll
llvm/test/Instrumentation/SanitizerCoverage/gep-tracing.ll
llvm/test/Instrumentation/SanitizerCoverage/inline-8bit-counters.ll
llvm/test/Instrumentation/SanitizerCoverage/interposable-symbol-nocomdat.ll
llvm/test/Instrumentation/SanitizerCoverage/no-func.ll
llvm/test/Instrumentation/SanitizerCoverage/pc-table.ll
llvm/test/Instrumentation/SanitizerCoverage/postdominator_check.ll
llvm/test/Instrumentation/SanitizerCoverage/seh.ll
llvm/test/Instrumentation/SanitizerCoverage/stack-depth-variable-declared-by-user.ll
llvm/test/Instrumentation/SanitizerCoverage/stack-depth.ll
llvm/test/Instrumentation/SanitizerCoverage/switch-tracing.ll
llvm/test/Instrumentation/SanitizerCoverage/trace-pc-guard-comdat.ll
llvm/test/Instrumentation/SanitizerCoverage/trace-pc-guard-inline-8bit-counters.ll
llvm/test/Instrumentation/SanitizerCoverage/trace-pc-guard-nocomdat.ll
llvm/test/Instrumentation/SanitizerCoverage/tracing-comdat.ll
llvm/test/Instrumentation/SanitizerCoverage/tracing.ll
llvm/test/Instrumentation/SanitizerCoverage/unreachable-critedge.ll
llvm/test/Instrumentation/SanitizerCoverage/wineh.ll