[PATCH] D66988: [NewPM][Sancov] Make Sancov a Module Pass instead of 2 Passes

Leonard Chan via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Aug 29 18:19:33 PDT 2019


leonardchan created this revision.
leonardchan added reviewers: chandlerc, fedor.sergeev, philip.pfaffe.
leonardchan added a project: Sanitizers.
Herald added subscribers: cfe-commits, hiraditya.
Herald added projects: clang, LLVM.

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.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D66988

Files:
  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

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D66988.218008.patch
Type: text/x-patch
Size: 60082 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190830/8b649c38/attachment-0001.bin>


More information about the llvm-commits mailing list