Skip to content

Commit 92c6cd5

Browse files
committed
patch codegen_ssa to allow passing ScalarPairs with PassMode::Direct
1 parent e1eae0d commit 92c6cd5

2 files changed

Lines changed: 28 additions & 1 deletion

File tree

crates/rustc_codegen_spirv/build.rs

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,33 @@ pub(super) fn elf_e_flags(architecture: Architecture, sess: &Session) -> u32 {",
256256
);
257257
}
258258

259+
// HACK(firestar99): Undo code cleanup that prevents passing ScalarPairs as `PassMode::Direct`
260+
// https://github.com/rust-lang/rust/commit/dfc475d018c780475ea962f15d86cfa05a50a148
261+
if relative_path == Path::new("src/mir/mod.rs") {
262+
src = src.replace(
263+
"
264+
debug_assert!(bx.is_backend_immediate(arg.layout));
265+
return local(OperandRef {
266+
val: OperandValue::Immediate(llarg),
267+
layout: arg.layout,
268+
move_annotation: None,
269+
});",
270+
"
271+
return local(OperandRef::from_immediate_or_packed_pair(
272+
bx, llarg, arg.layout,
273+
));",
274+
);
275+
}
276+
if relative_path == Path::new("src/mir/block.rs") {
277+
src = src.replace(
278+
r#"
279+
PassMode::Direct(_) => (op.immediate(), arg.layout.align.abi, false),
280+
PassMode::Ignore | PassMode::Pair(..) => unreachable!("handled above"),"#,
281+
"\
282+
_ => (op.immediate_or_packed_pair(bx), arg.layout.align.abi, false),",
283+
);
284+
}
285+
259286
fs::write(out_path, src)?;
260287
}
261288
}

tests/compiletests/ui/lang/core/intrinsics/black_box.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ OpLine %5 41 19
88
%10 = OpIAdd %7 %11 %12
99
OpLine %5 47 8
1010
%13 = OpBitcast %7 %14
11-
OpLine %15 1244 17
11+
OpLine %15 1245 17
1212
%16 = OpBitcast %7 %17
1313
OpLine %5 46 4
1414
%18 = OpCompositeConstruct %2 %13 %16 %19 %20 %21 %22 %6 %23 %10 %24 %24 %24

0 commit comments

Comments
 (0)