From 0b90833ea8f19794e6cb5205ef0cbf61bf37c5b9 Mon Sep 17 00:00:00 2001 From: Colin Cross Date: Wed, 19 Jun 2019 23:00:20 -0700 Subject: [PATCH] Optimize sanitizerRuntimeDepsMutator sanitizerRuntimeDepsMutator only modifies the currently visited module, it can visit modules in parallel. Also, stop recursing into modules that are not static dependencies, and stop recursing if the module already has all modifications that the mutator could make. Test: m checkbuild Change-Id: I95a57f763a91940f1854ba3c587a2f70e8baba97 --- cc/cc.go | 2 +- cc/sanitize.go | 13 +++++++++++-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/cc/cc.go b/cc/cc.go index 53ec89939..1100bac6e 100644 --- a/cc/cc.go +++ b/cc/cc.go @@ -65,7 +65,7 @@ func init() { ctx.TopDown("tsan_deps", sanitizerDepsMutator(tsan)) ctx.BottomUp("tsan", sanitizerMutator(tsan)).Parallel() - ctx.TopDown("sanitize_runtime_deps", sanitizerRuntimeDepsMutator) + ctx.TopDown("sanitize_runtime_deps", sanitizerRuntimeDepsMutator).Parallel() ctx.BottomUp("sanitize_runtime", sanitizerRuntimeMutator).Parallel() ctx.BottomUp("coverage", coverageMutator).Parallel() diff --git a/cc/sanitize.go b/cc/sanitize.go index 0af06592f..3756512b4 100644 --- a/cc/sanitize.go +++ b/cc/sanitize.go @@ -701,8 +701,8 @@ func sanitizerRuntimeDepsMutator(mctx android.TopDownMutatorContext) { if !isSanitizableDependencyTag(mctx.OtherModuleDependencyTag(child)) { return false } - if d, ok := child.(*Module); ok && d.static() && d.sanitize != nil { + if d, ok := child.(*Module); ok && d.static() && d.sanitize != nil { if enableMinimalRuntime(d.sanitize) { // If a static dependency is built with the minimal runtime, // make sure we include the ubsan minimal runtime. @@ -713,8 +713,17 @@ func sanitizerRuntimeDepsMutator(mctx android.TopDownMutatorContext) { // make sure we include the ubsan runtime. c.sanitize.Properties.UbsanRuntimeDep = true } + + if c.sanitize.Properties.MinimalRuntimeDep && + c.sanitize.Properties.UbsanRuntimeDep { + // both flags that this mutator might set are true, so don't bother recursing + return false + } + + return true + } else { + return false } - return true }) } }