File tree 3 files changed +22
-0
lines changed
3 files changed +22
-0
lines changed Original file line number Diff line number Diff line change @@ -8,8 +8,11 @@ use std::borrow::Cow;
8
8
9
9
use cranelift_codegen:: ir:: SigRef ;
10
10
use cranelift_module:: ModuleError ;
11
+ use rustc_codegen_ssa:: errors:: CompilerBuiltinsCannotCall ;
11
12
use rustc_middle:: middle:: codegen_fn_attrs:: CodegenFnAttrFlags ;
12
13
use rustc_middle:: ty:: layout:: FnAbiOf ;
14
+ use rustc_middle:: ty:: print:: with_no_trimmed_paths;
15
+ use rustc_monomorphize:: is_call_from_compiler_builtins_to_upstream_monomorphization;
13
16
use rustc_session:: Session ;
14
17
use rustc_span:: source_map:: Spanned ;
15
18
use rustc_target:: abi:: call:: { Conv , FnAbi } ;
@@ -372,6 +375,17 @@ pub(crate) fn codegen_terminator_call<'tcx>(
372
375
ty:: Instance :: expect_resolve ( fx. tcx , ty:: ParamEnv :: reveal_all ( ) , def_id, fn_args)
373
376
. polymorphize ( fx. tcx ) ;
374
377
378
+ if is_call_from_compiler_builtins_to_upstream_monomorphization ( fx. tcx , instance) {
379
+ if target. is_some ( ) {
380
+ let caller = with_no_trimmed_paths ! ( fx. tcx. def_path_str( fx. instance. def_id( ) ) ) ;
381
+ let callee = with_no_trimmed_paths ! ( fx. tcx. def_path_str( def_id) ) ;
382
+ fx. tcx . dcx ( ) . emit_err ( CompilerBuiltinsCannotCall { caller, callee } ) ;
383
+ } else {
384
+ fx. bcx . ins ( ) . trap ( TrapCode :: User ( 0 ) ) ;
385
+ return ;
386
+ }
387
+ }
388
+
375
389
if fx. tcx . symbol_name ( instance) . name . starts_with ( "llvm." ) {
376
390
crate :: intrinsics:: codegen_llvm_intrinsic_call (
377
391
fx,
Original file line number Diff line number Diff line change @@ -8,6 +8,7 @@ use rustc_index::IndexVec;
8
8
use rustc_middle:: ty:: adjustment:: PointerCoercion ;
9
9
use rustc_middle:: ty:: layout:: FnAbiOf ;
10
10
use rustc_middle:: ty:: print:: with_no_trimmed_paths;
11
+ use rustc_monomorphize:: is_call_from_compiler_builtins_to_upstream_monomorphization;
11
12
12
13
use crate :: constant:: ConstantCx ;
13
14
use crate :: debuginfo:: FunctionDebugContext ;
@@ -999,6 +1000,12 @@ fn codegen_panic_inner<'tcx>(
999
1000
let def_id = fx. tcx . require_lang_item ( lang_item, span) ;
1000
1001
1001
1002
let instance = Instance :: mono ( fx. tcx , def_id) . polymorphize ( fx. tcx ) ;
1003
+
1004
+ if is_call_from_compiler_builtins_to_upstream_monomorphization ( fx. tcx , instance) {
1005
+ fx. bcx . ins ( ) . trap ( TrapCode :: User ( 0 ) ) ;
1006
+ return ;
1007
+ }
1008
+
1002
1009
let symbol_name = fx. tcx . symbol_name ( instance) . name ;
1003
1010
1004
1011
fx. lib_call (
Original file line number Diff line number Diff line change @@ -21,6 +21,7 @@ extern crate rustc_hir;
21
21
extern crate rustc_incremental;
22
22
extern crate rustc_index;
23
23
extern crate rustc_metadata;
24
+ extern crate rustc_monomorphize;
24
25
extern crate rustc_session;
25
26
extern crate rustc_span;
26
27
extern crate rustc_target;
You can’t perform that action at this time.
0 commit comments