Skip to content

Commit bbe3882

Browse files
committed
asdf
1 parent 358171b commit bbe3882

3 files changed

Lines changed: 69 additions & 10 deletions

File tree

compiler/rustc_codegen_llvm/src/intrinsic.rs

Lines changed: 41 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,36 @@ fn call_simple_intrinsic<'ll, 'tcx>(
173173
))
174174
}
175175

176+
fn emit_offload_preload<'ll, 'tcx>(
177+
bx: &mut Builder<'_, 'll, 'tcx>,
178+
tcx: TyCtxt<'tcx>,
179+
instance: ty::Instance<'tcx>,
180+
args: &[OperandRef<'tcx, &'ll llvm::Value>],
181+
is_mut: bool,
182+
) {
183+
if tcx.sess.opts.unstable_opts.offload.is_empty() {
184+
let _ = tcx.dcx().emit_almost_fatal(OffloadWithoutEnable);
185+
}
186+
187+
if tcx.sess.lto() != rustc_session::config::Lto::Fat {
188+
let _ = tcx.dcx().emit_almost_fatal(OffloadWithoutFatLTO);
189+
}
190+
191+
dbg!("HI!");
192+
codegen_offload_preload(bx, tcx, instance, args);
193+
}
194+
176195
impl<'ll, 'tcx> IntrinsicCallBuilderMethods<'tcx> for Builder<'_, 'll, 'tcx> {
196+
fn codegen_offload_preload_call(
197+
&mut self,
198+
instance: ty::Instance<'tcx>,
199+
args: &[OperandRef<'tcx, &'ll llvm::Value>],
200+
is_mut: bool,
201+
) {
202+
let tcx = self.tcx;
203+
emit_offload_preload(self, tcx, instance, args, is_mut);
204+
}
205+
177206
fn codegen_intrinsic_call(
178207
&mut self,
179208
instance: ty::Instance<'tcx>,
@@ -246,18 +275,18 @@ impl<'ll, 'tcx> IntrinsicCallBuilderMethods<'tcx> for Builder<'_, 'll, 'tcx> {
246275
// offload *has* a return type, but somehow works without mentioning the place
247276
return IntrinsicResult::WroteIntoPlace;
248277
}
249-
sym::preload => {
250-
if tcx.sess.opts.unstable_opts.offload.is_empty() {
251-
let _ = tcx.dcx().emit_almost_fatal(OffloadWithoutEnable);
252-
}
278+
//sym::preload => {
279+
// if tcx.sess.opts.unstable_opts.offload.is_empty() {
280+
// let _ = tcx.dcx().emit_almost_fatal(OffloadWithoutEnable);
281+
// }
253282

254-
if tcx.sess.lto() != rustc_session::config::Lto::Fat {
255-
let _ = tcx.dcx().emit_almost_fatal(OffloadWithoutFatLTO);
256-
}
283+
// if tcx.sess.lto() != rustc_session::config::Lto::Fat {
284+
// let _ = tcx.dcx().emit_almost_fatal(OffloadWithoutFatLTO);
285+
// }
257286

258-
codegen_offload_preload(self, tcx, instance, args);
259-
return IntrinsicResult::WroteIntoPlace;
260-
}
287+
// codegen_offload_preload(self, tcx, instance, args);
288+
// return IntrinsicResult::WroteIntoPlace;
289+
//}
261290
sym::is_val_statically_known => {
262291
if let OperandValue::Immediate(imm) = args[0].val {
263292
self.call_intrinsic(
@@ -1960,6 +1989,7 @@ fn codegen_offload_preload<'ll, 'tcx>(
19601989
let metadata = &[meta];
19611990
let types = bx.cx.layout_of(pointee_ty).llvm_type(bx.cx);
19621991

1992+
dbg!("asdf");
19631993
let offload_globals_ref = cx.offload_globals.borrow();
19641994
let offload_globals = match offload_globals_ref.as_ref() {
19651995
Some(globals) => globals,
@@ -1968,6 +1998,7 @@ fn codegen_offload_preload<'ll, 'tcx>(
19681998
return;
19691999
}
19702000
};
2001+
dbg!("asdf");
19712002
let target_symbol = "asdf_I_ll_nameclash".to_owned();
19722003
let offload_data = gen_define_handling(&cx, metadata, target_symbol, offload_globals);
19732004
let has_dynamic = metadata.iter().any(|m| !matches!(m.payload_size, OffloadSize::Static(_)));

compiler/rustc_codegen_ssa/src/mir/block.rs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -919,6 +919,26 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
919919
fn_span,
920920
);
921921

922+
if Some(instance.def_id()) == bx.tcx().lang_items().preload_fn() {
923+
let cg_args: Vec<_> =
924+
args.iter().map(|arg| self.codegen_operand(bx, &arg.node)).collect();
925+
926+
bx.codegen_offload_preload_call(
927+
instance, &cg_args, //source_info,
928+
false, // immutable preload
929+
);
930+
}
931+
932+
if Some(instance.def_id()) == bx.tcx().lang_items().preload_mut_fn() {
933+
let cg_args: Vec<_> =
934+
args.iter().map(|arg| self.codegen_operand(bx, &arg.node)).collect();
935+
936+
bx.codegen_offload_preload_call(
937+
instance, &cg_args, //source_info,
938+
true, // mutable preload
939+
);
940+
}
941+
922942
match instance.def {
923943
// We don't need AsyncDropGlueCtorShim here because it is not `noop func`,
924944
// it is `func returning noop future`

compiler/rustc_codegen_ssa/src/traits/intrinsic.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,14 @@ pub trait IntrinsicCallBuilderMethods<'tcx>: BackendTypes {
3131
span: Span,
3232
) -> IntrinsicResult<'tcx, Self::Value>;
3333

34+
fn codegen_offload_preload_call(
35+
&mut self,
36+
instance: ty::Instance<'tcx>,
37+
args: &[OperandRef<'tcx, Self::Value>],
38+
//source_info: mir::SourceInfo,
39+
is_mut: bool,
40+
);
41+
3442
fn codegen_llvm_intrinsic_call(
3543
&mut self,
3644
instance: ty::Instance<'tcx>,

0 commit comments

Comments
 (0)