[Modules] Fix rebuilding an updated module for each of its consumers.
authorVolodymyr Sapsai <vsapsai@apple.com>
Wed, 28 Aug 2019 23:31:32 +0000 (23:31 +0000)
committerVolodymyr Sapsai <vsapsai@apple.com>
Wed, 28 Aug 2019 23:31:32 +0000 (23:31 +0000)
commit39c70ef6ac1d2d280abedca1b64c57dcff22b796
tree9b0c3ca1b3085b1567834f9634e0239b86518881
parentb5785156315284fcbfecf996f6303b4263309618
[Modules] Fix rebuilding an updated module for each of its consumers.

Marking a module for a rebuild when its signature differs from the
expected one causes redundant module rebuilds for incremental builds.
When a module is updated, its signature changes. But its consumers still
have the old signature and loading them will result in signature
mismatches. It will correctly cause the rebuilds for the consumers but
we don't need to rebuild the common module for each of them as it is
already up to date.

In practice this bug causes longer build times. We are doing more work
than required and only a single process can build a module, so parallel
builds degrade to a single-process mode where extra processes are just
waiting on a file lock.

Fix by not marking a module dependency for a rebuild on signature
mismatch. We'll check if it is up to date when we load it.

rdar://problem/50212358

Reviewers: dexonsmith, bruno, rsmith

Reviewed By: dexonsmith, bruno

Subscribers: jkorous, ributzka, cfe-commits, aprantl

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@370274 91177308-0d34-0410-b5e6-96231b3b80d8
lib/Serialization/ModuleManager.cpp
test/Modules/Inputs/implicit-invalidate-common/A.h [new file with mode: 0644]
test/Modules/Inputs/implicit-invalidate-common/B.h [new file with mode: 0644]
test/Modules/Inputs/implicit-invalidate-common/Common.h [new file with mode: 0644]
test/Modules/Inputs/implicit-invalidate-common/module.modulemap [new file with mode: 0644]
test/Modules/implicit-invalidate-common.c [new file with mode: 0644]