Author: Wael Yehia
Date: 2025-02-24T17:17:14-05:00
New Revision: d6ec32c8f25975ae31ec9ca7e67d942adadc3898

URL: 
https://github.com/llvm/llvm-project/commit/d6ec32c8f25975ae31ec9ca7e67d942adadc3898
DIFF: 
https://github.com/llvm/llvm-project/commit/d6ec32c8f25975ae31ec9ca7e67d942adadc3898.diff

LOG: [profile] runtime counter relocation is needed on windows-msvc targets 
(#127858)

Continuous profile syncing is supported on windows, and it also relies on 
runtime counter relocation (based on this
test [1])

Thanks to @anhtuyenibm for pointing it out to me.

[1] 
https://github.com/llvm/llvm-project/blob/main/compiler-rt/test/profile/ContinuousSyncMode/runtime-counter-relocation.c
---------

Co-authored-by: Wael Yehia <wye...@ca.ibm.com>

Added: 
    

Modified: 
    clang/lib/Driver/ToolChains/Clang.cpp
    clang/test/Driver/fprofile-continuous.c

Removed: 
    


################################################################################
diff  --git a/clang/lib/Driver/ToolChains/Clang.cpp 
b/clang/lib/Driver/ToolChains/Clang.cpp
index 7c50970068fa9..aa83e3e36124c 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -762,7 +762,8 @@ static void addPGOAndCoverageFlags(const ToolChain &TC, 
Compilation &C,
     else {
       CmdArgs.push_back("-fprofile-continuous");
       // Platforms that require a bias variable:
-      if (T.isOSBinFormatELF() || T.isOSAIX()) {
+      if (T.isOSBinFormatELF() || T.isOSAIX() ||
+          T.isKnownWindowsMSVCEnvironment()) {
         CmdArgs.push_back("-mllvm");
         CmdArgs.push_back("-runtime-counter-relocation");
       }

diff  --git a/clang/test/Driver/fprofile-continuous.c 
b/clang/test/Driver/fprofile-continuous.c
index 81719fb70cb1e..cc8e56c8f9fe0 100644
--- a/clang/test/Driver/fprofile-continuous.c
+++ b/clang/test/Driver/fprofile-continuous.c
@@ -6,6 +6,7 @@
 
 // RUN: %clang --target=powerpc64-ibm-aix -fprofile-generate 
-fprofile-continuous -### -c %s 2>&1 | FileCheck %s --check-prefix=RELOC
 // RUN: %clang --target=x86_64-unknown-fuchsia -fprofile-generate 
-fprofile-continuous -### -c %s 2>&1 | FileCheck %s --check-prefix=RELOC
+// RUN: %clang --target=x86_64-windows-msvc -fprofile-generate 
-fprofile-continuous -### -c %s 2>&1 | FileCheck %s --check-prefix=RELOC
 // RELOC: "-cc1" {{.*}} "-fprofile-continuous" "-mllvm" 
"-runtime-counter-relocation"
 
 // 2) test -fprofile-continuous with cs-profile-generate and 
-fprofile-instr-generate


        
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to