llvm-project
e07d245e - [MCParser] .incbin: Don't retain the buffer, don't require NUL termination (#196696)

Commit
1 day ago
[MCParser] .incbin: Don't retain the buffer, don't require NUL termination (#196696) processIncbinFile uses SourceMgr::AddIncludeFile, which * sets `RequiresNullTerminator=true` and disable `mmap` when the file size is a multiple of the page size, * and unnecessarily retains the throwaway buffer in `Buffers`. Switch to OpenIncludeFile so the buffer is freed when processIncbinFile returns, and pass RequiresNullTerminator=false. The buffer is consumed only by emitBytes; the lexer never scans it, so it does not need a trailing '\0' (different from #154972). Without that requirement, MemoryBuffer mmaps the file and RSS tracks only the touched pages. Stress test (1000 .incbin "blob.bin", 0, 16 against a 1 MiB blob): ``` Maximum RSS Before 1042944 KiB After 15360 KiB ``` Fix #62339
Author
Parents
Loading