about summary refs log tree commit diff
diff options
context:
space:
mode:
authorbjorn3 <bjorn3@users.noreply.github.com>2021-07-06 18:56:01 +0200
committerbjorn3 <17426603+bjorn3@users.noreply.github.com>2023-05-11 14:35:09 +0000
commit145b0574efd63603f35beda4d6b69933c8a01c1f (patch)
treeac63d2efc3a89ac5cfb506a4dfe93cc10f4f36ca
parent6ba7c5db079132b5d85112083691d4203a6b761c (diff)
downloadrust-145b0574efd63603f35beda4d6b69933c8a01c1f.tar.gz
rust-145b0574efd63603f35beda4d6b69933c8a01c1f.zip
Use global_fn_name instead of format!
-rw-r--r--compiler/rustc_codegen_cranelift/src/allocator.rs5
-rw-r--r--compiler/rustc_codegen_gcc/src/allocator.rs5
-rw-r--r--compiler/rustc_codegen_llvm/src/allocator.rs5
3 files changed, 9 insertions, 6 deletions
diff --git a/compiler/rustc_codegen_cranelift/src/allocator.rs b/compiler/rustc_codegen_cranelift/src/allocator.rs
index 3b74050250b..c27971897a0 100644
--- a/compiler/rustc_codegen_cranelift/src/allocator.rs
+++ b/compiler/rustc_codegen_cranelift/src/allocator.rs
@@ -4,7 +4,8 @@
 use crate::prelude::*;
 
 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_session::config::OomStrategy;
@@ -68,7 +69,7 @@ fn codegen_inner(
                 module,
                 unwind_context,
                 sig,
-                &format!("__rust_{}", method.name),
+                &global_fn_name(method.name),
                 &default_fn_name(method.name),
             );
         }
diff --git a/compiler/rustc_codegen_gcc/src/allocator.rs b/compiler/rustc_codegen_gcc/src/allocator.rs
index fe143aaad5f..ff68de8c8f1 100644
--- a/compiler/rustc_codegen_gcc/src/allocator.rs
+++ b/compiler/rustc_codegen_gcc/src/allocator.rs
@@ -2,7 +2,8 @@
 use gccjit::FnAttribute;
 use gccjit::{FunctionType, GlobalKind, ToRValue};
 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::ty::TyCtxt;
@@ -46,7 +47,7 @@ pub(crate) unsafe fn codegen(tcx: TyCtxt<'_>, mods: &mut GccContext, _module_nam
                     panic!("invalid allocator output")
                 }
             };
-            let name = format!("__rust_{}", method.name);
+            let name = global_fn_name(method.name);
 
             let args: Vec<_> = types.iter().enumerate()
                 .map(|(index, typ)| context.new_parameter(None, *typ, &format!("param{}", index)))
diff --git a/compiler/rustc_codegen_llvm/src/allocator.rs b/compiler/rustc_codegen_llvm/src/allocator.rs
index c2484681072..564e996cdf3 100644
--- a/compiler/rustc_codegen_llvm/src/allocator.rs
+++ b/compiler/rustc_codegen_llvm/src/allocator.rs
@@ -1,7 +1,8 @@
 use crate::attributes;
 use libc::c_uint;
 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::ty::TyCtxt;
@@ -59,7 +60,7 @@ pub(crate) unsafe fn codegen(
                 args.len() as c_uint,
                 False,
             );
-            let name = format!("__rust_{}", method.name);
+            let name = global_fn_name(method.name);
             let llfn =
                 llvm::LLVMRustGetOrInsertFunction(llmod, name.as_ptr().cast(), name.len(), ty);