From a77a739abcfa1c5734d374e1afb51cebdb6f36bd Mon Sep 17 00:00:00 2001 From: Vedant Kumar Date: Mon, 26 Oct 2020 16:23:06 -0700 Subject: [PATCH] [profile] Suppress spurious 'expected profile to require unlock' warning In %c (continuous sync) mode, avoid attempting to unlock an already-unlocked profile. The profile is only locked when profile merging is enabled. --- compiler-rt/lib/profile/InstrProfilingFile.c | 3 ++- compiler-rt/test/profile/ContinuousSyncMode/multiple-DSOs.c | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/compiler-rt/lib/profile/InstrProfilingFile.c b/compiler-rt/lib/profile/InstrProfilingFile.c index b43f91794e28..bd1ec44fc77e 100644 --- a/compiler-rt/lib/profile/InstrProfilingFile.c +++ b/compiler-rt/lib/profile/InstrProfilingFile.c @@ -668,7 +668,8 @@ static void initializeProfileForContinuousMode(void) { FileOffsetToCounters); } - unlockProfile(&ProfileRequiresUnlock, File); + if (ProfileRequiresUnlock) + unlockProfile(&ProfileRequiresUnlock, File); #endif // defined(__Fuchsia__) || defined(_WIN32) } diff --git a/compiler-rt/test/profile/ContinuousSyncMode/multiple-DSOs.c b/compiler-rt/test/profile/ContinuousSyncMode/multiple-DSOs.c index b56b923a3200..da42500df616 100644 --- a/compiler-rt/test/profile/ContinuousSyncMode/multiple-DSOs.c +++ b/compiler-rt/test/profile/ContinuousSyncMode/multiple-DSOs.c @@ -5,7 +5,7 @@ // RUN: %clang_pgogen -dynamiclib -o %t.dso1.dylib %t.dso1.c // RUN: %clang_pgogen -dynamiclib -o %t.dso2.dylib %t.dso2.c // RUN: %clang_pgogen -o %t.exe %s %t.dso1.dylib %t.dso2.dylib -// RUN: env LLVM_PROFILE_FILE="%c%t.profraw" %run %t.exe +// RUN: env LLVM_PROFILE_FILE="%c%t.profraw" %run %t.exe 2>&1 | count 0 // RUN: llvm-profdata show --counts --all-functions %t.profraw | FileCheck %s // CHECK-LABEL: Counters: