1
Fork 0

Use global_fn_name instead of format!

This commit is contained in:
bjorn3 2021-07-06 18:56:01 +02:00 committed by bjorn3
parent 6ba7c5db07
commit 145b0574ef
3 changed files with 9 additions and 6 deletions

View file

@ -4,7 +4,8 @@
use crate::prelude::*; use crate::prelude::*;
use rustc_ast::expand::allocator::{ use rustc_ast::expand::allocator::{
alloc_error_handler_name, default_fn_name, AllocatorKind, AllocatorTy, ALLOCATOR_METHODS, alloc_error_handler_name, default_fn_name, global_fn_name, AllocatorKind, AllocatorTy,
ALLOCATOR_METHODS,
}; };
use rustc_codegen_ssa::base::allocator_kind_for_codegen; use rustc_codegen_ssa::base::allocator_kind_for_codegen;
use rustc_session::config::OomStrategy; use rustc_session::config::OomStrategy;
@ -68,7 +69,7 @@ fn codegen_inner(
module, module,
unwind_context, unwind_context,
sig, sig,
&format!("__rust_{}", method.name), &global_fn_name(method.name),
&default_fn_name(method.name), &default_fn_name(method.name),
); );
} }

View file

@ -2,7 +2,8 @@
use gccjit::FnAttribute; use gccjit::FnAttribute;
use gccjit::{FunctionType, GlobalKind, ToRValue}; use gccjit::{FunctionType, GlobalKind, ToRValue};
use rustc_ast::expand::allocator::{ use rustc_ast::expand::allocator::{
alloc_error_handler_name, default_fn_name, AllocatorKind, AllocatorTy, ALLOCATOR_METHODS, alloc_error_handler_name, default_fn_name, global_fn_name, AllocatorKind, AllocatorTy,
ALLOCATOR_METHODS,
}; };
use rustc_middle::bug; use rustc_middle::bug;
use rustc_middle::ty::TyCtxt; use rustc_middle::ty::TyCtxt;
@ -46,7 +47,7 @@ pub(crate) unsafe fn codegen(tcx: TyCtxt<'_>, mods: &mut GccContext, _module_nam
panic!("invalid allocator output") panic!("invalid allocator output")
} }
}; };
let name = format!("__rust_{}", method.name); let name = global_fn_name(method.name);
let args: Vec<_> = types.iter().enumerate() let args: Vec<_> = types.iter().enumerate()
.map(|(index, typ)| context.new_parameter(None, *typ, &format!("param{}", index))) .map(|(index, typ)| context.new_parameter(None, *typ, &format!("param{}", index)))

View file

@ -1,7 +1,8 @@
use crate::attributes; use crate::attributes;
use libc::c_uint; use libc::c_uint;
use rustc_ast::expand::allocator::{ use rustc_ast::expand::allocator::{
alloc_error_handler_name, default_fn_name, AllocatorKind, AllocatorTy, ALLOCATOR_METHODS, alloc_error_handler_name, default_fn_name, global_fn_name, AllocatorKind, AllocatorTy,
ALLOCATOR_METHODS,
}; };
use rustc_middle::bug; use rustc_middle::bug;
use rustc_middle::ty::TyCtxt; use rustc_middle::ty::TyCtxt;
@ -59,7 +60,7 @@ pub(crate) unsafe fn codegen(
args.len() as c_uint, args.len() as c_uint,
False, False,
); );
let name = format!("__rust_{}", method.name); let name = global_fn_name(method.name);
let llfn = let llfn =
llvm::LLVMRustGetOrInsertFunction(llmod, name.as_ptr().cast(), name.len(), ty); llvm::LLVMRustGetOrInsertFunction(llmod, name.as_ptr().cast(), name.len(), ty);