Files
RedBear-OS/local/recipes/dev/libclc/source/llvm/test/Verifier/tbaa.ll
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

129 lines
4.9 KiB
LLVM

; RUN: not llvm-as < %s 2>&1 | FileCheck %s
; RUN: llvm-as -disable-verify < %s | opt -passes=verify -S | FileCheck %s --check-prefix=STRIP
; STRIP-NOT: tbaa
; STRIP: @f_0
; STRIP: Do no strip this
define void @f_0(ptr %ptr) {
; This part checks for the easy syntactic verifier rules.
; CHECK: Struct tag metadata must have either 3 or 4 operands
; CHECK-NEXT: store i32 0, ptr %ptr, align 4, !tbaa !{{[0-9]+}}
; CHECK: Immutability tag on struct tag metadata must be a constant
; CHECK-NEXT: store i32 1, ptr %ptr, align 4, !tbaa !{{[0-9]+}}
; CHECK: Immutability part of the struct tag metadata must be either 0 or 1
; CHECK-NEXT: store i32 2, ptr %ptr, align 4, !tbaa !{{[0-9]+}}
; CHECK: Offset must be constant integer
; CHECK-NEXT: store i32 3, ptr %ptr, align 4, !tbaa !{{[0-9]+}}
; CHECK: Malformed struct tag metadata: base and access-type should be non-null and point to Metadata nodes
; CHECK-NEXT: store i32 4, ptr %ptr, align 4, !tbaa !{{[0-9]+}}
; CHECK: Access type node must be a valid scalar type
; CHECK-NEXT: store i32 5, ptr %ptr, align 4, !tbaa !{{[0-9]+}}
; CHECK: Access bit-width not the same as description bit-width
; CHECK-NEXT: store i32 6, ptr %ptr, align 4, !tbaa !{{[0-9]+}}
; CHECK: Access type node must be a valid scalar type
; CHECK-NEXT: store i32 7, ptr %ptr, align 4, !tbaa !{{[0-9]+}}
; CHECK: Struct tag nodes have a string as their first operand
; CHECK-NEXT: !{{[0-9]+}} = !{!{{[0-9]+}}, !{{[0-9]+}}, i64 0}
; CHECK: Access type node must be a valid scalar type
; CHECK-NEXT: store i32 9, ptr %ptr, align 4, !tbaa !{{[0-9]+}}
; CHECK: TBAA metadata cannot have 0 operands
; CHECK-NEXT: store i32 10, ptr %ptr, align 4, !tbaa !{{[0-9]+}}
store i32 0, ptr %ptr, !tbaa !{!3, !2, i64 40, i64 0, i64 1, i64 2}
store i32 1, ptr %ptr, !tbaa !{!3, !2, i64 40, !"immutable"}
store i32 2, ptr %ptr, !tbaa !{!3, !2, i64 40, i64 4}
store i32 3, ptr %ptr, !tbaa !{!3, !2, !"40", i64 0}
store i32 4, ptr %ptr, !tbaa !{!3, null, !"40", i64 0}
store i32 5, ptr %ptr, !tbaa !{!3, !3, !"40", i64 0}
store i32 6, ptr %ptr, !tbaa !{!3, !2, i32 40, i64 0}
store i32 7, ptr %ptr, !tbaa !{!3, !12, i32 40, i64 0}, !metadata !42
store i32 8, ptr %ptr, !tbaa !{!13, !1, i64 0}
store i32 9, ptr %ptr, !tbaa !{!14, !14, i64 0}
store i32 10, ptr %ptr, !tbaa !15
ret void
}
!42 = !{!"Do no strip this!"}
define void @f_1(ptr %ptr) {
; This part checks for more semantic verifier rules.
; CHECK: Cycle detected in struct path
; CHECK-NEXT: store i32 0, ptr %ptr, align 4, !tbaa !{{[0-9]+}}
; CHECK: Offset not zero at the point of scalar access
; CHECK-NEXT: store i32 1, ptr %ptr, align 4, !tbaa !{{[0-9]+}}
; CHECK: Offset not zero at the point of scalar access
; CHECK-NEXT: store i32 2, ptr %ptr, align 4, !tbaa !{{[0-9]+}}
; CHECK: Could not find TBAA parent in struct type node
; CHECK-NEXT: store i32 3, ptr %ptr, align 4, !tbaa !{{[0-9]+}}
; CHECK: Did not see access type in access path!
; CHECK-NEXT: store i32 3, ptr %ptr, align 4, !tbaa !{{[0-9]+}}
; CHECK: Access type node must be a valid scalar type
; CHECK-NEXT: store i32 4, ptr %ptr, align 4, !tbaa !{{[0-9]+}}
; CHECK: Access type node must be a valid scalar type
; CHECK-NEXT: store i32 5, ptr %ptr, align 4, !tbaa !{{[0-9]+}}
; CHECK: Access type node must be a valid scalar type
; CHECK-NEXT: store i32 6, ptr %ptr, align 4, !tbaa !{{[0-9]+}}
; CHECK: Struct tag nodes must have an odd number of operands!
; CHECK-NEXT:!{{[0-9]+}} = !{!"bad-struct-type-0", !{{[0-9]+}}, i64 40, !{{[0-9]+}}}
; CHECK: Incorrect field entry in struct type node!
; CHECK-NEXT: store i32 8, ptr %ptr, align 4, !tbaa !{{[0-9]+}}
; CHECK: Bitwidth between the offsets and struct type entries must match
; CHECK-NEXT: store i32 9, ptr %ptr, align 4, !tbaa !{{[0-9]+}}
; CHECK: Offsets must be increasing!
; CHECK-NEXT: store i32 10, ptr %ptr, align 4, !tbaa !{{[0-9]+}}
store i32 0, ptr %ptr, !tbaa !{!4, !2, i64 40}
store i32 1, ptr %ptr, !tbaa !{!3, !2, i64 45}
store i32 2, ptr %ptr, !tbaa !{!3, !2, i64 45}
store i32 3, ptr %ptr, !tbaa !{!3, !2, i64 10}
store i32 4, ptr %ptr, !tbaa !{!5, !5, i64 0}
store i32 5, ptr %ptr, !tbaa !{!6, !6, i64 0}
store i32 6, ptr %ptr, !tbaa !{!7, !7, i64 0}
store i32 7, ptr %ptr, !tbaa !{!8, !1, i64 40}
store i32 8, ptr %ptr, !tbaa !{!9, !1, i64 40}
store i32 9, ptr %ptr, !tbaa !{!10, !1, i64 40}
store i32 10, ptr %ptr, !tbaa !{!11, !1, i64 40}
ret void
}
!0 = !{!"root"}
!1 = !{!"scalar-a", !0}
!2 = !{!"scalar-b", !0}
!3 = !{!"struct-a", !2, i64 20, !1, i64 40}
!4 = distinct !{!"self-recursive-struct", !2, i64 20, !4, i64 40}
!5 = !{!"bad-scalar-0", i64 40}
!6 = !{i64 42, !0}
!7 = !{!"bad-scalar-1", null}
!8 = !{!"bad-struct-type-0", !1, i64 40, !1}
!9 = !{!"bad-struct-type-1", !1, i64 40, i64 56, !1}
!10 = !{!"bad-struct-type-2", !1, i64 40, !1, i32 56}
!11 = !{!"bad-struct-type-2", !1, i64 80, !1, i64 56}
!12 = !{!"bad-scalar-2", !3, i64 0}
!13 = !{!1, !1, i64 0}
!14 = !{!"bad-scalar-2", !13}
!15 = !{}