Repository navigation
Windows: modules other than gc share the process heap; attributes named once; Debug DEBUG_TYPE fix - #412
Merged
Conversation
…helper #407 included MLIRRTTIHelperVC.h after MLIRGenImpl.h, and the helper undefines DEBUG_TYPE on the way out, so every LLVM_DEBUG in the file was an error in a Debug build (Release compiles LLVM_DEBUG away, so CI never saw it). MLIRGenStatements.cpp does the same after the same include. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
`@dllname("strlen") @Linkname("strlen")` both become DLL_NAME, and
processFunctionAttributes pushed it once per decorator. Two entries of one
name are an assert in a Debug build ("DictionaryAttr element names must be
unique", test-{compile,jit}-declare-linkname-shared-symbol) and print twice
in Release. checkLinkNameDecorators has already made sure they agree, so the
first stands; the same holds for any decorator written twice.
New test: --emit=mlir of declare_linkname_shared_symbol.ts fails on a
repeated dllname.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
ASDAlexander77
added a commit
that referenced
this pull request
Oct 6, 2026
The -mm=none frame allocator check looked for aligned_alloc(i32, i32). Since #412 ProcessHeapPass renames it on Windows, under every model but gc, to the process-heap allocator __tslang_heap_aligned_alloc, which keeps the 32-bit size_t signature AsyncTargetWidthPass gave it. The check now requires that name with both parameters i32. await_order expected "after await" before "in g", recorded when an await of a void async function did not wait. Since #497 main waits on g()'s token, so "in g" always prints first (300/300 runs, x86 and x64). Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Three fixes found by running the Debug build locally on the cross-module (
-shared, async,@linkname) tests. Those tests had 19 failures in Debug.1. Windows: every module but gc allocates from the process heap
A block made in one module is often freed in another. Two examples:
-mm=rcand-mm=own, an object of a library's class is made in the library and destroyed by the program;On Windows the C runtime does not give these modules one allocator:
mallocintslang.exeandTypeScriptRuntime.dllis rpmalloc.The fix:
ProcessHeapPassruns on Windows (not wasm) when the model is not gc; gc already hasGCPass.malloc,calloc,realloc,free,aligned_allocandaligned_freeto__tslang_heap_*. It changes both calls and address-of uses, such as a destructor slot.include/TypeScript/ProcessHeap.his header-only and wrapsHeapAlloc,HeapReAllocandHeapFree:realloc(p, 0)frees the block and returns null, as UCRT does;aligned_allocfails for an alignment aboveMEMORY_ALLOCATION_ALIGNMENTrather than return under-aligned memory.lib/ProcessHeapExports.incexports the helpers from three places, all from the same code:TypeScriptRuntime.dll(listed in the.def);MemRuntime.cpp(Alloc,AlignedAlloc,Free,AlignedFree) uses the process heap on Windows in every build.The pass must mark the helpers as allocators. The first version renamed the functions and nothing else. After that, DefaultLib under rc double-freed. The renamed functions had lost what LLVM knows about
mallocby name, so LLVM stopped deleting allocations whose only use is being freed, and that exposed double frees the deletion had been hiding. Each helper now gets the same attributes the C functions get:allockind;"alloc-family"="malloc";allocptron the argument of free and realloc;2. Debug assert: "DictionaryAttr element names must be unique"
processFunctionAttributescould add the same attribute twice, for exampledllnameon a@linknamedeclaration used from a-sharedmodule. Each attribute name is now added once.test-declare-linkname-attribute-once.3. Debug build:
MLIRGenCast.cppdefinesDEBUG_TYPEagain after the RTTI helperThe RTTI helper undefines
DEBUG_TYPEon its way out, which broke the Debug build. This is the same commit as in #411; whichever PR merges second will have nothing to apply for it.Test results
shared|async|linkname): 352/352 (19 failures before)🤖 Generated with Claude Code