test: complete compiler performance regression coverage

- Record the new array fixture in the frontend parity baseline.
- Keep runtime ABI checks precise for optimized class brand probes.
This commit is contained in:
Chris Tate
2026-09-30 08:35:10 -05:00
parent 5b6a7ba83b
commit 43e4a4d534
3 changed files with 16 additions and 3 deletions
@@ -108,7 +108,7 @@ test("class brand probes borrow a local only across an inert literal key", () =>
const key: IrExpr = { kind: "strLit", value: "object:Example", type: STRING, loc: receiverLoc };
const probe: IrExpr = { kind: "libCall", fn: "dyn.typedRefIs", args: [ref(dyn), key], type: BOOL, loc: receiverLoc };
const borrowed = work(probe, dyn);
expect(borrowed).not.toContain("call ptr @scr_dyn_retain");
expect(borrowed).not.toContain("call ptr @scr_dyn_retain_v(");
expect(borrowed).toContain("icmp ne ptr");
expect(borrowed).toContain("icmp eq i32");
expect(borrowed).toContain("@scr_dyn_typed_ref_is_key");
@@ -118,7 +118,7 @@ test("class brand probes borrow a local only across an inert literal key", () =>
const computed = work({ ...probe, args: [ref(dyn), {
kind: "toString", operand: ref(dyn), type: STRING, loc: receiverLoc,
}] }, dyn);
expect(computed).toContain("call ptr @scr_dyn_retain");
expect(computed).toContain("call ptr @scr_dyn_retain_v(");
});
test("capture boxes keep their ordinary owned-read contract", () => {
@@ -199,7 +199,7 @@ interface LlDeclare {
/** `declare zeroext i1 @scr_x(ptr, i1 zeroext, ...)` → shape (parameter
* attributes stripped; only the type words matter for the C prototype). */
function parseDeclare(text: string): LlDeclare | undefined {
const m = /^declare\s+(.+?)\s*@([A-Za-z0-9_$.]+)\((.*)\)$/.exec(text.trim());
const m = /^declare\s+(.+?)\s*@([A-Za-z0-9_$.]+)\(([^()]*)\)(?:\s+.*)?$/.exec(text.trim());
if (!m) return undefined;
const ret = m[1]!.replace(/\b(zeroext|signext|noalias|nonnull)\b/g, " ").replace(/\s+/g, " ").trim();
const parts = m[3]!.trim() === "" ? [] : m[3]!.split(",").map((p) =>
@@ -227,6 +227,13 @@ function checkDeclare(d: LlDeclare, protos: Map<string, CProto>): string | undef
}
describe("LLVM backend declares match scr_runtime.h prototypes", () => {
test("function memory attributes do not change the declared ABI", async () => {
const declaration = parseDeclare("declare zeroext i1 @scr_dyn_typed_ref_is_key(ptr, ptr) memory(read)");
expect(declaration).toEqual({ ret: "i1", name: "scr_dyn_typed_ref_is_key", params: ["ptr", "ptr"], variadic: false });
const { protos } = await parseHeader();
expect(checkDeclare(declaration!, protos)).toBeUndefined();
});
test("externally linkable objects reference the versioned runtime marker", async () => {
const loc = { file: "/source/abi-marker.ts", start: 0, end: 0 };
const mod: IrModule = {
@@ -8698,6 +8698,12 @@
],
"diags": []
},
"<repo>/tests/corpus/array-truncate-reuse.ts": {
"order": [
"<repo>/tests/corpus/array-truncate-reuse.ts"
],
"diags": []
},
"<repo>/tests/corpus/async-backend-factory.mjs": {
"order": [
"<repo>/tests/corpus/async-backend-factory.mjs"