Skip to content

Commit 6034f04

Browse files
committed
Auto merge of rust-lang#122567 - erikdesjardins:noname, r=<try>
Avoid naming LLVM basic blocks when `fewer_names` is true This may be a small perf win. r? `@ghost`
2 parents 72d7897 + 32fb9cd commit 6034f04

File tree

3 files changed

+9
-3
lines changed

3 files changed

+9
-3
lines changed

compiler/rustc_codegen_llvm/src/builder.rs

+8-2
Original file line numberDiff line numberDiff line change
@@ -155,8 +155,14 @@ impl<'a, 'll, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'll, 'tcx> {
155155

156156
fn append_block(cx: &'a CodegenCx<'ll, 'tcx>, llfn: &'ll Value, name: &str) -> &'ll BasicBlock {
157157
unsafe {
158-
let name = SmallCStr::new(name);
159-
llvm::LLVMAppendBasicBlockInContext(cx.llcx, llfn, name.as_ptr())
158+
let c_str_name;
159+
let name_ptr = if cx.tcx.sess.fewer_names() {
160+
const { c"".as_ptr().cast() }
161+
} else {
162+
c_str_name = SmallCStr::new(name);
163+
c_str_name.as_ptr()
164+
};
165+
llvm::LLVMAppendBasicBlockInContext(cx.llcx, llfn, name_ptr)
160166
}
161167
}
162168

compiler/rustc_codegen_llvm/src/lib.rs

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

compiler/rustc_codegen_ssa/src/mir/block.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1688,7 +1688,6 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
16881688
pub fn try_llbb(&mut self, bb: mir::BasicBlock) -> Option<Bx::BasicBlock> {
16891689
match self.cached_llbbs[bb] {
16901690
CachedLlbb::None => {
1691-
// FIXME(eddyb) only name the block if `fewer_names` is `false`.
16921691
let llbb = Bx::append_block(self.cx, self.llfn, &format!("{bb:?}"));
16931692
self.cached_llbbs[bb] = CachedLlbb::Some(llbb);
16941693
Some(llbb)

0 commit comments

Comments
 (0)