Files
RedBear-OS/local/recipes/dev/libclc/source/clang/test/CodeGen/homogeneous-aggregates.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

96 lines
4.1 KiB
C

// REQUIRES: arm-registered-target,aarch64-registered-target,powerpc-registered-target
// RUN: %clang_cc1 -triple thumbv7-none-none -mfloat-abi hard -x c -emit-llvm -o - %s | FileCheck %s --check-prefix=AAPCS
// RUN: %clang_cc1 -triple thumbv7-none-none -mfloat-abi hard -x c++ -emit-llvm -o - %s | FileCheck %s --check-prefix=AAPCS
// RUN: %clang_cc1 -triple thumbv7-none-none -mfloat-abi hard -x c++ -DEXTERN_C -emit-llvm -o - %s | FileCheck %s --check-prefix=AAPCS
// RUN: %clang_cc1 -triple aarch64-none-none -mfloat-abi hard -x c -emit-llvm -o - %s | FileCheck %s --check-prefix=AAPCS
// RUN: %clang_cc1 -triple aarch64-none-none -mfloat-abi hard -x c++ -emit-llvm -o - %s | FileCheck %s --check-prefix=AAPCS
// RUN: %clang_cc1 -triple aarch64-none-none -mfloat-abi hard -x c++ -DEXTERN_C -emit-llvm -o - %s | FileCheck %s --check-prefix=AAPCS
// RUN: %clang_cc1 -triple powerpc64le-none-none -mfloat-abi hard -x c -emit-llvm -o - %s | FileCheck %s --check-prefix=PPC --check-prefix=PPC-C
// RUN: %clang_cc1 -triple powerpc64le-none-none -mfloat-abi hard -x c++ -emit-llvm -o - %s | FileCheck %s --check-prefix=PPC --check-prefix=PPC-CXX
// RUN: %clang_cc1 -triple powerpc64le-none-none -mfloat-abi hard -x c++ -DEXTERN_C -emit-llvm -o - %s | FileCheck %s --check-prefix=PPC --check-prefix=PPC-CXX
// The aim here is to test whether each of these structure types is
// regarded as a homogeneous aggregate of a single kind of
// floating-point item, because in all of these ABIs, that changes the
// calling convention.
//
// We expect that 'Floats' and 'Doubles' are homogeneous, and 'Mixed'
// is not. But the next two structures, with separating zero-size
// bitfields, are more interesting.
//
// For the Arm architecture, AAPCS says that the homogeneity rule is
// applied _after_ data layout is completed, so that it's unaffected
// by anything that was completely discarded during data layout. So we
// expect that FloatsBF and DoublesBF still count as homogeneous.
//
// But on PowerPC, it depends on whether the source language is C or
// C++, because that's consistent with the decisions gcc makes.
struct Floats {
float a;
float b;
};
struct Doubles {
double a;
double b;
};
struct Mixed {
double a;
float b;
};
struct FloatsBF {
float a;
int : 0;
float b;
};
struct DoublesBF {
double a;
int : 0;
double b;
};
// In C++ mode, we test both with and without extern "C", to ensure
// that doesn't make a difference.
#ifdef EXTERN_C
#define LINKAGE extern "C"
#else
#define LINKAGE
#endif
// For Arm backends, the IR emitted for the homogeneous-aggregate
// return convention uses the actual structure type, so that
// HandleFloats returns a %struct.Floats, and so on. To check that
// 'Mixed' is not treated as homogeneous, it's enough to check that
// its return type is _not_ %struct.Mixed. (The fallback handling
// varies between AArch32 and AArch64.)
//
// For PowerPC, homogeneous structure types are lowered to an IR array
// types like [2 x float], and the non-homogeneous Mixed is lowered to
// a pair of i64.
// AAPCS: define{{.*}} %struct.Floats @{{.*HandleFloats.*}}
// PPC: define{{.*}} [2 x float] @{{.*HandleFloats.*}}
LINKAGE struct Floats HandleFloats(struct Floats x) { return x; }
// AAPCS: define{{.*}} %struct.Doubles @{{.*HandleDoubles.*}}
// PPC: define{{.*}} [2 x double] @{{.*HandleDoubles.*}}
LINKAGE struct Doubles HandleDoubles(struct Doubles x) { return x; }
// AAPCS-NOT: define{{.*}} %struct.Mixed @{{.*HandleMixed.*}}
// PPC: define{{.*}} { i64, i64 } @{{.*HandleMixed.*}}
LINKAGE struct Mixed HandleMixed(struct Mixed x) { return x; }
// AAPCS: define{{.*}} %struct.FloatsBF @{{.*HandleFloatsBF.*}}
// PPC-C-NOT: define{{.*}} [2 x float] @{{.*HandleFloatsBF.*}}
// PPC-CXX: define{{.*}} [2 x float] @{{.*HandleFloatsBF.*}}
LINKAGE struct FloatsBF HandleFloatsBF(struct FloatsBF x) { return x; }
// AAPCS: define{{.*}} %struct.DoublesBF @{{.*HandleDoublesBF.*}}
// PPC-C-NOT: define{{.*}} [2 x double] @{{.*HandleDoublesBF.*}}
// PPC-CXX: define{{.*}} [2 x double] @{{.*HandleDoublesBF.*}}
LINKAGE struct DoublesBF HandleDoublesBF(struct DoublesBF x) { return x; }