-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[profile] runtime counter relocation is needed on windows-msvc targets #127858
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
@llvm/pr-subscribers-clang @llvm/pr-subscribers-clang-driver Author: Wael Yehia (w2yehia) ChangesContinuous profiling syncing is supported on windows, and it also relies on runtime counter relocation (based on this test) Thanks to @anhtuyenibm for pointing it out to me. Full diff: https://github.com/llvm/llvm-project/pull/127858.diff 2 Files Affected:
diff --git a/clang/lib/Driver/ToolChains/Clang.cpp b/clang/lib/Driver/ToolChains/Clang.cpp
index 96af466e067a8..3f76d034ee308 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -795,7 +795,7 @@ 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
|
✅ With the latest revision this PR passed the C/C++ code formatter. |
Doesn't mingw target support it? |
Sorry I don't know. I was hoping someone familiar with clang on windows to comment. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for pointing out this reference page. The changes look good to me.
I'm pretty sure that profiling already works, both in mingw and MSVC configurations. I'm not familiar with all the nuances in various forms of profiling though, so it's unclear to me if this is some specific fringe configuration which didn't work before, or what this change actually changes. Can you summarize the high level use case which didn't work before, and in which way it used to fail before, which gets fixed by this change? |
Continuous profiling (that is continuous profile syncing to disk) is an existing feature, which is OFF by default on most platforms. What I added, in a previous PR (#124353), was a clang option (-fprofile-continuous) to enable the feature and take care of the nuances of setting up the compiler and runtime: (1) override the profile file name by appending '%c' into it, and (2) pass |
Thanks for the very thorough explanation!
I see! With this, I was able to test the feature in a mingw configuration, and I do get |
Thanks for checking. I can fix the condition but can you please let me know which of the two options you listed is better? |
I don't entirely know as I'm not familiar with what |
…127858) See PR comments for the discussion that led to this commit.
@mstorsjo FYI: 9ef7287d425 |
Thank you! |
Continuous profiling syncing is supported on windows, and it also relies on runtime counter relocation (based on this test)
Thanks to @anhtuyenibm for pointing it out to me.