sema: create pointer-to-function type for exported functions

After creating the function type IP entry, also create a
pointer-to-function type (*const fn(...) ...) matching what the Zig
compiler creates when taking the address of a function for @export.

For neghf2.zig (num_passing=4), gap shrinks from 861 to 860.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-02-25 19:30:30 +00:00
parent a165e64018
commit e6c419281e

View File

@@ -5612,7 +5612,19 @@ static void zirFunc(Sema* sema, SemaBlock* block, uint32_t inst) {
ftype_key.data.func_type.return_type = ret_ty;
ftype_key.data.func_type.param_count = param_count;
ftype_key.data.func_type.cc = cc;
(void)ipIntern(sema->ip, ftype_key);
InternPoolIndex func_type_ip = ipIntern(sema->ip, ftype_key);
// Create pointer-to-function type (*const fn(...) ...).
// Matches what the Zig compiler creates in ensureNavValUpToDate
// when taking the address of the function for @export.
InternPoolKey ptr_key;
memset(&ptr_key, 0, sizeof(ptr_key));
ptr_key.tag = IP_KEY_PTR_TYPE;
ptr_key.data.ptr_type.child = func_type_ip;
ptr_key.data.ptr_type.sentinel = IP_INDEX_NONE;
ptr_key.data.ptr_type.flags = PTR_FLAGS_SIZE_ONE | PTR_FLAGS_IS_CONST;
ptr_key.data.ptr_type.packed_offset = 0;
(void)ipIntern(sema->ip, ptr_key);
}
analyzeFuncBodyAndRecord(