Skip to content

Commit a7d4258

Browse files
revert changes and just delete the fixme
Avoiding the naming didn't have any meaningful perf impact.
1 parent 129b5e4 commit a7d4258

File tree

5 files changed

+14
-36
lines changed

5 files changed

+14
-36
lines changed

compiler/rustc_codegen_gcc/src/builder.rs

+4-5
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
use std::borrow::Cow;
22
use std::cell::Cell;
33
use std::convert::TryFrom;
4-
use std::fmt::Display;
54
use std::ops::Deref;
65

76
use gccjit::{
@@ -527,14 +526,14 @@ impl<'a, 'gcc, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'gcc, 'tcx> {
527526
self.block
528527
}
529528

530-
fn append_block(cx: &'a CodegenCx<'gcc, 'tcx>, func: RValue<'gcc>, name: impl Display) -> Block<'gcc> {
529+
fn append_block(cx: &'a CodegenCx<'gcc, 'tcx>, func: RValue<'gcc>, name: &str) -> Block<'gcc> {
531530
let func = cx.rvalue_as_function(func);
532-
func.new_block(name.to_string())
531+
func.new_block(name)
533532
}
534533

535-
fn append_sibling_block(&mut self, name: impl Display) -> Block<'gcc> {
534+
fn append_sibling_block(&mut self, name: &str) -> Block<'gcc> {
536535
let func = self.current_func();
537-
func.new_block(name.to_string())
536+
func.new_block(name)
538537
}
539538

540539
fn switch_to_block(&mut self, block: Self::BasicBlock) {

compiler/rustc_codegen_llvm/src/builder.rs

+4-15
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ use rustc_target::abi::{self, call::FnAbi, Align, Size, WrappingRange};
2626
use rustc_target::spec::{HasTargetSpec, SanitizerSet, Target};
2727
use smallvec::SmallVec;
2828
use std::borrow::Cow;
29-
use std::fmt::Display;
3029
use std::iter;
3130
use std::ops::Deref;
3231
use std::ptr;
@@ -154,24 +153,14 @@ impl<'a, 'll, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'll, 'tcx> {
154153

155154
fn set_span(&mut self, _span: Span) {}
156155

157-
fn append_block(
158-
cx: &'a CodegenCx<'ll, 'tcx>,
159-
llfn: &'ll Value,
160-
name: impl Display,
161-
) -> &'ll BasicBlock {
156+
fn append_block(cx: &'a CodegenCx<'ll, 'tcx>, llfn: &'ll Value, name: &str) -> &'ll BasicBlock {
162157
unsafe {
163-
let c_str_name;
164-
let name_ptr = if cx.tcx.sess.fewer_names() {
165-
const { c"".as_ptr().cast() }
166-
} else {
167-
c_str_name = SmallCStr::new(&name.to_string());
168-
c_str_name.as_ptr()
169-
};
170-
llvm::LLVMAppendBasicBlockInContext(cx.llcx, llfn, name_ptr)
158+
let name = SmallCStr::new(name);
159+
llvm::LLVMAppendBasicBlockInContext(cx.llcx, llfn, name.as_ptr())
171160
}
172161
}
173162

174-
fn append_sibling_block(&mut self, name: impl Display) -> &'ll BasicBlock {
163+
fn append_sibling_block(&mut self, name: &str) -> &'ll BasicBlock {
175164
Self::append_block(self.cx, self.llfn(), name)
176165
}
177166

compiler/rustc_codegen_llvm/src/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
#![feature(exact_size_is_empty)]
1212
#![feature(extern_types)]
1313
#![feature(hash_raw_entry)]
14-
#![feature(inline_const)]
1514
#![feature(iter_intersperse)]
1615
#![feature(let_chains)]
1716
#![feature(impl_trait_in_assoc_type)]

compiler/rustc_codegen_ssa/src/mir/block.rs

+4-7
Original file line numberDiff line numberDiff line change
@@ -83,11 +83,8 @@ impl<'a, 'tcx> TerminatorCodegenHelper<'tcx> {
8383
// Cross-funclet jump - need a trampoline
8484
debug_assert!(base::wants_new_eh_instructions(fx.cx.tcx().sess));
8585
debug!("llbb_with_cleanup: creating cleanup trampoline for {:?}", target);
86-
let trampoline_llbb = Bx::append_block(
87-
fx.cx,
88-
fx.llfn,
89-
format_args!("{:?}_cleanup_trampoline_{:?}", self.bb, target),
90-
);
86+
let name = &format!("{:?}_cleanup_trampoline_{:?}", self.bb, target);
87+
let trampoline_llbb = Bx::append_block(fx.cx, fx.llfn, name);
9188
let mut trampoline_bx = Bx::build(fx.cx, trampoline_llbb);
9289
trampoline_bx.cleanup_ret(self.funclet(fx).unwrap(), Some(lltarget));
9390
trampoline_llbb
@@ -1568,7 +1565,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
15681565
fn landing_pad_for_uncached(&mut self, bb: mir::BasicBlock) -> Bx::BasicBlock {
15691566
let llbb = self.llbb(bb);
15701567
if base::wants_new_eh_instructions(self.cx.sess()) {
1571-
let cleanup_bb = Bx::append_block(self.cx, self.llfn, format_args!("funclet_{bb:?}"));
1568+
let cleanup_bb = Bx::append_block(self.cx, self.llfn, &format!("funclet_{bb:?}"));
15721569
let mut cleanup_bx = Bx::build(self.cx, cleanup_bb);
15731570
let funclet = cleanup_bx.cleanup_pad(None, &[]);
15741571
cleanup_bx.br(llbb);
@@ -1691,7 +1688,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
16911688
pub fn try_llbb(&mut self, bb: mir::BasicBlock) -> Option<Bx::BasicBlock> {
16921689
match self.cached_llbbs[bb] {
16931690
CachedLlbb::None => {
1694-
let llbb = Bx::append_block(self.cx, self.llfn, format_args!("{bb:?}"));
1691+
let llbb = Bx::append_block(self.cx, self.llfn, &format!("{bb:?}"));
16951692
self.cached_llbbs[bb] = CachedLlbb::Some(llbb);
16961693
Some(llbb)
16971694
}

compiler/rustc_codegen_ssa/src/traits/builder.rs

+2-8
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,6 @@ use rustc_target::abi::call::FnAbi;
2222
use rustc_target::abi::{Abi, Align, Scalar, Size, WrappingRange};
2323
use rustc_target::spec::HasTargetSpec;
2424

25-
use std::fmt::Display;
26-
2725
#[derive(Copy, Clone)]
2826
pub enum OverflowOp {
2927
Add,
@@ -51,13 +49,9 @@ pub trait BuilderMethods<'a, 'tcx>:
5149
fn set_span(&mut self, span: Span);
5250

5351
// FIXME(eddyb) replace uses of this with `append_sibling_block`.
54-
fn append_block(
55-
cx: &'a Self::CodegenCx,
56-
llfn: Self::Function,
57-
name: impl Display,
58-
) -> Self::BasicBlock;
52+
fn append_block(cx: &'a Self::CodegenCx, llfn: Self::Function, name: &str) -> Self::BasicBlock;
5953

60-
fn append_sibling_block(&mut self, name: impl Display) -> Self::BasicBlock;
54+
fn append_sibling_block(&mut self, name: &str) -> Self::BasicBlock;
6155

6256
fn switch_to_block(&mut self, llbb: Self::BasicBlock);
6357

0 commit comments

Comments
 (0)