Files
scriptc/native/llvm-codegen/src/runtime-import.h
T
Malte Ubl 60c30d6ebd Import runtime bitcode into speed programs (H02)
Re-lands perf/h02-runtime-lto (6d373317, b62448f3) behind the speed
posture.

- Runtime packs gain an executable `speed` flavor whenever the host LLVM
  helper can run. Its static units are emitted through the helper's
  `runtime-unit` command (promoted unit-local symbols, object and import
  bitcode from one module); its SCR_DYNAMIC variants reference the release
  objects. Release, dev, and library flavors and the vendor archives are
  built exactly as before (the rebuilt macOS pack's flavors and archives
  are identical to the baseline's).
- Speed program builds load the speed flavor's bitcode and pass it to the
  helper (`--import-bitcode`); release builds never do.
  loadRuntimeBitcode only reads a real speed flavor, never release.
- The helper drops the emitter's inert sanitize_address attributes only
  when it imports, so release modules reach the pipeline unchanged.
- Tests: runtime-pack.test.ts covers speed-variant bitcode selection,
  verification, and that release-flavor bitcode is never imported;
  native-codegen.test.ts covers helper arguments and cache keys.

Release executables stay byte-identical to the stack tip with the rebuilt
helper (14/14 workloads, macOS).
2026-10-08 15:46:34 -05:00

30 lines
1.1 KiB
C++

#pragma once
#include "llvm/IR/Module.h"
#include <optional>
#include <string>
#include <vector>
namespace scriptc {
// Makes small runtime functions visible to the program optimizer. Each input
// is LLVM bitcode for a runtime-pack unit that is also linked as a native
// object (both are emitted from one module by `runtime-unit`, which promotes
// unit-local symbols to hidden unit-qualified globals). Selected external
// definitions are linked into the program module as available_externally,
// exactly like ThinLTO function import: the optimizer may inline or
// specialize them, and every remaining reference resolves to the runtime
// object at link time. Selection starts at the runtime functions the
// program declares and follows calls with a size limit that decays per hop.
// Bodies that would need a second copy of unit-local state or a second
// address for a local function (possible only with unpromoted bitcode) are
// never imported.
//
// Returns an error message on failure.
std::optional<std::string>
importRuntimeBitcode(llvm::Module &Program,
const std::vector<std::string> &BitcodePaths);
} // namespace scriptc