mirror of
https://github.com/vercel-labs/scriptc.git
synced 2026-10-22 05:59:31 +08:00
Decide inline truncation for the host when no triple is given
The Node-hosted CLI emits with an empty target triple (the host), while the native CLI passes its toolchain's triple. Inline truncation keyed on the triple text alone, so on x86-64 Linux the Node seed emitted llvm.trunc and the native compiler emitted the inline sequence, and the native bootstrap's LLVM comparison with the Node seed failed (self-hosting-native-driver, rebuild-emit). An empty triple now means the host architecture, as it already does for executable TLS; WASI keeps the intrinsic. The DataView emission test accepts either truncation form, since it runs on hosts of both kinds.
This commit is contained in:
@@ -811,7 +811,14 @@ export class LlEmitter {
|
||||
this.ffiExtendNarrowIntegers =
|
||||
options.wasi === true || ffiExtendsNarrowIntegers(options.targetTriple);
|
||||
this.wasi = options.wasi === true;
|
||||
this.inlineTrunc = /^(x86_64|amd64)\b/i.test(options.targetTriple ?? "");
|
||||
// An empty triple targets the host, as for executableTls below: the
|
||||
// Node-hosted CLI passes none, the native CLI passes its toolchain's, and
|
||||
// both must emit the same module for the same target.
|
||||
this.inlineTrunc =
|
||||
!this.wasi &&
|
||||
(options.targetTriple
|
||||
? /^(x86_64|amd64)\b/i.test(options.targetTriple)
|
||||
: process.arch === "x64");
|
||||
this.executableTls =
|
||||
mod.workers === true &&
|
||||
mod.lib === undefined &&
|
||||
|
||||
@@ -45,7 +45,8 @@ test("numeric byte pipelines retain checked fallbacks and use field widths on bo
|
||||
expect(wide).toContain("phi i64");
|
||||
expect(wide).toContain("@llvm.bswap.i64");
|
||||
const offsets = body(ll, "offsets");
|
||||
expect(offsets).toContain("@llvm.trunc.f64");
|
||||
// Truncation is the intrinsic, or inline on an x86-64 host (trunc.ts).
|
||||
expect(offsets).toMatch(/@llvm\.trunc\.f64|@llvm\.copysign\.f64/);
|
||||
expect(offsets).toContain("@scr_dataview_set");
|
||||
expect(offsets).toContain("@scr_dataview_get");
|
||||
expect(offsets).toMatch(/icmp ule i(?:32|64)/);
|
||||
|
||||
Reference in New Issue
Block a user