[clang-tools-extra] [compiler-rt] [clang] [PGO] Exposing PGO's Counter Reset and File Dumping APIs (PR #76471)

2024-01-09 Thread Wael Yehia via cfe-commits

https://github.com/w2yehia approved this pull request.


https://github.com/llvm/llvm-project/pull/76471
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] f296b4c - [AIX] Always pass namedsects option when linking with PGO.

2022-04-21 Thread Wael Yehia via cfe-commits

Author: Wael Yehia
Date: 2022-04-21T17:01:37Z
New Revision: f296b4c444625f84be1db27cfd52a3d16387f456

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

LOG: [AIX] Always pass namedsects option when linking with PGO.

Differential Revision: https://reviews.llvm.org/D124046

Added: 


Modified: 
clang/lib/Driver/ToolChains/AIX.cpp
clang/test/Driver/aix-ld.c

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/AIX.cpp 
b/clang/lib/Driver/ToolChains/AIX.cpp
index e4bbf498b9cd6..37316a792f6d1 100644
--- a/clang/lib/Driver/ToolChains/AIX.cpp
+++ b/clang/lib/Driver/ToolChains/AIX.cpp
@@ -98,9 +98,10 @@ void aix::Linker::ConstructJob(Compilation &C, const 
JobAction &JA,
 CmdArgs.push_back("-bnoentry");
   }
 
-  // Specify PGO linker option without LTO
-  if (!D.isUsingLTO() &&
-  (Args.hasFlag(options::OPT_fprofile_arcs, options::OPT_fno_profile_arcs,
+  // PGO instrumentation generates symbols belonging to special sections, and
+  // the linker needs to place all symbols in a particular section together in
+  // memory; the AIX linker does that under an option.
+  if (Args.hasFlag(options::OPT_fprofile_arcs, options::OPT_fno_profile_arcs,
 false) ||
Args.hasFlag(options::OPT_fprofile_generate,
 options::OPT_fno_profile_generate, false) ||
@@ -115,7 +116,7 @@ void aix::Linker::ConstructJob(Compilation &C, const 
JobAction &JA,
Args.hasFlag(options::OPT_fcs_profile_generate_EQ,
 options::OPT_fno_profile_generate, false) ||
Args.hasArg(options::OPT_fcreate_profile) ||
-   Args.hasArg(options::OPT_coverage)))
+   Args.hasArg(options::OPT_coverage))
 CmdArgs.push_back("-bdbg:namedsects");
 
   // Specify linker output file.

diff  --git a/clang/test/Driver/aix-ld.c b/clang/test/Driver/aix-ld.c
index 6a1b006bf1e3b..eccae132763d5 100644
--- a/clang/test/Driver/aix-ld.c
+++ b/clang/test/Driver/aix-ld.c
@@ -692,7 +692,7 @@
 // CHECK-PGO-LTO: "-resource-dir" "[[RESOURCE_DIR:[^"]+]]"
 // CHECK-PGO-LTO: "-isysroot" "[[SYSROOT:[^"]+]]"
 // CHECK-PGO-LTO: "{{.*}}ld{{(.exe)?}}"
-// CHECK-PGO-LTO-NOT: "-bdbg:namedsects"
+// CHECK-PGO-LTO: "-bdbg:namedsects"
 // CHECK-PGO-LTO: "-b32"
 // CHECK-PGO-LTO: "-bpT:0x1000" "-bpD:0x2000"
 // CHECK-PGO-LTO: "[[SYSROOT]]/usr/lib{{/|}}crt0.o"



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


[clang] 2407c13 - [AIX][PGO] Enable linux style PGO on AIX

2022-05-04 Thread Wael Yehia via cfe-commits

Author: Wael Yehia
Date: 2022-05-05T04:10:39Z
New Revision: 2407c13aa4a42f3a3438ae2d03fa38df0a5fd30b

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

LOG: [AIX][PGO] Enable linux style PGO on AIX

This patch switches the PGO implementation on AIX from using the runtime
registration-based section tracking to the __start_SECNAME/__stop_SECNAME
based. In order to enable the recognition of __start_SECNAME/__stop_SECNAME
symbols in the AIX linker, the -bdbg:namedsects:ss needs to be used.

Reviewed By: jsji, MaskRay, davidxl

Differential Revision: https://reviews.llvm.org/D124857

Added: 


Modified: 
clang/lib/Driver/ToolChains/AIX.cpp
clang/test/Driver/aix-ld.c
compiler-rt/lib/profile/InstrProfilingPlatformLinux.c
compiler-rt/lib/profile/InstrProfilingPlatformOther.c
llvm/lib/Transforms/Instrumentation/InstrProfiling.cpp
llvm/test/Instrumentation/InstrProfiling/platform.ll
llvm/test/Instrumentation/InstrProfiling/profiling.ll

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/AIX.cpp 
b/clang/lib/Driver/ToolChains/AIX.cpp
index 37316a792f6d12..878b84a777027c 100644
--- a/clang/lib/Driver/ToolChains/AIX.cpp
+++ b/clang/lib/Driver/ToolChains/AIX.cpp
@@ -117,7 +117,7 @@ void aix::Linker::ConstructJob(Compilation &C, const 
JobAction &JA,
 options::OPT_fno_profile_generate, false) ||
Args.hasArg(options::OPT_fcreate_profile) ||
Args.hasArg(options::OPT_coverage))
-CmdArgs.push_back("-bdbg:namedsects");
+CmdArgs.push_back("-bdbg:namedsects:ss");
 
   // Specify linker output file.
   assert((Output.isFilename() || Output.isNothing()) && "Invalid output.");

diff  --git a/clang/test/Driver/aix-ld.c b/clang/test/Driver/aix-ld.c
index eccae132763d5e..3f4784daa1e3eb 100644
--- a/clang/test/Driver/aix-ld.c
+++ b/clang/test/Driver/aix-ld.c
@@ -664,7 +664,7 @@
 // CHECK-PGO-NON-LTO: "-resource-dir" "[[RESOURCE_DIR:[^"]+]]"
 // CHECK-PGO-NON-LTO: "-isysroot" "[[SYSROOT:[^"]+]]"
 // CHECK-PGO-NON-LTO: "{{.*}}ld{{(.exe)?}}"
-// CHECK-PGO-NON-LTO: "-bdbg:namedsects"
+// CHECK-PGO-NON-LTO: "-bdbg:namedsects:ss"
 // CHECK-PGO-NON-LTO: "-b32"
 // CHECK-PGO-NON-LTO: "-bpT:0x1000" "-bpD:0x2000"
 // CHECK-PGO-NON-LTO: "[[SYSROOT]]/usr/lib{{/|}}crt0.o"
@@ -692,7 +692,7 @@
 // CHECK-PGO-LTO: "-resource-dir" "[[RESOURCE_DIR:[^"]+]]"
 // CHECK-PGO-LTO: "-isysroot" "[[SYSROOT:[^"]+]]"
 // CHECK-PGO-LTO: "{{.*}}ld{{(.exe)?}}"
-// CHECK-PGO-LTO: "-bdbg:namedsects"
+// CHECK-PGO-LTO: "-bdbg:namedsects:ss"
 // CHECK-PGO-LTO: "-b32"
 // CHECK-PGO-LTO: "-bpT:0x1000" "-bpD:0x2000"
 // CHECK-PGO-LTO: "[[SYSROOT]]/usr/lib{{/|}}crt0.o"

diff  --git a/compiler-rt/lib/profile/InstrProfilingPlatformLinux.c 
b/compiler-rt/lib/profile/InstrProfilingPlatformLinux.c
index 592c09b49d4b15..3af61d24948e7c 100644
--- a/compiler-rt/lib/profile/InstrProfilingPlatformLinux.c
+++ b/compiler-rt/lib/profile/InstrProfilingPlatformLinux.c
@@ -7,10 +7,13 @@
 
\*===--===*/
 
 #if defined(__linux__) || defined(__FreeBSD__) || defined(__Fuchsia__) || \
-(defined(__sun__) && defined(__svr4__)) || defined(__NetBSD__)
+(defined(__sun__) && defined(__svr4__)) || defined(__NetBSD__) || \
+defined(_AIX)
 
+#if !defined(_AIX)
 #include 
 #include 
+#endif
 #include 
 #include 
 
@@ -227,4 +230,43 @@ COMPILER_RT_VISIBILITY int 
__llvm_write_binary_ids(ProfDataWriter *Writer) {
 }
 #endif
 
+#if defined(_AIX)
+// Empty stubs to allow linking object files using the registration-based 
scheme
+COMPILER_RT_VISIBILITY
+void __llvm_profile_register_function(void *Data_) {}
+
+COMPILER_RT_VISIBILITY
+void __llvm_profile_register_names_function(void *NamesStart,
+uint64_t NamesSize) {}
+
+// The __start_SECNAME and __stop_SECNAME symbols (for SECNAME \in
+// {"__llvm_prf_cnts", "__llvm_prf_data", "__llvm_prf_name", 
"__llvm_prf_vnds"})
+// are always live when linking on AIX, regardless if the .o's being linked
+// reference symbols from the profile library (for example when no files were
+// compiled with -fprofile-generate). That's because these symbols are kept
+// alive through references in constructor functions that are always live in 
the
+// default linking model on AIX (-bcdtors:all). The __start_SECNAME and
+// __stop_SECNAME symbols are only resolved by the linker when the SECNAME
+// section exists. So for the scenario where the user objects have no such
+// section (i.e. when they are compiled with -fno-profile-generate), we always
+// define these zero length variables in each of the above 4 sections.
+COMPILER_RT_VISIBILITY int dummy_cnts[0] COMPILER_RT_SECT

[clang] [FatLTO] output of -ffat-lto-objects -S should be assembly. (PR #79041)

2024-01-24 Thread Wael Yehia via cfe-commits


@@ -12,14 +12,27 @@
 // CHECK-CC-S-NOT: -emit-llvm
 // CHECK-CC-S-NOT: -ffat-lto-objects
 
-/// When LTO is enabled, we expect LLVM IR output and -ffat-lto-objects to be 
passed to cc1.
+/// When fat LTO is enabled with -S, we expect asm output and 
-ffat-lto-objects to be passed to cc1.
 // RUN: %clang --target=x86_64-unknown-linux-gnu -flto -ffat-lto-objects -### 
%s -S 2>&1 | FileCheck %s -check-prefix=CHECK-CC-S-LTO
-// RUN: %clang --target=x86_64-unknown-linux-gnu -flto -ffat-lto-objects -### 
%s -S -emit-llvm 2>&1 | FileCheck %s -check-prefix=CHECK-CC-S-LTO
 // CHECK-CC-S-LTO: -cc1
 // CHECK-CC-S-LTO-SAME: -funified-lto
-// CHECK-CC-S-LTO-SAME: -emit-llvm
+// CHECK-CC-S-NOT: -emit-llvm
 // CHECK-CC-S-LTO-SAME: -ffat-lto-objects
 
+/// When fat LTO is enabled with -S and -emit-llvm, we expect IR output and 
-ffat-lto-objects to be passed to cc1.
+// RUN: %clang --target=x86_64-unknown-linux-gnu -flto -ffat-lto-objects -### 
%s -S -emit-llvm 2>&1 | FileCheck %s -check-prefix=CHECK-CC-S-EL-LTO
+// CHECK-CC-S-EL-LTO: -cc1
+// CHECK-CC-S-EL-LTO-SAME: -funified-lto
+// CHECK-CC-S-EL-LTO-SAME: -emit-llvm
+// CHECK-CC-S-EL-LTO-SAME: -ffat-lto-objects
+
+/// When fat LTO is enabled wihtout -S we expect native object output and 
-ffat-lto-object to be passed to cc1.
+// RUN: %clang --target=x86_64-unknown-linux-gnu -flto -ffat-lto-objects -### 
%s -c 2>&1 | FileCheck %s -check-prefix=CHECK-CC-C-LTO
+// CHECK-CC-C-LTO: -cc1
+// CHECK-CC-C-LTO: -funified-lto

w2yehia wrote:

should these be CHECK-CC-C-LTO-SAME ?

https://github.com/llvm/llvm-project/pull/79041
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[compiler-rt] [clang-tools-extra] [clang] [PGO] Reland PGO's Counter Reset and File Dumping APIs #76471 (PR #78285)

2024-01-22 Thread Wael Yehia via cfe-commits




w2yehia wrote:

will need instructions for how to recreate this file in the future.

https://github.com/llvm/llvm-project/pull/78285
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [compiler-rt] [clang-tools-extra] [PGO] Reland PGO's Counter Reset and File Dumping APIs #76471 (PR #78285)

2024-01-22 Thread Wael Yehia via cfe-commits

w2yehia wrote:

@qiongsiwu explained to me offline that the issue on Windows is that calls 
__llvm_orderfile_dump fail so he's not able to execute the instrumented program 
if it calls that function.
Regarding the `compiler-rt/test/profile/instrprof-api.c` test. The disadvantage 
of having a profdata file is that it's hard to debug/reproduce; the Inputs 
directory currently has no profdata files, it's all source/text files. So, it's 
better to avoid storing the profdata.
We can disable the test on Windows.
Or keep the Windows coverage and `#ifdef` the `__llvm_orderfile_dump` API call 
on Windows (which will require versioning the expected output using LIT 
substitution magic).






https://github.com/llvm/llvm-project/pull/78285
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] [clang] [compiler-rt] [PGO] Reland PGO's Counter Reset and File Dumping APIs #76471 (PR #78285)

2024-01-22 Thread Wael Yehia via cfe-commits

https://github.com/w2yehia approved this pull request.


https://github.com/llvm/llvm-project/pull/78285
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] [Docs][LTO] Updated HowToSubmitABug.rst for LTO crashes (PR #68389)

2023-10-19 Thread Wael Yehia via cfe-commits

https://github.com/w2yehia approved this pull request.


https://github.com/llvm/llvm-project/pull/68389
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 0850655 - Big-endian version of vpermxor

2021-11-30 Thread Wael Yehia via cfe-commits

Author: Tarique Islam
Date: 2021-11-30T22:49:55Z
New Revision: 0850655da69a700b7def4fe8d9a44d1c8d55877c

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

LOG: Big-endian version of vpermxor

A big-endian version of vpermxor, named vpermxor_be, is added to LLVM
and Clang. vpermxor_be can be called directly on both the little-endian
and the big-endian platforms.

Reviewed By: nemanjai

Differential Revision: https://reviews.llvm.org/D114540

Added: 
llvm/test/CodeGen/PowerPC/crypto_bifs_be.ll

Modified: 
clang/include/clang/Basic/BuiltinsPPC.def
clang/test/CodeGen/builtins-ppc-crypto.c
llvm/include/llvm/IR/IntrinsicsPowerPC.td
llvm/lib/Target/PowerPC/PPCInstrVSX.td

Removed: 




diff  --git a/clang/include/clang/Basic/BuiltinsPPC.def 
b/clang/include/clang/Basic/BuiltinsPPC.def
index 4ba23f8f3139b..70b0184f199f8 100644
--- a/clang/include/clang/Basic/BuiltinsPPC.def
+++ b/clang/include/clang/Basic/BuiltinsPPC.def
@@ -404,6 +404,7 @@ BUILTIN(__builtin_altivec_vbpermd, "V2ULLiV2ULLiV16Uc", "")
 // P8 Crypto built-ins.
 BUILTIN(__builtin_altivec_crypto_vsbox, "V2ULLiV2ULLi", "")
 BUILTIN(__builtin_altivec_crypto_vpermxor, "V16UcV16UcV16UcV16Uc", "")
+BUILTIN(__builtin_altivec_crypto_vpermxor_be, "V16UcV16UcV16UcV16Uc", "")
 BUILTIN(__builtin_altivec_crypto_vshasigmaw, "V4UiV4UiIiIi", "")
 BUILTIN(__builtin_altivec_crypto_vshasigmad, "V2ULLiV2ULLiIiIi", "")
 BUILTIN(__builtin_altivec_crypto_vcipher, "V2ULLiV2ULLiV2ULLi", "")

diff  --git a/clang/test/CodeGen/builtins-ppc-crypto.c 
b/clang/test/CodeGen/builtins-ppc-crypto.c
index 3ebccfd23efb2..136930523c8ec 100644
--- a/clang/test/CodeGen/builtins-ppc-crypto.c
+++ b/clang/test/CodeGen/builtins-ppc-crypto.c
@@ -132,6 +132,62 @@ vector unsigned char test_vpermxoruc(vector unsigned char 
a,
 // CHECK: @llvm.ppc.altivec.crypto.vpermxor
 }
 
+// CHECK-LABEL: define{{.*}} <16 x i8> @test_vpermxorb_be
+vector unsigned char test_vpermxorb_be(vector unsigned char a,
+   vector unsigned char b,
+   vector unsigned char c) {
+  return __builtin_altivec_crypto_vpermxor_be(a, b, c);
+// CHECK: @llvm.ppc.altivec.crypto.vpermxor.be
+}
+
+// CHECK-LABEL: define{{.*}} <8 x i16> @test_vpermxorh_be
+vector unsigned short test_vpermxorh_be(vector unsigned short a,
+vector unsigned short b,
+vector unsigned short c) {
+  return __builtin_altivec_crypto_vpermxor_be(a, b, c);
+// CHECK: @llvm.ppc.altivec.crypto.vpermxor.be
+}
+
+// CHECK-LABEL: define{{.*}} <4 x i32> @test_vpermxorw_be
+vector unsigned int test_vpermxorw_be(vector unsigned int a,
+  vector unsigned int b,
+  vector unsigned int c) {
+  return __builtin_altivec_crypto_vpermxor_be(a, b, c);
+// CHECK: @llvm.ppc.altivec.crypto.vpermxor.be
+}
+
+// CHECK-LABEL: define{{.*}} <2 x i64> @test_vpermxord_be
+vector unsigned long long test_vpermxord_be(vector unsigned long long a,
+vector unsigned long long b,
+vector unsigned long long c) {
+  return __builtin_altivec_crypto_vpermxor_be(a, b, c);
+// CHECK: @llvm.ppc.altivec.crypto.vpermxor.be
+}
+
+// CHECK-LABEL: define{{.*}} <16 x i8> @test_vpermxorbc_be
+vector bool char test_vpermxorbc_be(vector bool char a,
+vector bool char b,
+vector bool char c) {
+  return  __builtin_altivec_crypto_vpermxor_be(a, b, c);
+// CHECK: @llvm.ppc.altivec.crypto.vpermxor.be
+}
+
+// CHECK-LABEL: define{{.*}} <16 x i8> @test_vpermxorsc_be
+vector signed char test_vpermxorsc_be(vector signed char a,
+  vector signed char b,
+  vector signed char c) {
+  return  __builtin_altivec_crypto_vpermxor_be(a, b, c);
+// CHECK: @llvm.ppc.altivec.crypto.vpermxor.be
+}
+
+// CHECK-LABEL: define{{.*}} <16 x i8> @test_vpermxoruc_be
+vector unsigned char test_vpermxoruc_be(vector unsigned char a,
+vector unsigned char b,
+vector unsigned char c) {
+  return  __builtin_altivec_crypto_vpermxor_be(a, b, c);
+// CHECK: @llvm.ppc.altivec.crypto.vpermxor.be
+}
+
 // CHECK-LABEL: define{{.*}} <2 x i64> @test_vcipher
 vector unsigned long long test_vcipher(void)
 {

diff  --git a/llvm/include/llvm/IR/IntrinsicsPowerPC.td 
b/llvm/include/llvm/IR/IntrinsicsPowerPC.td
index 1d249310fc3f8..b01fa10763b83 100644
--- a/llvm/include/llvm/IR/IntrinsicsPowerPC.td
+++ b/llvm/include/llvm/IR/IntrinsicsPowerPC.td
@@ -1087,6 +1087,10 @@ let TargetPrefix = "ppc" 

[clang] 461a183 - [PGO][AIX] Improve dummy var retention and allow -bcdtors:csect linking.

2022-10-21 Thread Wael Yehia via cfe-commits

Author: Wael Yehia
Date: 2022-10-21T16:32:42Z
New Revision: 461a1836d3d77371bb6271fefd645897997a22b8

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

LOG: [PGO][AIX] Improve dummy var retention and allow -bcdtors:csect linking.

1) Use a static array of pointer to retain the dummy vars.
2) Associate liveness of the array with that of the runtime hook variable
   __llvm_profile_runtime.
3) Perform the runtime initialization through the runtime hook variable.
4) Preserve the runtime hook variable using the -u linker flag.

Reviewed By: hubert.reinterpretcast

Differential Revision: https://reviews.llvm.org/D136192

Added: 
compiler-rt/test/profile/AIX/lit.local.cfg.py
compiler-rt/test/profile/AIX/shared-bexpall-pgo.c

Modified: 
clang/lib/Driver/ToolChains/AIX.cpp
clang/lib/Driver/ToolChains/AIX.h
compiler-rt/lib/profile/InstrProfilingPlatformLinux.c
compiler-rt/lib/profile/InstrProfilingRuntime.cpp
llvm/lib/Transforms/Instrumentation/InstrProfiling.cpp
llvm/test/Instrumentation/InstrProfiling/no-counters.ll
llvm/test/Instrumentation/InstrProfiling/profiling.ll

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/AIX.cpp 
b/clang/lib/Driver/ToolChains/AIX.cpp
index 748b6a3590053..1e72f1e761e8b 100644
--- a/clang/lib/Driver/ToolChains/AIX.cpp
+++ b/clang/lib/Driver/ToolChains/AIX.cpp
@@ -13,6 +13,7 @@
 #include "clang/Driver/Options.h"
 #include "clang/Driver/SanitizerArgs.h"
 #include "llvm/Option/ArgList.h"
+#include "llvm/ProfileData/InstrProf.h"
 #include "llvm/Support/Path.h"
 
 using AIX = clang::driver::toolchains::AIX;
@@ -348,6 +349,16 @@ void AIX::AddCXXStdlibLibArgs(const llvm::opt::ArgList 
&Args,
   llvm_unreachable("Unexpected C++ library type; only libc++ is supported.");
 }
 
+void AIX::addProfileRTLibs(const llvm::opt::ArgList &Args,
+   llvm::opt::ArgStringList &CmdArgs) const {
+  // Add linker option -u__llvm_profile_runtime to cause runtime
+  // initialization to occur.
+  if (needsProfileRT(Args))
+CmdArgs.push_back(Args.MakeArgString(
+Twine("-u", llvm::getInstrProfRuntimeHookVarName(;
+  ToolChain::addProfileRTLibs(Args, CmdArgs);
+}
+
 ToolChain::CXXStdlibType AIX::GetDefaultCXXStdlibType() const {
   return ToolChain::CST_Libcxx;
 }

diff  --git a/clang/lib/Driver/ToolChains/AIX.h 
b/clang/lib/Driver/ToolChains/AIX.h
index c9948a65b89ab..e03aebcc3e7f0 100644
--- a/clang/lib/Driver/ToolChains/AIX.h
+++ b/clang/lib/Driver/ToolChains/AIX.h
@@ -80,6 +80,9 @@ class LLVM_LIBRARY_VISIBILITY AIX : public ToolChain {
   void AddCXXStdlibLibArgs(const llvm::opt::ArgList &Args,
llvm::opt::ArgStringList &CmdArgs) const override;
 
+  void addProfileRTLibs(const llvm::opt::ArgList &Args,
+llvm::opt::ArgStringList &CmdArgs) const override;
+
   CXXStdlibType GetDefaultCXXStdlibType() const override;
 
   RuntimeLibType GetDefaultRuntimeLibType() const override;

diff  --git a/compiler-rt/lib/profile/InstrProfilingPlatformLinux.c 
b/compiler-rt/lib/profile/InstrProfilingPlatformLinux.c
index 3af61d24948e7..adf4132c6b4d6 100644
--- a/compiler-rt/lib/profile/InstrProfilingPlatformLinux.c
+++ b/compiler-rt/lib/profile/InstrProfilingPlatformLinux.c
@@ -250,23 +250,21 @@ void __llvm_profile_register_names_function(void 
*NamesStart,
 // section exists. So for the scenario where the user objects have no such
 // section (i.e. when they are compiled with -fno-profile-generate), we always
 // define these zero length variables in each of the above 4 sections.
-COMPILER_RT_VISIBILITY int dummy_cnts[0] COMPILER_RT_SECTION(
+static int dummy_cnts[0] COMPILER_RT_SECTION(
 COMPILER_RT_SEG INSTR_PROF_CNTS_SECT_NAME);
-COMPILER_RT_VISIBILITY int dummy_data[0] COMPILER_RT_SECTION(
+static int dummy_data[0] COMPILER_RT_SECTION(
 COMPILER_RT_SEG INSTR_PROF_DATA_SECT_NAME);
-COMPILER_RT_VISIBILITY const int dummy_name[0] COMPILER_RT_SECTION(
+static const int dummy_name[0] COMPILER_RT_SECTION(
 COMPILER_RT_SEG INSTR_PROF_NAME_SECT_NAME);
-COMPILER_RT_VISIBILITY int dummy_vnds[0] COMPILER_RT_SECTION(
+static int dummy_vnds[0] COMPILER_RT_SECTION(
 COMPILER_RT_SEG INSTR_PROF_VNODES_SECT_NAME);
 
-// Create a fake reference to avoid GC'ing of the dummy variables by the 
linker.
-// Ideally, we create a ".ref" of each variable inside the function
-// __llvm_profile_begin_counters(), but there's no source level construct
-// that allows us to generate that.
-__attribute__((destructor)) void keep() {
-  int volatile use = &dummy_cnts < &dummy_data && &dummy_name < &dummy_vnds;
-  (void)use;
-}
+// To avoid GC'ing of the dummy variables by the linker, reference them in an
+// array and reference the array in the runtime registration code
+// (InstrProfilin

[clang] 5e72407 - [flang] Add driver install directory to AIX toolchain program paths list.

2023-01-25 Thread Wael Yehia via cfe-commits

Author: Paul Scoropan
Date: 2023-01-26T00:39:51Z
New Revision: 5e72407635a43b8b7f85c1658b6738f023a21f03

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

LOG: [flang] Add driver install directory to AIX toolchain program paths list.

flang-new encounters an issue where its unable to invoke itself because the
install directory was missing from the program paths on AIX.

Reviewed By: w2yehia

Differential Revision: https://reviews.llvm.org/D140628

Added: 


Modified: 
clang/lib/Driver/ToolChains/AIX.cpp

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/AIX.cpp 
b/clang/lib/Driver/ToolChains/AIX.cpp
index abbd3ef6c68f3..f62b566c3946e 100644
--- a/clang/lib/Driver/ToolChains/AIX.cpp
+++ b/clang/lib/Driver/ToolChains/AIX.cpp
@@ -287,6 +287,10 @@ void aix::Linker::ConstructJob(Compilation &C, const 
JobAction &JA,
 /// AIX - AIX tool chain which can call as(1) and ld(1) directly.
 AIX::AIX(const Driver &D, const llvm::Triple &Triple, const ArgList &Args)
 : ToolChain(D, Triple, Args) {
+  getProgramPaths().push_back(getDriver().getInstalledDir());
+  if (getDriver().getInstalledDir() != getDriver().Dir)
+getProgramPaths().push_back(getDriver().Dir);
+
   ParseInlineAsmUsingAsmParser = Args.hasFlag(
   options::OPT_fintegrated_as, options::OPT_fno_integrated_as, true);
   getLibraryPaths().push_back(getDriver().SysRoot + "/usr/lib");



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


[clang] 645f6dc - [ThinLTO][AIX] Enable thinlto on AIX

2023-07-19 Thread Wael Yehia via cfe-commits

Author: Wael Yehia
Date: 2023-07-19T17:37:15Z
New Revision: 645f6dcd69a5315dbe2a6b49fdd8d356512544e8

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

LOG: [ThinLTO][AIX] Enable thinlto on AIX

Starting from AIX 7.2 TL5 SP6 and AIX 7.3 TL2 the system linker supports 
thinLTO.

Reviewed By: ZarkoCA, MaskRay

Differential Revision: https://reviews.llvm.org/D155700

Added: 


Modified: 
clang/lib/Driver/Driver.cpp
clang/lib/Driver/ToolChains/CommonArgs.cpp
clang/test/CodeGen/thinlto-backend-option.ll
clang/test/CodeGen/thinlto-emit-llvm.c
clang/test/Driver/thinlto_backend.c
clang/test/Integration/thinlto_profile_sample_accurate.c

Removed: 
clang/test/Driver/aix-unsupported-features.c



diff  --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp
index ce40df21c708dd..fc52f47df00b5d 100644
--- a/clang/lib/Driver/Driver.cpp
+++ b/clang/lib/Driver/Driver.cpp
@@ -4830,8 +4830,6 @@ void Driver::BuildJobs(Compilation &C) const {
   }
 
   const llvm::Triple &RawTriple = C.getDefaultToolChain().getTriple();
-  if (RawTriple.isOSAIX() && LTOMode == LTOK_Thin)
-Diag(diag::err_drv_clang_unsupported) << "thinLTO on AIX";
 
   // Collect the list of architectures.
   llvm::StringSet<> ArchNames;

diff  --git a/clang/lib/Driver/ToolChains/CommonArgs.cpp 
b/clang/lib/Driver/ToolChains/CommonArgs.cpp
index cc958d7376b626..358d7565f47c2e 100644
--- a/clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ b/clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -671,8 +671,11 @@ void tools::addLTOOptions(const ToolChain &ToolChain, 
const ArgList &Args,
 CmdArgs.push_back(Args.MakeArgString(
 Twine(PluginOptPrefix) + "dwo_dir=" + Output.getFilename() + "_dwo"));
 
-  if (IsThinLTO)
+  if (IsThinLTO && !IsOSAIX)
 CmdArgs.push_back(Args.MakeArgString(Twine(PluginOptPrefix) + "thinlto"));
+  else if (IsThinLTO && IsOSAIX)
+CmdArgs.push_back(Args.MakeArgString(Twine("-bdbg:thinlto")));
+
 
   StringRef Parallelism = getLTOParallelism(Args, D);
   if (!Parallelism.empty())

diff  --git a/clang/test/CodeGen/thinlto-backend-option.ll 
b/clang/test/CodeGen/thinlto-backend-option.ll
index 5490d018dede2b..b25b584a2fe1c6 100644
--- a/clang/test/CodeGen/thinlto-backend-option.ll
+++ b/clang/test/CodeGen/thinlto-backend-option.ll
@@ -6,8 +6,6 @@
 ; scenario independent of any particular backend options that may exist now or
 ; in the future.
 
-; XFAIL: target={{.*}}-aix{{.*}}
-
 ; RUN: %clang -flto=thin -c -o %t.o %s
 ; RUN: llvm-lto -thinlto -o %t %t.o
 ; RUN: not %clang_cc1 -x ir %t.o -fthinlto-index=%t.thinlto.bc -mllvm 
-nonexistent -emit-obj -o /dev/null 2>&1 | FileCheck %s -check-prefix=UNKNOWN

diff  --git a/clang/test/CodeGen/thinlto-emit-llvm.c 
b/clang/test/CodeGen/thinlto-emit-llvm.c
index ce50b38bb4c6bc..de66b12fef202c 100644
--- a/clang/test/CodeGen/thinlto-emit-llvm.c
+++ b/clang/test/CodeGen/thinlto-emit-llvm.c
@@ -1,5 +1,3 @@
-// XFAIL: target={{.*}}-aix{{.*}}
-
 // Test to ensure -emit-llvm and -emit-llvm-bc work when invoking the
 // ThinLTO backend path.
 // RUN: %clang -O2 %s -flto=thin -c -o %t.o

diff  --git a/clang/test/Driver/aix-unsupported-features.c 
b/clang/test/Driver/aix-unsupported-features.c
deleted file mode 100644
index 0004575a223ae3..00
--- a/clang/test/Driver/aix-unsupported-features.c
+++ /dev/null
@@ -1,7 +0,0 @@
-// RUN: %clang -target powerpc-ibm-aix-xcoff -### -flto=thin 2>&1 %s | \
-// RUN:   FileCheck --check-prefix=CHECKTHINLTO %s
-// RUN: %clang -target powerpc64-ibm-aix-xcoff -### -flto=thin 2>&1 %s | \
-// RUN:   FileCheck --check-prefix=CHECKTHINLTO %s
-
-// CHECKTHINLTO: error: the clang compiler does not support 'thinLTO on AIX'
-

diff  --git a/clang/test/Driver/thinlto_backend.c 
b/clang/test/Driver/thinlto_backend.c
index 26d6c6714029dc..7a3d6ede7c0da7 100644
--- a/clang/test/Driver/thinlto_backend.c
+++ b/clang/test/Driver/thinlto_backend.c
@@ -1,5 +1,3 @@
-// XFAIL: target={{.*}}-aix{{.*}}
-
 // RUN: %clang -O2 %s -flto=thin -c -o %t.o
 // RUN: llvm-lto -thinlto -o %t %t.o
 

diff  --git a/clang/test/Integration/thinlto_profile_sample_accurate.c 
b/clang/test/Integration/thinlto_profile_sample_accurate.c
index 8821ca76336f2b..b8ddde89d9dc68 100644
--- a/clang/test/Integration/thinlto_profile_sample_accurate.c
+++ b/clang/test/Integration/thinlto_profile_sample_accurate.c
@@ -1,5 +1,3 @@
-// XFAIL: target={{.*}}-aix{{.*}}
-
 // Test to ensure -emit-llvm profile-sample-accurate is honored in ThinLTO.
 // RUN: %clang -O2 %s -flto=thin -fprofile-sample-accurate -c -o %t.o
 // RUN: llvm-lto -thinlto -o %t %t.o



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


[clang] 7ec844c - [Doc][clang] Some PGO documentation improvements.

2023-07-11 Thread Wael Yehia via cfe-commits

Author: Wael Yehia
Date: 2023-07-11T16:26:48Z
New Revision: 7ec844c881a23bf0d2e4450ac9ca97091490084f

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

LOG: [Doc][clang] Some PGO documentation improvements.

Reviewed By: phosek

Differential Revision: https://reviews.llvm.org/D154239

Added: 


Modified: 
clang/docs/UsersManual.rst

Removed: 




diff  --git a/clang/docs/UsersManual.rst b/clang/docs/UsersManual.rst
index da9d0d364cd03a..14af07d35f5e1d 100644
--- a/clang/docs/UsersManual.rst
+++ b/clang/docs/UsersManual.rst
@@ -2603,7 +2603,7 @@ instrumentation:
environment variable to specify an alternate file. If non-default file name
is specified by both the environment variable and the command line option,
the environment variable takes precedence. The file name pattern specified
-   can include 
diff erent modifiers: ``%p``, ``%h``, and ``%m``.
+   can include 
diff erent modifiers: ``%p``, ``%h``, ``%m``, ``%t``, and ``%c``.
 
Any instance of ``%p`` in that file name will be replaced by the process
ID, so that you can easily distinguish the profile output from multiple
@@ -2639,6 +2639,8 @@ instrumentation:
 
  $ LLVM_PROFILE_FILE="code-%m.profraw" ./code
 
+   See `this `_ 
section
+   about the ``%t``, and ``%c`` modifiers.
 
 3. Combine profiles from multiple runs and convert the "raw" profile format to
the input expected by clang. Use the ``merge`` command of the
@@ -2700,6 +2702,8 @@ programs using the same instrumentation method as 
``-fprofile-generate``.
   the profile dumping path specified at command line, the environment variable
   ``LLVM_PROFILE_FILE`` can still be used to override
   the directory and filename for the profile file at runtime.
+  To override the path and filename at compile time, use
+  ``-Xclang -fprofile-instrument-path=/path/to/file_pattern.profraw``.
 
 .. option:: -fcs-profile-generate[=]
 



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


[clang] 534e23e - [ThinLTO][Matrix] Forward -enable-matrix flag to the LTO plugin

2023-08-31 Thread Wael Yehia via cfe-commits

Author: Wael Yehia
Date: 2023-09-01T03:17:54Z
New Revision: 534e23e47b03292f80a3c8265a88a790f610d3f5

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

LOG: [ThinLTO][Matrix] Forward -enable-matrix flag to the LTO plugin

because matrix intrinsics lowering happens at link time in ThinLTO.

Reviewed By: MaskRay

Differential Revision: https://reviews.llvm.org/D153583

Added: 
clang/test/Driver/matrix.c

Modified: 
clang/lib/Driver/ToolChains/CommonArgs.cpp

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/CommonArgs.cpp 
b/clang/lib/Driver/ToolChains/CommonArgs.cpp
index a16469f931884e..1a74a3a1e4cc1d 100644
--- a/clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ b/clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -680,6 +680,12 @@ void tools::addLTOOptions(const ToolChain &ToolChain, 
const ArgList &Args,
   else if (IsThinLTO && IsOSAIX)
 CmdArgs.push_back(Args.MakeArgString(Twine("-bdbg:thinlto")));
 
+  // Matrix intrinsic lowering happens at link time with ThinLTO. Enable
+  // LowerMatrixIntrinsicsPass, which is transitively called by
+  // buildThinLTODefaultPipeline under EnableMatrix.
+  if (IsThinLTO && Args.hasArg(options::OPT_fenable_matrix))
+CmdArgs.push_back(
+Args.MakeArgString(Twine(PluginOptPrefix) + "-enable-matrix"));
 
   StringRef Parallelism = getLTOParallelism(Args, D);
   if (!Parallelism.empty())

diff  --git a/clang/test/Driver/matrix.c b/clang/test/Driver/matrix.c
new file mode 100644
index 00..15b44ce5a4ec15
--- /dev/null
+++ b/clang/test/Driver/matrix.c
@@ -0,0 +1,8 @@
+// RUN: touch %t.o
+// RUN: %clang -flto=thin -fenable-matrix %t.o -### 
--target=powerpc64-ibm-aix-xcoff 2>&1 \
+// RUN: | FileCheck %s -check-prefix=CHECK-THINLTO-MATRIX-AIX
+// CHECK-THINLTO-MATRIX-AIX: "-bplugin_opt:-enable-matrix"
+
+// RUN: %clang -flto=thin -fenable-matrix %t.o -### 
--target=x86_64-unknown-linux 2>&1 \
+// RUN: | FileCheck %s -check-prefix=CHECK-THINLTO-MATRIX
+// CHECK-THINLTO-MATRIX: "-plugin-opt=-enable-matrix"



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


[clang] da92f2f - [AIX][Driver] Implement -mxcoff-build-id option

2023-03-27 Thread Wael Yehia via cfe-commits

Author: Wael Yehia
Date: 2023-03-27T15:36:41Z
New Revision: da92f2fb33c4e5fc570a51b0615e3d30a5b0bf8f

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

LOG: [AIX][Driver] Implement -mxcoff-build-id option

The -mxcoff-build-id=0xHEXSTRING option is an alternative to the
--build-id=0xHEXSTRING linker option that is not currently available in
the AIX linker.

If HEXSTRING is an odd number of hex digits then a '0' character is prepended.
The characters ':' and '-' are not allowed (unlike the GNU linker option).
The given build-id will be saved in the string table of the loader section.

A subsequent commit will teach the profile runtime to read and use the embedded 
id.

Reviewed By: daltenty, qiongsiwu1, stephenpeckham

Differential Revision: https://reviews.llvm.org/D146431

Added: 
clang/test/Driver/xcoff-build-id.c

Modified: 
clang/include/clang/Driver/Options.td
clang/lib/Driver/ToolChains/AIX.cpp

Removed: 




diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index 2f81f60a63995..5d2089e6b3edc 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -3905,6 +3905,8 @@ defm zvector : BoolFOption<"zvector",
 def mzvector : Flag<["-"], "mzvector">, Alias;
 def mno_zvector : Flag<["-"], "mno-zvector">, Alias;
 
+def mxcoff_build_id_EQ : Joined<["-"], "mxcoff-build-id=">, Group, 
MetaVarName<"<0xHEXSTRING>">,
+  HelpText<"On AIX, request creation of a build-id string, \"0xHEXSTRING\", in 
the string table of the loader section inside the linked binary">;
 def mignore_xcoff_visibility : Flag<["-"], "mignore-xcoff-visibility">, 
Group,
 HelpText<"Not emit the visibility attribute for asm in AIX OS or give all 
symbols 'unspecified' visibility in XCOFF object file">,
   Flags<[CC1Option]>;

diff  --git a/clang/lib/Driver/ToolChains/AIX.cpp 
b/clang/lib/Driver/ToolChains/AIX.cpp
index 711e8619d0a79..0ac261b548718 100644
--- a/clang/lib/Driver/ToolChains/AIX.cpp
+++ b/clang/lib/Driver/ToolChains/AIX.cpp
@@ -143,6 +143,22 @@ void aix::Linker::ConstructJob(Compilation &C, const 
JobAction &JA,
Args.hasArg(options::OPT_coverage))
 CmdArgs.push_back("-bdbg:namedsects:ss");
 
+  if (Arg *A =
+  Args.getLastArg(clang::driver::options::OPT_mxcoff_build_id_EQ)) {
+StringRef BuildId = A->getValue();
+if (BuildId[0] != '0' || BuildId[1] != 'x' ||
+BuildId.find_if_not(llvm::isHexDigit, 2) != StringRef::npos)
+  ToolChain.getDriver().Diag(diag::err_drv_unsupported_option_argument)
+  << A->getSpelling() << BuildId;
+else {
+  std::string LinkerFlag = "-bdbg:ldrinfo:xcoff_binary_id:0x";
+  if (BuildId.size() % 2) // Prepend a 0 if odd number of digits.
+LinkerFlag += "0";
+  LinkerFlag += BuildId.drop_front(2).lower();
+  CmdArgs.push_back(Args.MakeArgString(LinkerFlag));
+}
+  }
+
   // Specify linker output file.
   assert((Output.isFilename() || Output.isNothing()) && "Invalid output.");
   if (Output.isFilename()) {

diff  --git a/clang/test/Driver/xcoff-build-id.c 
b/clang/test/Driver/xcoff-build-id.c
new file mode 100644
index 0..5f12f5b737716
--- /dev/null
+++ b/clang/test/Driver/xcoff-build-id.c
@@ -0,0 +1,14 @@
+// RUN: touch %t.o
+// RUN: %clang --target=powerpc64-ibm-aix -### %t.o -mxcoff-build-id=0x12 2>&1 
| FileCheck %s
+// Test that:
+//  1) our ldrinfo flag comes before any user specified ldrinfo flag;
+//  2) upper case hex digits are converted to lower case;
+//  3) a zero is added when odd number of digits is specified in the HEXSTRING.
+// RUN: %clang --target=powerpc-ibm-aix -### %t.o -Wl,-bdbg:ldrinfo:FOO 
-mxcoff-build-id=0x011ffFF 2>&1 | FileCheck %s --check-prefix=OTHER
+
+// RUN: %clang --target=powerpc-ibm-aix -### %t.o -mxcoff-build-id=ff 2>&1 | 
FileCheck %s --check-prefix=BAD_INPUT
+// RUN: %clang --target=powerpc-ibm-aix -### %t.o -mxcoff-build-id=0x0z  2>&1 
| FileCheck %s --check-prefix=BAD_INPUT
+
+CHECK: "-bdbg:ldrinfo:xcoff_binary_id:0x12"
+OTHER: "-bdbg:ldrinfo:xcoff_binary_id:0x0011" {{.*}} "-bdbg:ldrinfo:FOO"
+BAD_INPUT: clang: error: unsupported argument {{.*}} to option 
'-mxcoff-build-id='



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


[clang] 256914b - [AIX] Update release notes regarding -mxcoff-build-id and the profile runtime

2023-03-28 Thread Wael Yehia via cfe-commits

Author: Wael Yehia
Date: 2023-03-28T14:53:12Z
New Revision: 256914bf1c13a7f2dc1343b9761cae15b8b37e00

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

LOG: [AIX] Update release notes regarding -mxcoff-build-id and the profile 
runtime

Added: 


Modified: 
clang/docs/ReleaseNotes.rst
llvm/docs/ReleaseNotes.rst

Removed: 




diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 34cfb8e672ef5..aabaab5ca5dc2 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -338,6 +338,11 @@ CUDA Support
 
 AIX Support
 ^^^
+- Add an AIX-only link-time option, `-mxcoff-build-id=0xHEXSTRING`, to allow 
users
+  to embed a hex id in their binary such that it's readable by the program 
itself.
+  This option is an alternative to the `--build-id=0xHEXSTRING` GNU linker 
option
+  which is currently not supported by the AIX linker.
+
 
 WebAssembly Support
 ^^^

diff  --git a/llvm/docs/ReleaseNotes.rst b/llvm/docs/ReleaseNotes.rst
index 6f78497644479..3791d5116124e 100644
--- a/llvm/docs/ReleaseNotes.rst
+++ b/llvm/docs/ReleaseNotes.rst
@@ -127,6 +127,8 @@ Changes to the PowerPC Backend
   RO data section. This option should be used with the ``-fdata-sections``
   option, and is not supported with ``-fno-data-sections``. The option is
   only supported on AIX.
+* On AIX, teach the profile runtime to check for a build-id string; such string
+  can be created by the -mxcoff-build-id option.
 
 Changes to the RISC-V Backend
 -



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


[clang] 91db11c - XFAIL thinlto testcases on AIX

2021-04-26 Thread Wael Yehia via cfe-commits

Author: Wael Yehia
Date: 2021-04-26T17:02:06Z
New Revision: 91db11c98db5de3e6079bddc0aba896ec3d3d0ad

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

LOG: XFAIL thinlto testcases on AIX

In D100350, we switched off thinLTO on the AIX OS. So, XFAIL tests that
invoke clang with -flto=thin on AIX.

Added: 


Modified: 
clang/test/CodeGen/thinlto-backend-option.ll
clang/test/CodeGen/thinlto-emit-llvm.c
clang/test/Driver/thinlto_backend.c
clang/test/Integration/thinlto_profile_sample_accurate.c

Removed: 




diff  --git a/clang/test/CodeGen/thinlto-backend-option.ll 
b/clang/test/CodeGen/thinlto-backend-option.ll
index b25b584a2fe1..556aaf9fad22 100644
--- a/clang/test/CodeGen/thinlto-backend-option.ll
+++ b/clang/test/CodeGen/thinlto-backend-option.ll
@@ -6,6 +6,8 @@
 ; scenario independent of any particular backend options that may exist now or
 ; in the future.
 
+; XFAIL: aix
+
 ; RUN: %clang -flto=thin -c -o %t.o %s
 ; RUN: llvm-lto -thinlto -o %t %t.o
 ; RUN: not %clang_cc1 -x ir %t.o -fthinlto-index=%t.thinlto.bc -mllvm 
-nonexistent -emit-obj -o /dev/null 2>&1 | FileCheck %s -check-prefix=UNKNOWN

diff  --git a/clang/test/CodeGen/thinlto-emit-llvm.c 
b/clang/test/CodeGen/thinlto-emit-llvm.c
index d6ef6650243e..dc46ae78e9b8 100644
--- a/clang/test/CodeGen/thinlto-emit-llvm.c
+++ b/clang/test/CodeGen/thinlto-emit-llvm.c
@@ -1,3 +1,5 @@
+// XFAIL: aix
+
 // Test to ensure -emit-llvm and -emit-llvm-bc work when invoking the
 // ThinLTO backend path.
 // RUN: %clang -O2 %s -flto=thin -c -o %t.o

diff  --git a/clang/test/Driver/thinlto_backend.c 
b/clang/test/Driver/thinlto_backend.c
index 7a3d6ede7c0d..64f0a7bf6785 100644
--- a/clang/test/Driver/thinlto_backend.c
+++ b/clang/test/Driver/thinlto_backend.c
@@ -1,3 +1,5 @@
+// XFAIL: aix
+
 // RUN: %clang -O2 %s -flto=thin -c -o %t.o
 // RUN: llvm-lto -thinlto -o %t %t.o
 

diff  --git a/clang/test/Integration/thinlto_profile_sample_accurate.c 
b/clang/test/Integration/thinlto_profile_sample_accurate.c
index ac7274cee2d2..b756829439cf 100644
--- a/clang/test/Integration/thinlto_profile_sample_accurate.c
+++ b/clang/test/Integration/thinlto_profile_sample_accurate.c
@@ -1,3 +1,5 @@
+// XFAIL: aix
+
 // Test to ensure -emit-llvm profile-sample-accurate is honored in ThinLTO.
 // RUN: %clang -O2 %s -flto=thin -fprofile-sample-accurate -c -o %t.o
 // RUN: llvm-lto -thinlto -o %t %t.o



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


[clang] 369c0e0 - [AIX] Diagnose thinLTO usage in clang on AIX.

2021-04-19 Thread Wael Yehia via cfe-commits

Author: Wael Yehia
Date: 2021-04-19T16:39:48Z
New Revision: 369c0e0f48dd3585566d251cc99955dbdeed84a1

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

LOG: [AIX] Diagnose thinLTO usage in clang on AIX.

Reviewed By: Xiangling Liao

Differential Revision: https://reviews.llvm.org/D100350

Added: 
clang/test/Driver/aix-unsupported-features.c

Modified: 
clang/lib/Driver/Driver.cpp

Removed: 




diff  --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp
index 39a630a7b4e8a..9a1b106673263 100644
--- a/clang/lib/Driver/Driver.cpp
+++ b/clang/lib/Driver/Driver.cpp
@@ -3998,10 +3998,13 @@ void Driver::BuildJobs(Compilation &C) const {
   }
 
   const llvm::Triple &RawTriple = C.getDefaultToolChain().getTriple();
-  if (RawTriple.isOSAIX())
+  if (RawTriple.isOSAIX()) {
 if (Arg *A = C.getArgs().getLastArg(options::OPT_G))
   Diag(diag::err_drv_unsupported_opt_for_target)
   << A->getSpelling() << RawTriple.str();
+if (LTOMode == LTOK_Thin)
+  Diag(diag::err_drv_clang_unsupported) << "thinLTO on AIX";
+  }
 
   // Collect the list of architectures.
   llvm::StringSet<> ArchNames;

diff  --git a/clang/test/Driver/aix-unsupported-features.c 
b/clang/test/Driver/aix-unsupported-features.c
new file mode 100644
index 0..0004575a223ae
--- /dev/null
+++ b/clang/test/Driver/aix-unsupported-features.c
@@ -0,0 +1,7 @@
+// RUN: %clang -target powerpc-ibm-aix-xcoff -### -flto=thin 2>&1 %s | \
+// RUN:   FileCheck --check-prefix=CHECKTHINLTO %s
+// RUN: %clang -target powerpc64-ibm-aix-xcoff -### -flto=thin 2>&1 %s | \
+// RUN:   FileCheck --check-prefix=CHECKTHINLTO %s
+
+// CHECKTHINLTO: error: the clang compiler does not support 'thinLTO on AIX'
+



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


[clang] [PGO] Add a clang option -fprofile-continuous that enables PGO continuous mode (PR #124353)

2025-02-03 Thread Wael Yehia via cfe-commits

w2yehia wrote:

I believe all comments have been addressed. 
friendly ping.
@petrhosek any feedback please?

https://github.com/llvm/llvm-project/pull/124353
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [compiler-rt] [Sanitizers] the access size (8 bytes) exceeds the max lock-free size (4 bytes) for 32-bit (PR #125388)

2025-02-05 Thread Wael Yehia via cfe-commits


@@ -1120,3 +1120,23 @@
 // RUN:-c \
 // RUN:   | FileCheck --check-prefixes=CHECK-K-UNUSED %s
 // CHECK-K-UNUSED: clang: warning: -K: 'linker' input unused 
[-Wunused-command-line-argument]
+
+
+// This test verifies that the linker doesn't include '-latomic' when no 
sanitizers are enabled 
+// Running this test on non-AIX host will result in an unrelated error 
+// FIXME: Sanitizer interface functions must be exported by export files on AIX

w2yehia wrote:

```suggestion
// FIXME: Running this test on non-AIX host will result in the following error:
// LLVM ERROR: Sanitizer interface functions must be exported by export files 
on AIX
```

https://github.com/llvm/llvm-project/pull/125388
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [compiler-rt] [Sanitizers] the access size (8 bytes) exceeds the max lock-free size (4 bytes) for 32-bit (PR #125388)

2025-02-05 Thread Wael Yehia via cfe-commits


@@ -1120,3 +1120,23 @@
 // RUN:-c \
 // RUN:   | FileCheck --check-prefixes=CHECK-K-UNUSED %s
 // CHECK-K-UNUSED: clang: warning: -K: 'linker' input unused 
[-Wunused-command-line-argument]
+
+
+// This test verifies that the linker doesn't include '-latomic' when no 
sanitizers are enabled 
+// Running this test on non-AIX host will result in an unrelated error 
+// FIXME: Sanitizer interface functions must be exported by export files on AIX

w2yehia wrote:

The 1st test doesn't crash though. The error occurs when you have -m32 and 
-fsanitize=address, so technically you don't need to make the first test aix 
specific.

https://github.com/llvm/llvm-project/pull/125388
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [compiler-rt] [Sanitizers] the access size (8 bytes) exceeds the max lock-free size (4 bytes) for 32-bit (PR #125388)

2025-02-05 Thread Wael Yehia via cfe-commits

https://github.com/w2yehia requested changes to this pull request.


https://github.com/llvm/llvm-project/pull/125388
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [compiler-rt] [Sanitizers] the access size (8 bytes) exceeds the max lock-free size (4 bytes) for 32-bit (PR #125388)

2025-02-05 Thread Wael Yehia via cfe-commits


@@ -1120,3 +1120,23 @@
 // RUN:-c \
 // RUN:   | FileCheck --check-prefixes=CHECK-K-UNUSED %s
 // CHECK-K-UNUSED: clang: warning: -K: 'linker' input unused 
[-Wunused-command-line-argument]
+
+
+// This test verifies that the linker doesn't include '-latomic' when no 
sanitizers are enabled 
+// Running this test on non-AIX host will result in an unrelated error 
+// FIXME: Sanitizer interface functions must be exported by export files on AIX

w2yehia wrote:

I tried the 2nd test on powerpcle and I see the error message:
`LLVM ERROR: Sanitizer interface functions must be exported by export files on 
AIX.`
I suggest reformatting the comment to make it clear that the FIXME is related 
to the "unrelated error". See above suggestion.


https://github.com/llvm/llvm-project/pull/125388
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [profile] Add a clang option -fprofile-continuous that enables continuous instrumentation profiling mode (PR #124353)

2025-02-08 Thread Wael Yehia via cfe-commits

https://github.com/w2yehia updated 
https://github.com/llvm/llvm-project/pull/124353

>From abef90fe8f46431a5fb8b7fe717c9fb65eb30266 Mon Sep 17 00:00:00 2001
From: Wael Yehia 
Date: Thu, 23 Jan 2025 00:03:15 +
Subject: [PATCH 1/8] [PGO] Add a clang option -fprofile-continuous that
 enables PGO continuous mode

---
 clang/docs/UsersManual.rst   |  8 
 clang/include/clang/Basic/CodeGenOptions.def |  1 +
 clang/include/clang/Driver/Options.td|  5 +++
 clang/lib/CodeGen/BackendUtil.cpp| 42 +++-
 clang/lib/Driver/ToolChains/Clang.cpp| 29 ++
 clang/test/CodeGen/profile-continuous.c  | 16 
 6 files changed, 83 insertions(+), 18 deletions(-)
 create mode 100644 clang/test/CodeGen/profile-continuous.c

diff --git a/clang/docs/UsersManual.rst b/clang/docs/UsersManual.rst
index 260e84910c6f783..1e5099067339977 100644
--- a/clang/docs/UsersManual.rst
+++ b/clang/docs/UsersManual.rst
@@ -3033,6 +3033,14 @@ indexed format, regardeless whether it is produced by 
frontend or the IR pass.
   overhead. ``prefer-atomic`` will be transformed to ``atomic`` when supported
   by the target, or ``single`` otherwise.
 
+.. option:: -fprofile-continuous
+
+  Enables continuous PGO mode where profile counter updates are continuously
+  synced to a file. This option sets any neccessary modifiers (currently 
``%c``)
+  in the default profile filename and passes any necessary flags to the
+  middle-end to support this mode. Value profiling is not supported in
+  continuous mode.
+
 .. option:: -ftemporal-profile
 
   Enables the temporal profiling extension for IRPGO to improve startup time by
diff --git a/clang/include/clang/Basic/CodeGenOptions.def 
b/clang/include/clang/Basic/CodeGenOptions.def
index 0f4ed13d5f3d8c1..bbaf8b183222e98 100644
--- a/clang/include/clang/Basic/CodeGenOptions.def
+++ b/clang/include/clang/Basic/CodeGenOptions.def
@@ -221,6 +221,7 @@ AFFECTING_VALUE_CODEGENOPT(OptimizationLevel, 2, 0) ///< 
The -O[0-3] option spec
 AFFECTING_VALUE_CODEGENOPT(OptimizeSize, 2, 0) ///< If -Os (==1) or -Oz (==2) 
is specified.
 
 CODEGENOPT(AtomicProfileUpdate , 1, 0) ///< Set -fprofile-update=atomic
+CODEGENOPT(ContinuousProfileSync, 1, 0) ///< Enable continuous PGO mode
 /// Choose profile instrumenation kind or no instrumentation.
 ENUM_CODEGENOPT(ProfileInstr, ProfileInstrKind, 2, ProfileNone)
 /// Choose profile kind for PGO use compilation.
diff --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index 2721c1b5d8dc554..5a7e64d5b5a96f3 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -1886,6 +1886,11 @@ def fprofile_update_EQ : Joined<["-"], 
"fprofile-update=">,
 Values<"atomic,prefer-atomic,single">,
 MetaVarName<"">, HelpText<"Set update method of profile counters">,
 MarshallingInfoFlag>;
+def fprofile_continuous : Flag<["-"], "fprofile-continuous">,
+Group, Visibility<[ClangOption, CC1Option]>,
+HelpText<"Enable Continuous PGO mode">,
+MarshallingInfoFlag>;
+
 defm pseudo_probe_for_profiling : BoolFOption<"pseudo-probe-for-profiling",
   CodeGenOpts<"PseudoProbeForProfiling">, DefaultFalse,
   PosFlag,
diff --git a/clang/lib/CodeGen/BackendUtil.cpp 
b/clang/lib/CodeGen/BackendUtil.cpp
index 3951ad01497ccac..afafa8af585c712 100644
--- a/clang/lib/CodeGen/BackendUtil.cpp
+++ b/clang/lib/CodeGen/BackendUtil.cpp
@@ -133,6 +133,16 @@ std::string getDefaultProfileGenName() {
  : "default_%m.profraw";
 }
 
+// Path and name of file used for profile generation
+std::string getProfileGenName(const CodeGenOptions &CodeGenOpts) {
+  std::string FileName = CodeGenOpts.InstrProfileOutput.empty()
+ ? getDefaultProfileGenName()
+ : CodeGenOpts.InstrProfileOutput;
+  if (CodeGenOpts.ContinuousProfileSync)
+FileName = "%c" + FileName;
+  return FileName;
+}
+
 class EmitAssemblyHelper {
   CompilerInstance &CI;
   DiagnosticsEngine &Diags;
@@ -550,7 +560,9 @@ getInstrProfOptions(const CodeGenOptions &CodeGenOpts,
 return std::nullopt;
   InstrProfOptions Options;
   Options.NoRedZone = CodeGenOpts.DisableRedZone;
-  Options.InstrProfileOutput = CodeGenOpts.InstrProfileOutput;
+  Options.InstrProfileOutput = CodeGenOpts.ContinuousProfileSync
+   ? ("%c" + CodeGenOpts.InstrProfileOutput)
+   : CodeGenOpts.InstrProfileOutput;
   Options.Atomic = CodeGenOpts.AtomicProfileUpdate;
   return Options;
 }
@@ -811,13 +823,12 @@ void EmitAssemblyHelper::RunOptimizationPipeline(
 
   if (CodeGenOpts.hasProfileIRInstr())
 // -fprofile-generate.
-PGOOpt = PGOOptions(
-CodeGenOpts.InstrProfileOutput.empty() ? getDefaultProfileGenName()
-   : 
CodeGenOpts.InstrProfileOutput,
-"", "", CodeGenOpts.MemoryProfileUsePath, nullptr, PGOOptions::IRInstr,
- 

[clang] [profile] Add a clang option -fprofile-continuous that enables continuous instrumentation profiling mode (PR #124353)

2025-02-08 Thread Wael Yehia via cfe-commits

https://github.com/w2yehia updated 
https://github.com/llvm/llvm-project/pull/124353

>From abef90fe8f46431a5fb8b7fe717c9fb65eb30266 Mon Sep 17 00:00:00 2001
From: Wael Yehia 
Date: Thu, 23 Jan 2025 00:03:15 +
Subject: [PATCH 1/8] [PGO] Add a clang option -fprofile-continuous that
 enables PGO continuous mode

---
 clang/docs/UsersManual.rst   |  8 
 clang/include/clang/Basic/CodeGenOptions.def |  1 +
 clang/include/clang/Driver/Options.td|  5 +++
 clang/lib/CodeGen/BackendUtil.cpp| 42 +++-
 clang/lib/Driver/ToolChains/Clang.cpp| 29 ++
 clang/test/CodeGen/profile-continuous.c  | 16 
 6 files changed, 83 insertions(+), 18 deletions(-)
 create mode 100644 clang/test/CodeGen/profile-continuous.c

diff --git a/clang/docs/UsersManual.rst b/clang/docs/UsersManual.rst
index 260e84910c6f783..1e5099067339977 100644
--- a/clang/docs/UsersManual.rst
+++ b/clang/docs/UsersManual.rst
@@ -3033,6 +3033,14 @@ indexed format, regardeless whether it is produced by 
frontend or the IR pass.
   overhead. ``prefer-atomic`` will be transformed to ``atomic`` when supported
   by the target, or ``single`` otherwise.
 
+.. option:: -fprofile-continuous
+
+  Enables continuous PGO mode where profile counter updates are continuously
+  synced to a file. This option sets any neccessary modifiers (currently 
``%c``)
+  in the default profile filename and passes any necessary flags to the
+  middle-end to support this mode. Value profiling is not supported in
+  continuous mode.
+
 .. option:: -ftemporal-profile
 
   Enables the temporal profiling extension for IRPGO to improve startup time by
diff --git a/clang/include/clang/Basic/CodeGenOptions.def 
b/clang/include/clang/Basic/CodeGenOptions.def
index 0f4ed13d5f3d8c1..bbaf8b183222e98 100644
--- a/clang/include/clang/Basic/CodeGenOptions.def
+++ b/clang/include/clang/Basic/CodeGenOptions.def
@@ -221,6 +221,7 @@ AFFECTING_VALUE_CODEGENOPT(OptimizationLevel, 2, 0) ///< 
The -O[0-3] option spec
 AFFECTING_VALUE_CODEGENOPT(OptimizeSize, 2, 0) ///< If -Os (==1) or -Oz (==2) 
is specified.
 
 CODEGENOPT(AtomicProfileUpdate , 1, 0) ///< Set -fprofile-update=atomic
+CODEGENOPT(ContinuousProfileSync, 1, 0) ///< Enable continuous PGO mode
 /// Choose profile instrumenation kind or no instrumentation.
 ENUM_CODEGENOPT(ProfileInstr, ProfileInstrKind, 2, ProfileNone)
 /// Choose profile kind for PGO use compilation.
diff --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index 2721c1b5d8dc554..5a7e64d5b5a96f3 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -1886,6 +1886,11 @@ def fprofile_update_EQ : Joined<["-"], 
"fprofile-update=">,
 Values<"atomic,prefer-atomic,single">,
 MetaVarName<"">, HelpText<"Set update method of profile counters">,
 MarshallingInfoFlag>;
+def fprofile_continuous : Flag<["-"], "fprofile-continuous">,
+Group, Visibility<[ClangOption, CC1Option]>,
+HelpText<"Enable Continuous PGO mode">,
+MarshallingInfoFlag>;
+
 defm pseudo_probe_for_profiling : BoolFOption<"pseudo-probe-for-profiling",
   CodeGenOpts<"PseudoProbeForProfiling">, DefaultFalse,
   PosFlag,
diff --git a/clang/lib/CodeGen/BackendUtil.cpp 
b/clang/lib/CodeGen/BackendUtil.cpp
index 3951ad01497ccac..afafa8af585c712 100644
--- a/clang/lib/CodeGen/BackendUtil.cpp
+++ b/clang/lib/CodeGen/BackendUtil.cpp
@@ -133,6 +133,16 @@ std::string getDefaultProfileGenName() {
  : "default_%m.profraw";
 }
 
+// Path and name of file used for profile generation
+std::string getProfileGenName(const CodeGenOptions &CodeGenOpts) {
+  std::string FileName = CodeGenOpts.InstrProfileOutput.empty()
+ ? getDefaultProfileGenName()
+ : CodeGenOpts.InstrProfileOutput;
+  if (CodeGenOpts.ContinuousProfileSync)
+FileName = "%c" + FileName;
+  return FileName;
+}
+
 class EmitAssemblyHelper {
   CompilerInstance &CI;
   DiagnosticsEngine &Diags;
@@ -550,7 +560,9 @@ getInstrProfOptions(const CodeGenOptions &CodeGenOpts,
 return std::nullopt;
   InstrProfOptions Options;
   Options.NoRedZone = CodeGenOpts.DisableRedZone;
-  Options.InstrProfileOutput = CodeGenOpts.InstrProfileOutput;
+  Options.InstrProfileOutput = CodeGenOpts.ContinuousProfileSync
+   ? ("%c" + CodeGenOpts.InstrProfileOutput)
+   : CodeGenOpts.InstrProfileOutput;
   Options.Atomic = CodeGenOpts.AtomicProfileUpdate;
   return Options;
 }
@@ -811,13 +823,12 @@ void EmitAssemblyHelper::RunOptimizationPipeline(
 
   if (CodeGenOpts.hasProfileIRInstr())
 // -fprofile-generate.
-PGOOpt = PGOOptions(
-CodeGenOpts.InstrProfileOutput.empty() ? getDefaultProfileGenName()
-   : 
CodeGenOpts.InstrProfileOutput,
-"", "", CodeGenOpts.MemoryProfileUsePath, nullptr, PGOOptions::IRInstr,
- 

[clang] [profile] Add a clang option -fprofile-continuous that enables continuous instrumentation profiling mode (PR #124353)

2025-02-08 Thread Wael Yehia via cfe-commits

https://github.com/w2yehia updated 
https://github.com/llvm/llvm-project/pull/124353

>From abef90fe8f46431a5fb8b7fe717c9fb65eb30266 Mon Sep 17 00:00:00 2001
From: Wael Yehia 
Date: Thu, 23 Jan 2025 00:03:15 +
Subject: [PATCH 1/8] [PGO] Add a clang option -fprofile-continuous that
 enables PGO continuous mode

---
 clang/docs/UsersManual.rst   |  8 
 clang/include/clang/Basic/CodeGenOptions.def |  1 +
 clang/include/clang/Driver/Options.td|  5 +++
 clang/lib/CodeGen/BackendUtil.cpp| 42 +++-
 clang/lib/Driver/ToolChains/Clang.cpp| 29 ++
 clang/test/CodeGen/profile-continuous.c  | 16 
 6 files changed, 83 insertions(+), 18 deletions(-)
 create mode 100644 clang/test/CodeGen/profile-continuous.c

diff --git a/clang/docs/UsersManual.rst b/clang/docs/UsersManual.rst
index 260e84910c6f783..1e5099067339977 100644
--- a/clang/docs/UsersManual.rst
+++ b/clang/docs/UsersManual.rst
@@ -3033,6 +3033,14 @@ indexed format, regardeless whether it is produced by 
frontend or the IR pass.
   overhead. ``prefer-atomic`` will be transformed to ``atomic`` when supported
   by the target, or ``single`` otherwise.
 
+.. option:: -fprofile-continuous
+
+  Enables continuous PGO mode where profile counter updates are continuously
+  synced to a file. This option sets any neccessary modifiers (currently 
``%c``)
+  in the default profile filename and passes any necessary flags to the
+  middle-end to support this mode. Value profiling is not supported in
+  continuous mode.
+
 .. option:: -ftemporal-profile
 
   Enables the temporal profiling extension for IRPGO to improve startup time by
diff --git a/clang/include/clang/Basic/CodeGenOptions.def 
b/clang/include/clang/Basic/CodeGenOptions.def
index 0f4ed13d5f3d8c1..bbaf8b183222e98 100644
--- a/clang/include/clang/Basic/CodeGenOptions.def
+++ b/clang/include/clang/Basic/CodeGenOptions.def
@@ -221,6 +221,7 @@ AFFECTING_VALUE_CODEGENOPT(OptimizationLevel, 2, 0) ///< 
The -O[0-3] option spec
 AFFECTING_VALUE_CODEGENOPT(OptimizeSize, 2, 0) ///< If -Os (==1) or -Oz (==2) 
is specified.
 
 CODEGENOPT(AtomicProfileUpdate , 1, 0) ///< Set -fprofile-update=atomic
+CODEGENOPT(ContinuousProfileSync, 1, 0) ///< Enable continuous PGO mode
 /// Choose profile instrumenation kind or no instrumentation.
 ENUM_CODEGENOPT(ProfileInstr, ProfileInstrKind, 2, ProfileNone)
 /// Choose profile kind for PGO use compilation.
diff --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index 2721c1b5d8dc554..5a7e64d5b5a96f3 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -1886,6 +1886,11 @@ def fprofile_update_EQ : Joined<["-"], 
"fprofile-update=">,
 Values<"atomic,prefer-atomic,single">,
 MetaVarName<"">, HelpText<"Set update method of profile counters">,
 MarshallingInfoFlag>;
+def fprofile_continuous : Flag<["-"], "fprofile-continuous">,
+Group, Visibility<[ClangOption, CC1Option]>,
+HelpText<"Enable Continuous PGO mode">,
+MarshallingInfoFlag>;
+
 defm pseudo_probe_for_profiling : BoolFOption<"pseudo-probe-for-profiling",
   CodeGenOpts<"PseudoProbeForProfiling">, DefaultFalse,
   PosFlag,
diff --git a/clang/lib/CodeGen/BackendUtil.cpp 
b/clang/lib/CodeGen/BackendUtil.cpp
index 3951ad01497ccac..afafa8af585c712 100644
--- a/clang/lib/CodeGen/BackendUtil.cpp
+++ b/clang/lib/CodeGen/BackendUtil.cpp
@@ -133,6 +133,16 @@ std::string getDefaultProfileGenName() {
  : "default_%m.profraw";
 }
 
+// Path and name of file used for profile generation
+std::string getProfileGenName(const CodeGenOptions &CodeGenOpts) {
+  std::string FileName = CodeGenOpts.InstrProfileOutput.empty()
+ ? getDefaultProfileGenName()
+ : CodeGenOpts.InstrProfileOutput;
+  if (CodeGenOpts.ContinuousProfileSync)
+FileName = "%c" + FileName;
+  return FileName;
+}
+
 class EmitAssemblyHelper {
   CompilerInstance &CI;
   DiagnosticsEngine &Diags;
@@ -550,7 +560,9 @@ getInstrProfOptions(const CodeGenOptions &CodeGenOpts,
 return std::nullopt;
   InstrProfOptions Options;
   Options.NoRedZone = CodeGenOpts.DisableRedZone;
-  Options.InstrProfileOutput = CodeGenOpts.InstrProfileOutput;
+  Options.InstrProfileOutput = CodeGenOpts.ContinuousProfileSync
+   ? ("%c" + CodeGenOpts.InstrProfileOutput)
+   : CodeGenOpts.InstrProfileOutput;
   Options.Atomic = CodeGenOpts.AtomicProfileUpdate;
   return Options;
 }
@@ -811,13 +823,12 @@ void EmitAssemblyHelper::RunOptimizationPipeline(
 
   if (CodeGenOpts.hasProfileIRInstr())
 // -fprofile-generate.
-PGOOpt = PGOOptions(
-CodeGenOpts.InstrProfileOutput.empty() ? getDefaultProfileGenName()
-   : 
CodeGenOpts.InstrProfileOutput,
-"", "", CodeGenOpts.MemoryProfileUsePath, nullptr, PGOOptions::IRInstr,
- 

[clang] [profile] Add a clang option -fprofile-continuous that enables continuous instrumentation profiling mode (PR #124353)

2025-02-08 Thread Wael Yehia via cfe-commits

https://github.com/w2yehia closed 
https://github.com/llvm/llvm-project/pull/124353
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [profile] Add a clang option -fprofile-continuous that enables continuous instrumentation profiling mode (PR #124353)

2025-02-08 Thread Wael Yehia via cfe-commits

https://github.com/w2yehia updated 
https://github.com/llvm/llvm-project/pull/124353

>From abef90fe8f46431a5fb8b7fe717c9fb65eb30266 Mon Sep 17 00:00:00 2001
From: Wael Yehia 
Date: Thu, 23 Jan 2025 00:03:15 +
Subject: [PATCH 1/8] [PGO] Add a clang option -fprofile-continuous that
 enables PGO continuous mode

---
 clang/docs/UsersManual.rst   |  8 
 clang/include/clang/Basic/CodeGenOptions.def |  1 +
 clang/include/clang/Driver/Options.td|  5 +++
 clang/lib/CodeGen/BackendUtil.cpp| 42 +++-
 clang/lib/Driver/ToolChains/Clang.cpp| 29 ++
 clang/test/CodeGen/profile-continuous.c  | 16 
 6 files changed, 83 insertions(+), 18 deletions(-)
 create mode 100644 clang/test/CodeGen/profile-continuous.c

diff --git a/clang/docs/UsersManual.rst b/clang/docs/UsersManual.rst
index 260e84910c6f783..1e5099067339977 100644
--- a/clang/docs/UsersManual.rst
+++ b/clang/docs/UsersManual.rst
@@ -3033,6 +3033,14 @@ indexed format, regardeless whether it is produced by 
frontend or the IR pass.
   overhead. ``prefer-atomic`` will be transformed to ``atomic`` when supported
   by the target, or ``single`` otherwise.
 
+.. option:: -fprofile-continuous
+
+  Enables continuous PGO mode where profile counter updates are continuously
+  synced to a file. This option sets any neccessary modifiers (currently 
``%c``)
+  in the default profile filename and passes any necessary flags to the
+  middle-end to support this mode. Value profiling is not supported in
+  continuous mode.
+
 .. option:: -ftemporal-profile
 
   Enables the temporal profiling extension for IRPGO to improve startup time by
diff --git a/clang/include/clang/Basic/CodeGenOptions.def 
b/clang/include/clang/Basic/CodeGenOptions.def
index 0f4ed13d5f3d8c1..bbaf8b183222e98 100644
--- a/clang/include/clang/Basic/CodeGenOptions.def
+++ b/clang/include/clang/Basic/CodeGenOptions.def
@@ -221,6 +221,7 @@ AFFECTING_VALUE_CODEGENOPT(OptimizationLevel, 2, 0) ///< 
The -O[0-3] option spec
 AFFECTING_VALUE_CODEGENOPT(OptimizeSize, 2, 0) ///< If -Os (==1) or -Oz (==2) 
is specified.
 
 CODEGENOPT(AtomicProfileUpdate , 1, 0) ///< Set -fprofile-update=atomic
+CODEGENOPT(ContinuousProfileSync, 1, 0) ///< Enable continuous PGO mode
 /// Choose profile instrumenation kind or no instrumentation.
 ENUM_CODEGENOPT(ProfileInstr, ProfileInstrKind, 2, ProfileNone)
 /// Choose profile kind for PGO use compilation.
diff --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index 2721c1b5d8dc554..5a7e64d5b5a96f3 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -1886,6 +1886,11 @@ def fprofile_update_EQ : Joined<["-"], 
"fprofile-update=">,
 Values<"atomic,prefer-atomic,single">,
 MetaVarName<"">, HelpText<"Set update method of profile counters">,
 MarshallingInfoFlag>;
+def fprofile_continuous : Flag<["-"], "fprofile-continuous">,
+Group, Visibility<[ClangOption, CC1Option]>,
+HelpText<"Enable Continuous PGO mode">,
+MarshallingInfoFlag>;
+
 defm pseudo_probe_for_profiling : BoolFOption<"pseudo-probe-for-profiling",
   CodeGenOpts<"PseudoProbeForProfiling">, DefaultFalse,
   PosFlag,
diff --git a/clang/lib/CodeGen/BackendUtil.cpp 
b/clang/lib/CodeGen/BackendUtil.cpp
index 3951ad01497ccac..afafa8af585c712 100644
--- a/clang/lib/CodeGen/BackendUtil.cpp
+++ b/clang/lib/CodeGen/BackendUtil.cpp
@@ -133,6 +133,16 @@ std::string getDefaultProfileGenName() {
  : "default_%m.profraw";
 }
 
+// Path and name of file used for profile generation
+std::string getProfileGenName(const CodeGenOptions &CodeGenOpts) {
+  std::string FileName = CodeGenOpts.InstrProfileOutput.empty()
+ ? getDefaultProfileGenName()
+ : CodeGenOpts.InstrProfileOutput;
+  if (CodeGenOpts.ContinuousProfileSync)
+FileName = "%c" + FileName;
+  return FileName;
+}
+
 class EmitAssemblyHelper {
   CompilerInstance &CI;
   DiagnosticsEngine &Diags;
@@ -550,7 +560,9 @@ getInstrProfOptions(const CodeGenOptions &CodeGenOpts,
 return std::nullopt;
   InstrProfOptions Options;
   Options.NoRedZone = CodeGenOpts.DisableRedZone;
-  Options.InstrProfileOutput = CodeGenOpts.InstrProfileOutput;
+  Options.InstrProfileOutput = CodeGenOpts.ContinuousProfileSync
+   ? ("%c" + CodeGenOpts.InstrProfileOutput)
+   : CodeGenOpts.InstrProfileOutput;
   Options.Atomic = CodeGenOpts.AtomicProfileUpdate;
   return Options;
 }
@@ -811,13 +823,12 @@ void EmitAssemblyHelper::RunOptimizationPipeline(
 
   if (CodeGenOpts.hasProfileIRInstr())
 // -fprofile-generate.
-PGOOpt = PGOOptions(
-CodeGenOpts.InstrProfileOutput.empty() ? getDefaultProfileGenName()
-   : 
CodeGenOpts.InstrProfileOutput,
-"", "", CodeGenOpts.MemoryProfileUsePath, nullptr, PGOOptions::IRInstr,
- 

[clang] [PGO] Add a clang option -fprofile-continuous that enables continuous instrumentation profiling mode (PR #124353)

2025-02-06 Thread Wael Yehia via cfe-commits

https://github.com/w2yehia updated 
https://github.com/llvm/llvm-project/pull/124353

>From abef90fe8f46431a5fb8b7fe717c9fb65eb30266 Mon Sep 17 00:00:00 2001
From: Wael Yehia 
Date: Thu, 23 Jan 2025 00:03:15 +
Subject: [PATCH 1/7] [PGO] Add a clang option -fprofile-continuous that
 enables PGO continuous mode

---
 clang/docs/UsersManual.rst   |  8 
 clang/include/clang/Basic/CodeGenOptions.def |  1 +
 clang/include/clang/Driver/Options.td|  5 +++
 clang/lib/CodeGen/BackendUtil.cpp| 42 +++-
 clang/lib/Driver/ToolChains/Clang.cpp| 29 ++
 clang/test/CodeGen/profile-continuous.c  | 16 
 6 files changed, 83 insertions(+), 18 deletions(-)
 create mode 100644 clang/test/CodeGen/profile-continuous.c

diff --git a/clang/docs/UsersManual.rst b/clang/docs/UsersManual.rst
index 260e84910c6f783..1e5099067339977 100644
--- a/clang/docs/UsersManual.rst
+++ b/clang/docs/UsersManual.rst
@@ -3033,6 +3033,14 @@ indexed format, regardeless whether it is produced by 
frontend or the IR pass.
   overhead. ``prefer-atomic`` will be transformed to ``atomic`` when supported
   by the target, or ``single`` otherwise.
 
+.. option:: -fprofile-continuous
+
+  Enables continuous PGO mode where profile counter updates are continuously
+  synced to a file. This option sets any neccessary modifiers (currently 
``%c``)
+  in the default profile filename and passes any necessary flags to the
+  middle-end to support this mode. Value profiling is not supported in
+  continuous mode.
+
 .. option:: -ftemporal-profile
 
   Enables the temporal profiling extension for IRPGO to improve startup time by
diff --git a/clang/include/clang/Basic/CodeGenOptions.def 
b/clang/include/clang/Basic/CodeGenOptions.def
index 0f4ed13d5f3d8c1..bbaf8b183222e98 100644
--- a/clang/include/clang/Basic/CodeGenOptions.def
+++ b/clang/include/clang/Basic/CodeGenOptions.def
@@ -221,6 +221,7 @@ AFFECTING_VALUE_CODEGENOPT(OptimizationLevel, 2, 0) ///< 
The -O[0-3] option spec
 AFFECTING_VALUE_CODEGENOPT(OptimizeSize, 2, 0) ///< If -Os (==1) or -Oz (==2) 
is specified.
 
 CODEGENOPT(AtomicProfileUpdate , 1, 0) ///< Set -fprofile-update=atomic
+CODEGENOPT(ContinuousProfileSync, 1, 0) ///< Enable continuous PGO mode
 /// Choose profile instrumenation kind or no instrumentation.
 ENUM_CODEGENOPT(ProfileInstr, ProfileInstrKind, 2, ProfileNone)
 /// Choose profile kind for PGO use compilation.
diff --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index 2721c1b5d8dc554..5a7e64d5b5a96f3 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -1886,6 +1886,11 @@ def fprofile_update_EQ : Joined<["-"], 
"fprofile-update=">,
 Values<"atomic,prefer-atomic,single">,
 MetaVarName<"">, HelpText<"Set update method of profile counters">,
 MarshallingInfoFlag>;
+def fprofile_continuous : Flag<["-"], "fprofile-continuous">,
+Group, Visibility<[ClangOption, CC1Option]>,
+HelpText<"Enable Continuous PGO mode">,
+MarshallingInfoFlag>;
+
 defm pseudo_probe_for_profiling : BoolFOption<"pseudo-probe-for-profiling",
   CodeGenOpts<"PseudoProbeForProfiling">, DefaultFalse,
   PosFlag,
diff --git a/clang/lib/CodeGen/BackendUtil.cpp 
b/clang/lib/CodeGen/BackendUtil.cpp
index 3951ad01497ccac..afafa8af585c712 100644
--- a/clang/lib/CodeGen/BackendUtil.cpp
+++ b/clang/lib/CodeGen/BackendUtil.cpp
@@ -133,6 +133,16 @@ std::string getDefaultProfileGenName() {
  : "default_%m.profraw";
 }
 
+// Path and name of file used for profile generation
+std::string getProfileGenName(const CodeGenOptions &CodeGenOpts) {
+  std::string FileName = CodeGenOpts.InstrProfileOutput.empty()
+ ? getDefaultProfileGenName()
+ : CodeGenOpts.InstrProfileOutput;
+  if (CodeGenOpts.ContinuousProfileSync)
+FileName = "%c" + FileName;
+  return FileName;
+}
+
 class EmitAssemblyHelper {
   CompilerInstance &CI;
   DiagnosticsEngine &Diags;
@@ -550,7 +560,9 @@ getInstrProfOptions(const CodeGenOptions &CodeGenOpts,
 return std::nullopt;
   InstrProfOptions Options;
   Options.NoRedZone = CodeGenOpts.DisableRedZone;
-  Options.InstrProfileOutput = CodeGenOpts.InstrProfileOutput;
+  Options.InstrProfileOutput = CodeGenOpts.ContinuousProfileSync
+   ? ("%c" + CodeGenOpts.InstrProfileOutput)
+   : CodeGenOpts.InstrProfileOutput;
   Options.Atomic = CodeGenOpts.AtomicProfileUpdate;
   return Options;
 }
@@ -811,13 +823,12 @@ void EmitAssemblyHelper::RunOptimizationPipeline(
 
   if (CodeGenOpts.hasProfileIRInstr())
 // -fprofile-generate.
-PGOOpt = PGOOptions(
-CodeGenOpts.InstrProfileOutput.empty() ? getDefaultProfileGenName()
-   : 
CodeGenOpts.InstrProfileOutput,
-"", "", CodeGenOpts.MemoryProfileUsePath, nullptr, PGOOptions::IRInstr,
- 

[clang] [PGO] Add a clang option -fprofile-continuous that enables continuous instrumentation profiling mode (PR #124353)

2025-02-06 Thread Wael Yehia via cfe-commits


@@ -0,0 +1,21 @@
+// 1) test on platforms that (do or do not) require runtime relocation
+//
+// RUN: %clang -target x86_64-darwin -fprofile-generate -fprofile-continuous 
-### -c %s 2>&1 | FileCheck %s --check-prefix=NO_RELOC
+// NO_RELOC: "-cc1" {{.*}} "-fprofile-continuous"
+// NO_RELOC-NOT: "-mllvm" "-runtime-counter-relocation"
+
+// RUN: %clang -target powerpc64-ibm-aix -fprofile-generate 
-fprofile-continuous -### -c %s 2>&1 | FileCheck %s --check-prefix=RELOC

w2yehia wrote:

done

https://github.com/llvm/llvm-project/pull/124353
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [PGO] Add a clang option -fprofile-continuous that enables continuous instrumentation profiling mode (PR #124353)

2025-02-06 Thread Wael Yehia via cfe-commits


@@ -3033,6 +3033,24 @@ indexed format, regardeless whether it is produced by 
frontend or the IR pass.
   overhead. ``prefer-atomic`` will be transformed to ``atomic`` when supported
   by the target, or ``single`` otherwise.
 
+.. option:: -fprofile-continuous
+
+  Enables the continuous instrumentation profiling where profile counter 
updates
+  are continuously synced to a file. This option sets any neccessary modifiers
+  (currently ``%c``) in the default profile filename and passes any necessary
+  flags to the middle-end to support this mode. Value profiling is not 
supported
+  in continuous mode.
+
+  .. code-block:: console
+
+$ clang++ -O2 -fprofile-generate -fprofile-continuous code.cc -o code
+
+  Running `./code` will collect the profile and write it to the

w2yehia wrote:

Thanks. Fixed.

https://github.com/llvm/llvm-project/pull/124353
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [profile] Add a clang option -fprofile-continuous that enables continuous instrumentation profiling mode (PR #124353)

2025-02-06 Thread Wael Yehia via cfe-commits

https://github.com/w2yehia edited 
https://github.com/llvm/llvm-project/pull/124353
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [compiler-rt] [Sanitizers] the access size (8 bytes) exceeds the max lock-free size (4 bytes) for 32-bit (PR #125388)

2025-02-05 Thread Wael Yehia via cfe-commits


@@ -1120,3 +1120,23 @@
 // RUN:-c \
 // RUN:   | FileCheck --check-prefixes=CHECK-K-UNUSED %s
 // CHECK-K-UNUSED: clang: warning: -K: 'linker' input unused 
[-Wunused-command-line-argument]
+
+
+// This test verifies that the linker doesn't include '-latomic' when no 
sanitizers are enabled 
+// Running this test on non-AIX host will result in an unrelated error 
+// FIXME: Sanitizer interface functions must be exported by export files on AIX

w2yehia wrote:

why do we have this FIXME here? Do you expect separate tests in the future for 
the FIXME or does the FIXME apply specifically to the test below?

https://github.com/llvm/llvm-project/pull/125388
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [compiler-rt] [Sanitizers] the access size (8 bytes) exceeds the max lock-free size (4 bytes) for 32-bit (PR #125388)

2025-02-05 Thread Wael Yehia via cfe-commits

https://github.com/w2yehia deleted 
https://github.com/llvm/llvm-project/pull/125388
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [profile] Add a clang option -fprofile-continuous that enables continuous instrumentation profiling mode (PR #124353)

2025-02-07 Thread Wael Yehia via cfe-commits

w2yehia wrote:

Thank you to the reviewers.
I'll merge this tonight if I get no further feedback.

https://github.com/llvm/llvm-project/pull/124353
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [profile] Add a clang option -fprofile-continuous that enables continuous instrumentation profiling mode (PR #124353)

2025-02-10 Thread Wael Yehia via cfe-commits

w2yehia wrote:

> > Just saw this in LLVM weekly. But this is not supported on Windows right? 
> > Only the UNIX platforms that can mmap? In that case it the limitation needs 
> > to be documented
> 
> It is supported! We have [an `mmap` implementation for 
> Windows](https://github.com/llvm/llvm-project/blob/d7fd2a2a3befe451d3cc70612a40e8c90a780caf/compiler-rt/lib/profile/WindowsMMap.c)
>  in the profile runtime and [the continuous mode is being tested in 
> Windows](https://github.com/llvm/llvm-project/blob/d7fd2a2a3befe451d3cc70612a40e8c90a780caf/compiler-rt/test/profile/ContinuousSyncMode/runtime-counter-relocation.c).

Thanks Petr. The Source Coverage page has:
> Support for Linux may be mostly complete but requires testing, and support 
> for Windows may require more extensive changes: please get involved if you 
> are interested in porting this feature.

Should we keep it as is or improve it?

https://github.com/llvm/llvm-project/pull/124353
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [compiler-rt] [Sanitizers] the access size (8 bytes) exceeds the max lock-free size (4 bytes) for 32-bit (PR #125388)

2025-02-02 Thread Wael Yehia via cfe-commits

https://github.com/w2yehia edited 
https://github.com/llvm/llvm-project/pull/125388
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [compiler-rt] [Sanitizers] the access size (8 bytes) exceeds the max lock-free size (4 bytes) for 32-bit (PR #125388)

2025-02-02 Thread Wael Yehia via cfe-commits


@@ -239,6 +239,9 @@ append_list_if(SANITIZER_LIMIT_FRAME_SIZE 
-Wframe-larger-than=570
 append_list_if(COMPILER_RT_HAS_WGLOBAL_CONSTRUCTORS_FLAG -Wglobal-constructors
SANITIZER_CFLAGS)
 
+# Suppress -Watomic-alignment warnings by not treating them as errors

w2yehia wrote:

Adding the -Wno-error should only be needed in 32-bit mode, and probably AIX 
only for now.

https://github.com/llvm/llvm-project/pull/125388
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [compiler-rt] [Sanitizers] the access size (8 bytes) exceeds the max lock-free size (4 bytes) for 32-bit (PR #125388)

2025-02-02 Thread Wael Yehia via cfe-commits


@@ -239,6 +239,9 @@ append_list_if(SANITIZER_LIMIT_FRAME_SIZE 
-Wframe-larger-than=570
 append_list_if(COMPILER_RT_HAS_WGLOBAL_CONSTRUCTORS_FLAG -Wglobal-constructors
SANITIZER_CFLAGS)
 
+# Suppress -Watomic-alignment warnings by not treating them as errors

w2yehia wrote:

also, for other conditional additions to `CFLAGS` (like the ones above) a 
variable is defined in `compiler-rt/CMakeLists.txt` and checked here (see 
`SANITIZER_LIMIT_FRAME_SIZE` for example). Not sure if yours has to be done 
similarly.

https://github.com/llvm/llvm-project/pull/125388
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [compiler-rt] [Sanitizers] the access size (8 bytes) exceeds the max lock-free size (4 bytes) for 32-bit (PR #125388)

2025-02-02 Thread Wael Yehia via cfe-commits


@@ -338,6 +338,10 @@ void aix::Linker::ConstructJob(Compilation &C, const 
JobAction &JA,
 CmdArgs.push_back("-lpthread");
   }
   const char *Exec = Args.MakeArgString(ToolChain.GetLinkerPath());
+  
+  if (Sanitize.hasAnySanitizer() && IsArch32Bit) {

w2yehia wrote:

a comment on why we need -latomic here. 
For example:
```
// Some code in the sanitizer libs requires 64-bit atomics.
```

https://github.com/llvm/llvm-project/pull/125388
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [PGO] Add a clang option -fprofile-continuous that enables PGO continuous mode (PR #124353)

2025-01-30 Thread Wael Yehia via cfe-commits


@@ -785,6 +786,34 @@ static void addPGOAndCoverageFlags(const ToolChain &TC, 
Compilation &C,
   D.Diag(diag::err_drv_unsupported_option_argument)
   << A->getSpelling() << Val;
   }
+  if (const auto *A = Args.getLastArg(options::OPT_fprofile_continuous)) {
+if (!PGOGenerateArg && !CSPGOGenerateArg && !ProfileGenerateArg)
+  D.Diag(clang::diag::err_drv_argument_only_allowed_with)
+  << A->getSpelling()
+  << "-fprofile-generate, -fprofile-instr-generate, or "
+ "-fcs-profile-generate";
+else {
+  CmdArgs.push_back("-fprofile-continuous");
+  // Platforms that require a bias variable:
+  if (T.isOSFuchsia() || T.isOSBinFormatELF() || T.isOSAIX()) {
+CmdArgs.push_back("-mllvm");

w2yehia wrote:

> `runtime_reloc = bool(config.host_os in ["AIX", "Linux"]`

I will be removing the above code in the [follow-up 
PR](https://github.com/w2yehia/llvm-project/pull/1).

https://github.com/llvm/llvm-project/pull/124353
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [PGO] Add a clang option -fprofile-continuous that enables PGO continuous mode (PR #124353)

2025-01-30 Thread Wael Yehia via cfe-commits

https://github.com/w2yehia edited 
https://github.com/llvm/llvm-project/pull/124353
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [PGO] Add a clang option -fprofile-continuous that enables PGO continuous mode (PR #124353)

2025-01-30 Thread Wael Yehia via cfe-commits

https://github.com/w2yehia updated 
https://github.com/llvm/llvm-project/pull/124353

>From abef90fe8f46431a5fb8b7fe717c9fb65eb30266 Mon Sep 17 00:00:00 2001
From: Wael Yehia 
Date: Thu, 23 Jan 2025 00:03:15 +
Subject: [PATCH 1/5] [PGO] Add a clang option -fprofile-continuous that
 enables PGO continuous mode

---
 clang/docs/UsersManual.rst   |  8 
 clang/include/clang/Basic/CodeGenOptions.def |  1 +
 clang/include/clang/Driver/Options.td|  5 +++
 clang/lib/CodeGen/BackendUtil.cpp| 42 +++-
 clang/lib/Driver/ToolChains/Clang.cpp| 29 ++
 clang/test/CodeGen/profile-continuous.c  | 16 
 6 files changed, 83 insertions(+), 18 deletions(-)
 create mode 100644 clang/test/CodeGen/profile-continuous.c

diff --git a/clang/docs/UsersManual.rst b/clang/docs/UsersManual.rst
index 260e84910c6f78..1e509906733997 100644
--- a/clang/docs/UsersManual.rst
+++ b/clang/docs/UsersManual.rst
@@ -3033,6 +3033,14 @@ indexed format, regardeless whether it is produced by 
frontend or the IR pass.
   overhead. ``prefer-atomic`` will be transformed to ``atomic`` when supported
   by the target, or ``single`` otherwise.
 
+.. option:: -fprofile-continuous
+
+  Enables continuous PGO mode where profile counter updates are continuously
+  synced to a file. This option sets any neccessary modifiers (currently 
``%c``)
+  in the default profile filename and passes any necessary flags to the
+  middle-end to support this mode. Value profiling is not supported in
+  continuous mode.
+
 .. option:: -ftemporal-profile
 
   Enables the temporal profiling extension for IRPGO to improve startup time by
diff --git a/clang/include/clang/Basic/CodeGenOptions.def 
b/clang/include/clang/Basic/CodeGenOptions.def
index 0f4ed13d5f3d8c..bbaf8b183222e9 100644
--- a/clang/include/clang/Basic/CodeGenOptions.def
+++ b/clang/include/clang/Basic/CodeGenOptions.def
@@ -221,6 +221,7 @@ AFFECTING_VALUE_CODEGENOPT(OptimizationLevel, 2, 0) ///< 
The -O[0-3] option spec
 AFFECTING_VALUE_CODEGENOPT(OptimizeSize, 2, 0) ///< If -Os (==1) or -Oz (==2) 
is specified.
 
 CODEGENOPT(AtomicProfileUpdate , 1, 0) ///< Set -fprofile-update=atomic
+CODEGENOPT(ContinuousProfileSync, 1, 0) ///< Enable continuous PGO mode
 /// Choose profile instrumenation kind or no instrumentation.
 ENUM_CODEGENOPT(ProfileInstr, ProfileInstrKind, 2, ProfileNone)
 /// Choose profile kind for PGO use compilation.
diff --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index 2721c1b5d8dc55..5a7e64d5b5a96f 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -1886,6 +1886,11 @@ def fprofile_update_EQ : Joined<["-"], 
"fprofile-update=">,
 Values<"atomic,prefer-atomic,single">,
 MetaVarName<"">, HelpText<"Set update method of profile counters">,
 MarshallingInfoFlag>;
+def fprofile_continuous : Flag<["-"], "fprofile-continuous">,
+Group, Visibility<[ClangOption, CC1Option]>,
+HelpText<"Enable Continuous PGO mode">,
+MarshallingInfoFlag>;
+
 defm pseudo_probe_for_profiling : BoolFOption<"pseudo-probe-for-profiling",
   CodeGenOpts<"PseudoProbeForProfiling">, DefaultFalse,
   PosFlag,
diff --git a/clang/lib/CodeGen/BackendUtil.cpp 
b/clang/lib/CodeGen/BackendUtil.cpp
index 3951ad01497cca..afafa8af585c71 100644
--- a/clang/lib/CodeGen/BackendUtil.cpp
+++ b/clang/lib/CodeGen/BackendUtil.cpp
@@ -133,6 +133,16 @@ std::string getDefaultProfileGenName() {
  : "default_%m.profraw";
 }
 
+// Path and name of file used for profile generation
+std::string getProfileGenName(const CodeGenOptions &CodeGenOpts) {
+  std::string FileName = CodeGenOpts.InstrProfileOutput.empty()
+ ? getDefaultProfileGenName()
+ : CodeGenOpts.InstrProfileOutput;
+  if (CodeGenOpts.ContinuousProfileSync)
+FileName = "%c" + FileName;
+  return FileName;
+}
+
 class EmitAssemblyHelper {
   CompilerInstance &CI;
   DiagnosticsEngine &Diags;
@@ -550,7 +560,9 @@ getInstrProfOptions(const CodeGenOptions &CodeGenOpts,
 return std::nullopt;
   InstrProfOptions Options;
   Options.NoRedZone = CodeGenOpts.DisableRedZone;
-  Options.InstrProfileOutput = CodeGenOpts.InstrProfileOutput;
+  Options.InstrProfileOutput = CodeGenOpts.ContinuousProfileSync
+   ? ("%c" + CodeGenOpts.InstrProfileOutput)
+   : CodeGenOpts.InstrProfileOutput;
   Options.Atomic = CodeGenOpts.AtomicProfileUpdate;
   return Options;
 }
@@ -811,13 +823,12 @@ void EmitAssemblyHelper::RunOptimizationPipeline(
 
   if (CodeGenOpts.hasProfileIRInstr())
 // -fprofile-generate.
-PGOOpt = PGOOptions(
-CodeGenOpts.InstrProfileOutput.empty() ? getDefaultProfileGenName()
-   : 
CodeGenOpts.InstrProfileOutput,
-"", "", CodeGenOpts.MemoryProfileUsePath, nullptr, PGOOptions::IRInstr,
-P

[clang] [PGO] Add a clang option -fprofile-continuous that enables PGO continuous mode (PR #124353)

2025-01-30 Thread Wael Yehia via cfe-commits


@@ -0,0 +1,21 @@
+// 1) test on platforms that (do or do not) require runtime relocation
+//
+// RUN: %clang -target x86_64-darwin -fprofile-generate -fprofile-continuous 
-### -c %s 2>&1 | FileCheck %s --check-prefix=NO_RELOC
+// NO_RELOC: "-cc1" {{.*}} "-fprofile-continuous"
+// NO_RELOC-NOT: "-mllvm" "-runtime-counter-relocation"
+
+// 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
+// RELOC: "-cc1" {{.*}} "-fprofile-continuous" "-mllvm" 
"-runtime-counter-relocation"
+
+// 2) test -fprofile-continuous with cs-profile-generate and 
-fprofile-instr-generate
+//
+// RUN: %clang -target powerpc-ibm-aix -fprofile-instr-generate 
-fprofile-continuous -### -c %s 2>&1 | FileCheck %s --check-prefix=CLANG_PGO
+// RUN: %clang -target powerpc64le-unknown-linux -fprofile-instr-generate= 
-fprofile-continuous -### -c %s 2>&1 | FileCheck %s --check-prefix=CLANG_PGO
+// CLANG_PGO: "-cc1" {{.*}} "-fprofile-continuous" "-mllvm" 
"-runtime-counter-relocation" "-fprofile-instrument-path=default.profraw"
+
+// RUN: %clang -target x86_64-unknown-fuchsia -fcs-profile-generate 
-fprofile-continuous -### -c %s 2>&1 | FileCheck %s --check-prefix=RELOC
+
+// RUN: not %clang -fprofile-continuous -### -c %s 2>&1 | FileCheck %s 
--check-prefix=ERROR
+// ERROR: clang: error: invalid argument '-fprofile-continuous' only allowed 
with '-fprofile-generate, -fprofile-instr-generate, or -fcs-profile-generate'

w2yehia wrote:

done

https://github.com/llvm/llvm-project/pull/124353
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [PGO] Add a clang option -fprofile-continuous that enables PGO continuous mode (PR #124353)

2025-01-30 Thread Wael Yehia via cfe-commits


@@ -785,6 +786,34 @@ static void addPGOAndCoverageFlags(const ToolChain &TC, 
Compilation &C,
   D.Diag(diag::err_drv_unsupported_option_argument)
   << A->getSpelling() << Val;
   }
+  if (const auto *A = Args.getLastArg(options::OPT_fprofile_continuous)) {
+if (!PGOGenerateArg && !CSPGOGenerateArg && !ProfileGenerateArg)
+  D.Diag(clang::diag::err_drv_argument_only_allowed_with)
+  << A->getSpelling()
+  << "-fprofile-generate, -fprofile-instr-generate, or "
+ "-fcs-profile-generate";
+else {
+  CmdArgs.push_back("-fprofile-continuous");
+  // Platforms that require a bias variable:
+  if (T.isOSFuchsia() || T.isOSBinFormatELF() || T.isOSAIX()) {
+CmdArgs.push_back("-mllvm");

w2yehia wrote:

done

https://github.com/llvm/llvm-project/pull/124353
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [AIX] fix unsupported diff flag on AIX (-strip-trailing-cr) (PR #120276)

2024-12-17 Thread Wael Yehia via cfe-commits

https://github.com/w2yehia approved this pull request.

LGTM

https://github.com/llvm/llvm-project/pull/120276
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [PGO] Add a clang option -fprofile-continuous that enables PGO continuous mode (PR #124353)

2025-01-24 Thread Wael Yehia via cfe-commits

https://github.com/w2yehia created 
https://github.com/llvm/llvm-project/pull/124353

None

>From abef90fe8f46431a5fb8b7fe717c9fb65eb30266 Mon Sep 17 00:00:00 2001
From: Wael Yehia 
Date: Thu, 23 Jan 2025 00:03:15 +
Subject: [PATCH] [PGO] Add a clang option -fprofile-continuous that enables
 PGO continuous mode

---
 clang/docs/UsersManual.rst   |  8 
 clang/include/clang/Basic/CodeGenOptions.def |  1 +
 clang/include/clang/Driver/Options.td|  5 +++
 clang/lib/CodeGen/BackendUtil.cpp| 42 +++-
 clang/lib/Driver/ToolChains/Clang.cpp| 29 ++
 clang/test/CodeGen/profile-continuous.c  | 16 
 6 files changed, 83 insertions(+), 18 deletions(-)
 create mode 100644 clang/test/CodeGen/profile-continuous.c

diff --git a/clang/docs/UsersManual.rst b/clang/docs/UsersManual.rst
index 260e84910c6f78..1e509906733997 100644
--- a/clang/docs/UsersManual.rst
+++ b/clang/docs/UsersManual.rst
@@ -3033,6 +3033,14 @@ indexed format, regardeless whether it is produced by 
frontend or the IR pass.
   overhead. ``prefer-atomic`` will be transformed to ``atomic`` when supported
   by the target, or ``single`` otherwise.
 
+.. option:: -fprofile-continuous
+
+  Enables continuous PGO mode where profile counter updates are continuously
+  synced to a file. This option sets any neccessary modifiers (currently 
``%c``)
+  in the default profile filename and passes any necessary flags to the
+  middle-end to support this mode. Value profiling is not supported in
+  continuous mode.
+
 .. option:: -ftemporal-profile
 
   Enables the temporal profiling extension for IRPGO to improve startup time by
diff --git a/clang/include/clang/Basic/CodeGenOptions.def 
b/clang/include/clang/Basic/CodeGenOptions.def
index 0f4ed13d5f3d8c..bbaf8b183222e9 100644
--- a/clang/include/clang/Basic/CodeGenOptions.def
+++ b/clang/include/clang/Basic/CodeGenOptions.def
@@ -221,6 +221,7 @@ AFFECTING_VALUE_CODEGENOPT(OptimizationLevel, 2, 0) ///< 
The -O[0-3] option spec
 AFFECTING_VALUE_CODEGENOPT(OptimizeSize, 2, 0) ///< If -Os (==1) or -Oz (==2) 
is specified.
 
 CODEGENOPT(AtomicProfileUpdate , 1, 0) ///< Set -fprofile-update=atomic
+CODEGENOPT(ContinuousProfileSync, 1, 0) ///< Enable continuous PGO mode
 /// Choose profile instrumenation kind or no instrumentation.
 ENUM_CODEGENOPT(ProfileInstr, ProfileInstrKind, 2, ProfileNone)
 /// Choose profile kind for PGO use compilation.
diff --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index 2721c1b5d8dc55..5a7e64d5b5a96f 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -1886,6 +1886,11 @@ def fprofile_update_EQ : Joined<["-"], 
"fprofile-update=">,
 Values<"atomic,prefer-atomic,single">,
 MetaVarName<"">, HelpText<"Set update method of profile counters">,
 MarshallingInfoFlag>;
+def fprofile_continuous : Flag<["-"], "fprofile-continuous">,
+Group, Visibility<[ClangOption, CC1Option]>,
+HelpText<"Enable Continuous PGO mode">,
+MarshallingInfoFlag>;
+
 defm pseudo_probe_for_profiling : BoolFOption<"pseudo-probe-for-profiling",
   CodeGenOpts<"PseudoProbeForProfiling">, DefaultFalse,
   PosFlag,
diff --git a/clang/lib/CodeGen/BackendUtil.cpp 
b/clang/lib/CodeGen/BackendUtil.cpp
index 3951ad01497cca..afafa8af585c71 100644
--- a/clang/lib/CodeGen/BackendUtil.cpp
+++ b/clang/lib/CodeGen/BackendUtil.cpp
@@ -133,6 +133,16 @@ std::string getDefaultProfileGenName() {
  : "default_%m.profraw";
 }
 
+// Path and name of file used for profile generation
+std::string getProfileGenName(const CodeGenOptions &CodeGenOpts) {
+  std::string FileName = CodeGenOpts.InstrProfileOutput.empty()
+ ? getDefaultProfileGenName()
+ : CodeGenOpts.InstrProfileOutput;
+  if (CodeGenOpts.ContinuousProfileSync)
+FileName = "%c" + FileName;
+  return FileName;
+}
+
 class EmitAssemblyHelper {
   CompilerInstance &CI;
   DiagnosticsEngine &Diags;
@@ -550,7 +560,9 @@ getInstrProfOptions(const CodeGenOptions &CodeGenOpts,
 return std::nullopt;
   InstrProfOptions Options;
   Options.NoRedZone = CodeGenOpts.DisableRedZone;
-  Options.InstrProfileOutput = CodeGenOpts.InstrProfileOutput;
+  Options.InstrProfileOutput = CodeGenOpts.ContinuousProfileSync
+   ? ("%c" + CodeGenOpts.InstrProfileOutput)
+   : CodeGenOpts.InstrProfileOutput;
   Options.Atomic = CodeGenOpts.AtomicProfileUpdate;
   return Options;
 }
@@ -811,13 +823,12 @@ void EmitAssemblyHelper::RunOptimizationPipeline(
 
   if (CodeGenOpts.hasProfileIRInstr())
 // -fprofile-generate.
-PGOOpt = PGOOptions(
-CodeGenOpts.InstrProfileOutput.empty() ? getDefaultProfileGenName()
-   : 
CodeGenOpts.InstrProfileOutput,
-"", "", CodeGenOpts.MemoryProfileUsePath, nullptr, PGOOptions::IRInstr,
-   

[clang] [PGO] Add a clang option -fprofile-continuous that enables PGO continuous mode (PR #124353)

2025-01-24 Thread Wael Yehia via cfe-commits

w2yehia wrote:

Follow up PR https://github.com/w2yehia/llvm-project/pull/1 to switch all 
applicable tests in `compiler-rt/test/profile/ContinuousSyncMode` to use 
`-fprofile-continuous`

https://github.com/llvm/llvm-project/pull/124353
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [PGO] Add a clang option -fprofile-continuous that enables PGO continuous mode (PR #124353)

2025-01-24 Thread Wael Yehia via cfe-commits


@@ -3033,6 +3033,14 @@ indexed format, regardeless whether it is produced by 
frontend or the IR pass.
   overhead. ``prefer-atomic`` will be transformed to ``atomic`` when supported
   by the target, or ``single`` otherwise.
 
+.. option:: -fprofile-continuous

w2yehia wrote:

For example:
```
$ clang++ -O2 -fprofile-generate -fprofile-continuous code.cc -o code
```
Running `./code` will collect the profile and write it to the 
`default_.profraw` file.
However, if `./code` abruptly terminates or does not call `exit()`, in 
continuous mode the profile collected up to the point of termination will be 
available in `default_.profraw` while in the non-continuous mode, no 
profile file is generated.

https://github.com/llvm/llvm-project/pull/124353
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [PGO] Add a clang option -fprofile-continuous that enables PGO continuous mode (PR #124353)

2025-01-24 Thread Wael Yehia via cfe-commits


@@ -3033,6 +3033,14 @@ indexed format, regardeless whether it is produced by 
frontend or the IR pass.
   overhead. ``prefer-atomic`` will be transformed to ``atomic`` when supported
   by the target, or ``single`` otherwise.
 
+.. option:: -fprofile-continuous

w2yehia wrote:

something like the above?

https://github.com/llvm/llvm-project/pull/124353
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [PGO] Add a clang option -fprofile-continuous that enables PGO continuous mode (PR #124353)

2025-01-27 Thread Wael Yehia via cfe-commits


@@ -3033,6 +3033,14 @@ indexed format, regardeless whether it is produced by 
frontend or the IR pass.
   overhead. ``prefer-atomic`` will be transformed to ``atomic`` when supported
   by the target, or ``single`` otherwise.
 
+.. option:: -fprofile-continuous

w2yehia wrote:

@david-xl is the above what you had in mind?

https://github.com/llvm/llvm-project/pull/124353
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [PGO] Add a clang option -fprofile-continuous that enables PGO continuous mode (PR #124353)

2025-01-27 Thread Wael Yehia via cfe-commits


@@ -1886,6 +1886,11 @@ def fprofile_update_EQ : Joined<["-"], 
"fprofile-update=">,
 Values<"atomic,prefer-atomic,single">,
 MetaVarName<"">, HelpText<"Set update method of profile counters">,
 MarshallingInfoFlag>;
+def fprofile_continuous : Flag<["-"], "fprofile-continuous">,

w2yehia wrote:

Thanks for the feedback. I prefer `-fprofile-continuous` since everywhere we 
call this feature the "continuous mode". If others feel strongly about changing 
it, then I can ofcourse change it.

https://github.com/llvm/llvm-project/pull/124353
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [PGO] Add a clang option -fprofile-continuous that enables PGO continuous mode (PR #124353)

2025-01-27 Thread Wael Yehia via cfe-commits

https://github.com/w2yehia updated 
https://github.com/llvm/llvm-project/pull/124353

>From abef90fe8f46431a5fb8b7fe717c9fb65eb30266 Mon Sep 17 00:00:00 2001
From: Wael Yehia 
Date: Thu, 23 Jan 2025 00:03:15 +
Subject: [PATCH 1/2] [PGO] Add a clang option -fprofile-continuous that
 enables PGO continuous mode

---
 clang/docs/UsersManual.rst   |  8 
 clang/include/clang/Basic/CodeGenOptions.def |  1 +
 clang/include/clang/Driver/Options.td|  5 +++
 clang/lib/CodeGen/BackendUtil.cpp| 42 +++-
 clang/lib/Driver/ToolChains/Clang.cpp| 29 ++
 clang/test/CodeGen/profile-continuous.c  | 16 
 6 files changed, 83 insertions(+), 18 deletions(-)
 create mode 100644 clang/test/CodeGen/profile-continuous.c

diff --git a/clang/docs/UsersManual.rst b/clang/docs/UsersManual.rst
index 260e84910c6f78..1e509906733997 100644
--- a/clang/docs/UsersManual.rst
+++ b/clang/docs/UsersManual.rst
@@ -3033,6 +3033,14 @@ indexed format, regardeless whether it is produced by 
frontend or the IR pass.
   overhead. ``prefer-atomic`` will be transformed to ``atomic`` when supported
   by the target, or ``single`` otherwise.
 
+.. option:: -fprofile-continuous
+
+  Enables continuous PGO mode where profile counter updates are continuously
+  synced to a file. This option sets any neccessary modifiers (currently 
``%c``)
+  in the default profile filename and passes any necessary flags to the
+  middle-end to support this mode. Value profiling is not supported in
+  continuous mode.
+
 .. option:: -ftemporal-profile
 
   Enables the temporal profiling extension for IRPGO to improve startup time by
diff --git a/clang/include/clang/Basic/CodeGenOptions.def 
b/clang/include/clang/Basic/CodeGenOptions.def
index 0f4ed13d5f3d8c..bbaf8b183222e9 100644
--- a/clang/include/clang/Basic/CodeGenOptions.def
+++ b/clang/include/clang/Basic/CodeGenOptions.def
@@ -221,6 +221,7 @@ AFFECTING_VALUE_CODEGENOPT(OptimizationLevel, 2, 0) ///< 
The -O[0-3] option spec
 AFFECTING_VALUE_CODEGENOPT(OptimizeSize, 2, 0) ///< If -Os (==1) or -Oz (==2) 
is specified.
 
 CODEGENOPT(AtomicProfileUpdate , 1, 0) ///< Set -fprofile-update=atomic
+CODEGENOPT(ContinuousProfileSync, 1, 0) ///< Enable continuous PGO mode
 /// Choose profile instrumenation kind or no instrumentation.
 ENUM_CODEGENOPT(ProfileInstr, ProfileInstrKind, 2, ProfileNone)
 /// Choose profile kind for PGO use compilation.
diff --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index 2721c1b5d8dc55..5a7e64d5b5a96f 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -1886,6 +1886,11 @@ def fprofile_update_EQ : Joined<["-"], 
"fprofile-update=">,
 Values<"atomic,prefer-atomic,single">,
 MetaVarName<"">, HelpText<"Set update method of profile counters">,
 MarshallingInfoFlag>;
+def fprofile_continuous : Flag<["-"], "fprofile-continuous">,
+Group, Visibility<[ClangOption, CC1Option]>,
+HelpText<"Enable Continuous PGO mode">,
+MarshallingInfoFlag>;
+
 defm pseudo_probe_for_profiling : BoolFOption<"pseudo-probe-for-profiling",
   CodeGenOpts<"PseudoProbeForProfiling">, DefaultFalse,
   PosFlag,
diff --git a/clang/lib/CodeGen/BackendUtil.cpp 
b/clang/lib/CodeGen/BackendUtil.cpp
index 3951ad01497cca..afafa8af585c71 100644
--- a/clang/lib/CodeGen/BackendUtil.cpp
+++ b/clang/lib/CodeGen/BackendUtil.cpp
@@ -133,6 +133,16 @@ std::string getDefaultProfileGenName() {
  : "default_%m.profraw";
 }
 
+// Path and name of file used for profile generation
+std::string getProfileGenName(const CodeGenOptions &CodeGenOpts) {
+  std::string FileName = CodeGenOpts.InstrProfileOutput.empty()
+ ? getDefaultProfileGenName()
+ : CodeGenOpts.InstrProfileOutput;
+  if (CodeGenOpts.ContinuousProfileSync)
+FileName = "%c" + FileName;
+  return FileName;
+}
+
 class EmitAssemblyHelper {
   CompilerInstance &CI;
   DiagnosticsEngine &Diags;
@@ -550,7 +560,9 @@ getInstrProfOptions(const CodeGenOptions &CodeGenOpts,
 return std::nullopt;
   InstrProfOptions Options;
   Options.NoRedZone = CodeGenOpts.DisableRedZone;
-  Options.InstrProfileOutput = CodeGenOpts.InstrProfileOutput;
+  Options.InstrProfileOutput = CodeGenOpts.ContinuousProfileSync
+   ? ("%c" + CodeGenOpts.InstrProfileOutput)
+   : CodeGenOpts.InstrProfileOutput;
   Options.Atomic = CodeGenOpts.AtomicProfileUpdate;
   return Options;
 }
@@ -811,13 +823,12 @@ void EmitAssemblyHelper::RunOptimizationPipeline(
 
   if (CodeGenOpts.hasProfileIRInstr())
 // -fprofile-generate.
-PGOOpt = PGOOptions(
-CodeGenOpts.InstrProfileOutput.empty() ? getDefaultProfileGenName()
-   : 
CodeGenOpts.InstrProfileOutput,
-"", "", CodeGenOpts.MemoryProfileUsePath, nullptr, PGOOptions::IRInstr,
-P

[clang] [PGO] Add a clang option -fprofile-continuous that enables PGO continuous mode (PR #124353)

2025-01-27 Thread Wael Yehia via cfe-commits


@@ -133,6 +133,16 @@ std::string getDefaultProfileGenName() {
  : "default_%m.profraw";
 }
 
+// Path and name of file used for profile generation
+std::string getProfileGenName(const CodeGenOptions &CodeGenOpts) {

w2yehia wrote:

sure. FYI I was following the style used by getDefaultProfileGenName above

https://github.com/llvm/llvm-project/pull/124353
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [PGO] Add a clang option -fprofile-continuous that enables PGO continuous mode (PR #124353)

2025-01-27 Thread Wael Yehia via cfe-commits


@@ -785,6 +786,34 @@ static void addPGOAndCoverageFlags(const ToolChain &TC, 
Compilation &C,
   D.Diag(diag::err_drv_unsupported_option_argument)
   << A->getSpelling() << Val;
   }
+  if (const auto *A = Args.getLastArg(options::OPT_fprofile_continuous)) {
+if (!PGOGenerateArg && !CSPGOGenerateArg && !ProfileGenerateArg)
+  D.Diag(clang::diag::err_drv_argument_only_allowed_with)
+  << A->getSpelling()
+  << "-fprofile-generate, -fprofile-instr-generate, or "
+ "-fcs-profile-generate";
+else {
+  CmdArgs.push_back("-fprofile-continuous");
+  // Platforms that require a bias variable:
+  if (T.isOSFuchsia() || T.isOSBinFormatELF() || T.isOSAIX()) {
+CmdArgs.push_back("-mllvm");

w2yehia wrote:

I see, I didn't know Fuchsia uses ELF.
So if `T.isOSBinFormatELF()` subsumes `T.isOSFuchsia()` then we can remove 
`T.isOSFuchsia()`.

I tried to copy the conditions that the 
[runtime](https://github.com/llvm/llvm-project/blob/main/compiler-rt/lib/profile/InstrProfilingFile.c#L199)
 uses for when runtime relocation is needed:
`#elif defined(__ELF__) || defined(_WIN32) || defined(_AIX)`

Fuchsia 
[uses](https://github.com/llvm/llvm-project/blob/5815a311050ae218ebcda53adeee24ed96851943/compiler-rt/lib/profile/InstrProfilingPlatformFuchsia.c#L183)
 runtime relocation AFAIU.

> This condition will add -runtime-counter-relocation to all ELF targets, which 
> I think is not desired.
Continuous mode is not supported on many platforms, so the ELF targets that do 
not support it will not care if we pass the runtime-relocation or not. 
I didn't filter out unsupported plaftforms via a diagnostic in this patch. If 
it's desirable to do so, I can add a diagnostic.
Please advice.

https://github.com/llvm/llvm-project/pull/124353
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [PGO] Add a clang option -fprofile-continuous that enables PGO continuous mode (PR #124353)

2025-01-27 Thread Wael Yehia via cfe-commits

https://github.com/w2yehia edited 
https://github.com/llvm/llvm-project/pull/124353
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [PGO] Add a clang option -fprofile-continuous that enables PGO continuous mode (PR #124353)

2025-01-27 Thread Wael Yehia via cfe-commits


@@ -0,0 +1,16 @@
+// RUN: %clang %s -S -emit-llvm -fprofile-generate -fprofile-continuous -o - | 
FileCheck %s --check-prefix=IRPGO

w2yehia wrote:

In this test, I'm testing both the driver (lines 4,5,8) and the clang codegen 
(lines 1,2,3,6).
Should I split it into 2 files, one for each stage?

https://github.com/llvm/llvm-project/pull/124353
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [PGO] Add a clang option -fprofile-continuous that enables PGO continuous mode (PR #124353)

2025-01-29 Thread Wael Yehia via cfe-commits

https://github.com/w2yehia edited 
https://github.com/llvm/llvm-project/pull/124353
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [profile] Add a clang option -fprofile-continuous that enables continuous instrumentation profiling mode (PR #124353)

2025-02-08 Thread Wael Yehia via cfe-commits

w2yehia wrote:

thanks @MaskRay 

https://github.com/llvm/llvm-project/pull/124353
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [profile] Add a clang option -fprofile-continuous that enables continuous instrumentation profiling mode (PR #124353)

2025-02-08 Thread Wael Yehia via cfe-commits

w2yehia wrote:

> LLVM Buildbot has detected a new failure on builder `clang-m68k-linux-cross` 
> running on `suse-gary-m68k-cross` while building `clang` at step 4 "build 
> stage 1".

Unrelated or noise. That buildbot had the exact failure few drivers 
[earlier](https://lab.llvm.org/buildbot/#/builders/27/builds/5835/steps/4/logs/stdio).

https://github.com/llvm/llvm-project/pull/124353
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


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

2025-02-19 Thread Wael Yehia via cfe-commits

https://github.com/w2yehia created 
https://github.com/llvm/llvm-project/pull/127858

Continuous profiling syncing is [supported on 
windows,](https://github.com/llvm/llvm-project/pull/124353#issuecomment-2649075857)
 and it also relies on runtime counter relocation (based on this 
[test](https://github.com/llvm/llvm-project/blob/main/compiler-rt/test/profile/ContinuousSyncMode/runtime-counter-relocation.c))

Thanks to @anhtuyenibm for pointing it out to me.

>From 843f78e9826b037a7bfb0913728a11eb249f4181 Mon Sep 17 00:00:00 2001
From: Wael Yehia 
Date: Wed, 19 Feb 2025 06:25:16 +
Subject: [PATCH] [profile] runtime counter relocation is needed on
 windows-msvc targets

---
 clang/lib/Driver/ToolChains/Clang.cpp   | 2 +-
 clang/test/Driver/fprofile-continuous.c | 1 +
 2 files changed, 2 insertions(+), 1 deletion(-)

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

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


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

2025-02-19 Thread Wael Yehia via cfe-commits

w2yehia wrote:

> Doesn't mingw target support it?

Sorry I don't know. I was hoping someone familiar with clang on windows to 
comment.

https://github.com/llvm/llvm-project/pull/127858
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


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

2025-02-19 Thread Wael Yehia via cfe-commits

https://github.com/w2yehia updated 
https://github.com/llvm/llvm-project/pull/127858

>From 843f78e9826b037a7bfb0913728a11eb249f4181 Mon Sep 17 00:00:00 2001
From: Wael Yehia 
Date: Wed, 19 Feb 2025 06:25:16 +
Subject: [PATCH 1/2] [profile] runtime counter relocation is needed on
 windows-msvc targets

---
 clang/lib/Driver/ToolChains/Clang.cpp   | 2 +-
 clang/test/Driver/fprofile-continuous.c | 1 +
 2 files changed, 2 insertions(+), 1 deletion(-)

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

>From c984182fd2957563ef5cd4b7bc4525dc3bb185d8 Mon Sep 17 00:00:00 2001
From: Wael Yehia 
Date: Wed, 19 Feb 2025 19:55:19 +
Subject: [PATCH 2/2] clang-format

---
 clang/lib/Driver/ToolChains/Clang.cpp | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/clang/lib/Driver/ToolChains/Clang.cpp 
b/clang/lib/Driver/ToolChains/Clang.cpp
index 3f76d034ee308..e7acc3f55267d 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -795,7 +795,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() || 
T.isKnownWindowsMSVCEnvironment()) {
+  if (T.isOSBinFormatELF() || T.isOSAIX() ||
+  T.isKnownWindowsMSVCEnvironment()) {
 CmdArgs.push_back("-mllvm");
 CmdArgs.push_back("-runtime-counter-relocation");
   }

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


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

2025-02-24 Thread Wael Yehia via cfe-commits

https://github.com/w2yehia closed 
https://github.com/llvm/llvm-project/pull/127858
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


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

2025-02-20 Thread Wael Yehia via cfe-commits


@@ -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

w2yehia wrote:

_WIN32 doesn't indicate it's only for 32-bit: 
[source](https://accu.org/journals/overload/24/132/wilson_2223/)
i.e. the compiler-rt code is active in both 32-bit and 64-bit compilations of 
the runtime on Windows.

https://github.com/llvm/llvm-project/pull/127858
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


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

2025-02-20 Thread Wael Yehia via cfe-commits

https://github.com/w2yehia edited 
https://github.com/llvm/llvm-project/pull/127858
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


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

2025-03-11 Thread Wael Yehia via cfe-commits

w2yehia wrote:

> 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. 
The feature 
[mmap's](https://github.com/llvm/llvm-project/blob/main/compiler-rt/lib/profile/InstrProfilingFile.c#L273)
 the profile file rather than writing it at program exit (the default 
non-continuous mode behavior). There are two implementations in 
`InstrProfilingFile.c`, 
[one](https://github.com/llvm/llvm-project/blob/main/compiler-rt/lib/profile/InstrProfilingFile.c#L160)
 that mmap's onto existing memory, and 
[another](https://github.com/llvm/llvm-project/blob/main/compiler-rt/lib/profile/InstrProfilingFile.c#L273)
 that mmap's without an address hint. The latter relies on a corresponding 
compiler action (added in 
[this](https://github.com/llvm/llvm-project/commit/d3db13af7e5c01632fbf28149a2d4f9c4841aeba)
 commit), which is enabled using `-mllvm -runtime-counter-relocation`. 

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 `-runtime-counter-relocation` to the 
backend on certain platforms.
This PR added `T.isKnownWindowsMSVCEnvironment()` to the conditions under which 
the drivers passes `-runtime-counter-relocation` to the backend, and the 
question is whether this is sufficient for windows or more changes to the 
conditions are needed. 
Note if we miss a condition/configuration then it doesn't break the feature 
there, it just would 
[fail](https://github.com/llvm/llvm-project/blob/main/compiler-rt/lib/profile/InstrProfilingFile.c#L662)
 at runtime if you try enabling using this new clang option 
(-fprofile-continuous).

https://github.com/llvm/llvm-project/pull/127858
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 9ef7287 - [profile] runtime counter relocation needed on all windows targets (#127858)

2025-03-11 Thread Wael Yehia via cfe-commits

Author: Wael Yehia
Date: 2025-03-12T03:13:33Z
New Revision: 9ef7287d42526014abb0cf2aa53ac2c3087198be

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

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

See PR comments for the discussion that led to this commit.

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 4ebbd241d2f0b..a6a96286e9857 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -762,8 +762,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() ||
-  T.isKnownWindowsMSVCEnvironment()) {
+  if (T.isOSBinFormatELF() || T.isOSAIX() || T.isOSWindows()) {
 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 cc8e56c8f9fe0..b76f2cd2fe3b8 100644
--- a/clang/test/Driver/fprofile-continuous.c
+++ b/clang/test/Driver/fprofile-continuous.c
@@ -7,6 +7,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
+// RUN: %clang --target=x86_64-windows-gnu -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


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

2025-03-11 Thread Wael Yehia via cfe-commits

w2yehia wrote:

@mstorsjo FYI: https://github.com/llvm/llvm-project/commit/9ef7287d425

https://github.com/llvm/llvm-project/pull/127858
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


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

2025-03-11 Thread Wael Yehia via cfe-commits

w2yehia wrote:

> So I believe this should be generalized to all of Windows (and/or generalized 
> to check for a COFF object file format?) instead of singling out specifically 
> MSVC only.

Thanks for checking. I can fix the condition but can you please let me know 
which of the two options you listed is better?

https://github.com/llvm/llvm-project/pull/127858
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits