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

Fangrui Song via cfe-commits cfe-commits at lists.llvm.org
Wed Jan 29 21:15:45 PST 2025


================
@@ -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'
----------------
MaskRay wrote:

Remove `clang: `

Some users might customize the executable name. We have a convention to just omit `clang: ` when testing `error:`

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


More information about the cfe-commits mailing list