summaryrefslogtreecommitdiffstats
path: root/clang/lib/Frontend/CompilerInstance.cpp
diff options
context:
space:
mode:
authorBruno Cardoso Lopes <bruno.cardoso@gmail.com>2017-03-18 00:26:18 +0000
committerBruno Cardoso Lopes <bruno.cardoso@gmail.com>2017-03-18 00:26:18 +0000
commit5a0af1fcd16eb997c2405eda51b90497eaf32caa (patch)
tree282e04f36dd4e0100ac24a05f7bfe9598b9e1536 /clang/lib/Frontend/CompilerInstance.cpp
parent0e6cb1925c04a155874548ae6cd6a4db689b046f (diff)
downloadbcm5719-llvm-5a0af1fcd16eb997c2405eda51b90497eaf32caa.tar.gz
bcm5719-llvm-5a0af1fcd16eb997c2405eda51b90497eaf32caa.zip
[Modules] In case of lock timeout, fallback and build module
Duncan's r298165 introduced the PCMCache mechanism, which guarantees that locks aren't necessary anymore for correctness but only for performance, by avoiding building it twice when possible. Change the logic to avoid an error but actually build the module in case the timeout happens. Instead of an error, still emit a remark for debugging purposes. rdar://problem/30297862 llvm-svn: 298175
Diffstat (limited to 'clang/lib/Frontend/CompilerInstance.cpp')
-rw-r--r--clang/lib/Frontend/CompilerInstance.cpp17
1 files changed, 12 insertions, 5 deletions
diff --git a/clang/lib/Frontend/CompilerInstance.cpp b/clang/lib/Frontend/CompilerInstance.cpp
index 4841c103f61..f660429e49d 100644
--- a/clang/lib/Frontend/CompilerInstance.cpp
+++ b/clang/lib/Frontend/CompilerInstance.cpp
@@ -1190,10 +1190,14 @@ static bool compileAndLoadModule(CompilerInstance &ImportingInstance,
llvm::LockFileManager Locked(ModuleFileName);
switch (Locked) {
case llvm::LockFileManager::LFS_Error:
- Diags.Report(ModuleNameLoc, diag::err_module_lock_failure)
+ // PCMCache takes care of correctness and locks are only necessary for
+ // performance. Fallback to building the module in case of any lock
+ // related errors.
+ Diags.Report(ModuleNameLoc, diag::remark_module_lock_failure)
<< Module->Name << Locked.getErrorMessage();
- return false;
-
+ // Clear out any potential leftover.
+ Locked.unsafeRemoveLockFile();
+ // FALLTHROUGH
case llvm::LockFileManager::LFS_Owned:
// We're responsible for building the module ourselves.
if (!compileModuleImpl(ImportingInstance, ModuleNameLoc, Module,
@@ -1213,11 +1217,14 @@ static bool compileAndLoadModule(CompilerInstance &ImportingInstance,
case llvm::LockFileManager::Res_OwnerDied:
continue; // try again to get the lock.
case llvm::LockFileManager::Res_Timeout:
- Diags.Report(ModuleNameLoc, diag::err_module_lock_timeout)
+ // Since PCMCache takes care of correctness, we try waiting for another
+ // process to complete the build so clang does not do it done twice. If
+ // case of timeout, build it ourselves.
+ Diags.Report(ModuleNameLoc, diag::remark_module_lock_timeout)
<< Module->Name;
// Clear the lock file so that future invokations can make progress.
Locked.unsafeRemoveLockFile();
- return false;
+ continue;
}
break;
}
OpenPOWER on IntegriCloud