Files
RedBear-OS/local/recipes/dev/libclc/source/compiler-rt/test/profile/instrprof-dump.c
T
vasilito cb424d7448 build: static patch-sanity linter (shift-left the malformed-patch class)
verify-patch-sanity.py validates every active recipe .patch has internally-
consistent hunk line counts — catching the 'malformed patch at line N' failure
at commit/CI/preflight time instead of hours into a cook. This cycle hit that
class three times (qtwaylandscanner, sddm, xwayland), each only discovered when
cookbook tried to apply the patch.

Running it across the repo found 29 latent malformed patches (validated against
GNU patch: e.g. relibc/P3-sysv-ipc reproduces 'malformed patch at line 22').
They were harmless only because they sit in vendored recipes (baked, not re-
applied) — but would fail on any version-bump re-derivation. --fix recounts the
hunk headers (body untouched) and repaired all 29.

Wired into build-preflight.sh (Phase 1.0D) and redbear-ci.yml, with a unit test
(test-patch-sanity.sh). Skips archived/legacy trees and unvalidatable formats
(empty placeholders, bare-@@ git hunks).
2026-08-01 05:13:02 +03:00

63 lines
1.6 KiB
C

/*
RUN: rm -fr %t.profdir
RUN: %clang_profgen=%t.profdir/default_%m.profraw -o %t -O2 %s
RUN: %run %t 2>&1 | FileCheck %s --check-prefix=NO_EXIT_WRITE
RUN: llvm-profdata merge -o %t.profdata %t.profdir
RUN: %clang_profuse=%t.profdata -o - -S -emit-llvm %s | FileCheck %s --check-prefix=PROF
NO_EXIT_WRITE: Profile data not written to file: already written
*/
int __llvm_profile_dump(void);
void __llvm_profile_reset_counters(void);
int foo(int);
int bar(int);
int skip(int);
int main(int argc, const char *argv[]) {
int Ret = foo(0); /* region 1 */
__llvm_profile_dump();
/* not profiled -- cleared later. */
skip(0); /* skipped region */
__llvm_profile_reset_counters();
Ret += bar(0); /* region 2 */
__llvm_profile_dump();
skip(1);
__llvm_profile_reset_counters();
/* foo's profile will be merged. */
foo(1); /* region 3 */
__llvm_profile_dump();
return Ret;
}
__attribute__((noinline)) int foo(int X) {
/* PROF: define {{.*}} @foo({{.*}}!prof ![[ENT:[0-9]+]]
PROF: br i1 %{{.*}}, label %{{.*}}, label %{{.*}}, !prof ![[PD1:[0-9]+]]
*/
return X <= 0 ? -X : X;
}
__attribute__((noinline)) int skip(int X) {
/* PROF: define {{.*}} @skip(
PROF: br i1 %{{.*}}, label %{{.*}}, label %{{[^,]+$}}
*/
return X <= 0 ? -X : X;
}
__attribute__((noinline)) int bar(int X) {
/* PROF-LABEL: define {{.*}} @bar(
PROF: br i1 %{{.*}}, label %{{.*}}, label %{{.*}}, !prof ![[PD2:[0-9]+]]
*/
return X <= 0 ? -X : X;
}
/*
PROF: ![[ENT]] = !{!"function_entry_count", i64 2}
PROF: ![[PD1]] = !{!"branch_weights", i32 2, i32 2}
*/