mirror of
https://github.com/vercel-labs/scriptc.git
synced 2026-10-31 07:23:06 +08:00
Name the source file in empty split codegen parts (#2397)
This commit is contained in:
@@ -1241,6 +1241,7 @@ emitSplitCodegen(const EmitOptions &Options, Module &M, TargetMachine &Machine,
|
||||
size_t Count = Options.Outputs.size();
|
||||
std::optional<CodegenSplit> Split = splitForCodegen(M, Count);
|
||||
std::string Identifier = M.getModuleIdentifier();
|
||||
std::string SourceFileName = M.getSourceFileName();
|
||||
Triple TargetTriple = M.getTargetTriple();
|
||||
DataLayout Layout = M.getDataLayout();
|
||||
std::vector<std::vector<SmallString<256>>> Temporaries(Count);
|
||||
@@ -1274,6 +1275,7 @@ emitSplitCodegen(const EmitOptions &Options, Module &M, TargetMachine &Machine,
|
||||
keepCodegenPart(*Part, Split->PartOf, I);
|
||||
} else {
|
||||
Part = std::make_unique<Module>(Identifier, Context);
|
||||
Part->setSourceFileName(SourceFileName);
|
||||
Part->setTargetTriple(TargetTriple);
|
||||
Part->setDataLayout(Layout);
|
||||
}
|
||||
|
||||
@@ -327,6 +327,16 @@ describe.runIf(helper !== null)("LLVM program partitions", () => {
|
||||
const first = await readFile(parts[0]!);
|
||||
const [single] = await emit(dir, source, { outputs: 1, optLevel: "2", name: "whole" });
|
||||
expect(await readFile(single!)).toEqual(first);
|
||||
// The empty parts name the source path, so they do not depend on the
|
||||
// input's file name either.
|
||||
const renamed = await emit(dir, source, {
|
||||
outputs: 3,
|
||||
optLevel: "2",
|
||||
split: true,
|
||||
name: "renamed",
|
||||
});
|
||||
for (let index = 0; index < parts.length; index++)
|
||||
expect(await readFile(renamed[index]!)).toEqual(await readFile(parts[index]!));
|
||||
});
|
||||
|
||||
test("split code generation requires several optimized outputs and no cache", async () => {
|
||||
|
||||
Reference in New Issue
Block a user