Skip to content

The bitcode format writes each module to a temporary file, then reads and parses it #273

Open

Description

@SizzleUnrlsd

Summary

In the bc format of --compile-ir-format, the default, each source is compiled to a temporary .bc file. The analyzer then reads that file into a string, copies the string into a buffer and parses the buffer into its module (InputPipeline.cpp L907-L918 and L1155-L1198 at db7fb25). coretrace-compiler held that module in memory before it wrote the file.

CoreTrace/coretrace-compiler#265, a draft, adds compileToModule: it gives the module of a compilation, created in the caller's llvm::LLVMContext, and writes no output file.

Measured on macOS arm64 (M3, 8 cores) with LLVM 20.1.2, --format=json --timing, --jobs=1, no IR cache, medians of 3 to 5 runs. The analyzer at db7fb25 with coretrace-compiler built from its main branch is compared with the same analyzer taking each module from compileToModule:

Sources Loading at db7fb25 Loading with compileToModule
This repository's 53 C++ sources 44.1 s 40.7 s
8 C++ files, each including 11 standard headers 3.81 s 3.49 s
Lua 5.4.6, 34 C files 1.14 s 0.97 s

Both give the same diagnostics and functions.

Proposal

In the bc format, take each module from compileToModule. With the compile IR cache, store the bitcode of that module.

With --timing, a compiled source then has no bitcode parse to report. The regression test check_compile_ir_format_switch recognizes the bc format by that log line, so it needs the line of the new path.

Related: CoreTrace/coretrace-compiler#263, and #271 for the other cost of loading, compilations that run one at a time.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions