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: