diff options
Diffstat (limited to 'compiler/rustc_codegen_llvm/src')
| -rw-r--r-- | compiler/rustc_codegen_llvm/src/builder.rs | 19 | ||||
| -rw-r--r-- | compiler/rustc_codegen_llvm/src/lib.rs | 1 |
2 files changed, 16 insertions, 4 deletions
diff --git a/compiler/rustc_codegen_llvm/src/builder.rs b/compiler/rustc_codegen_llvm/src/builder.rs index 63e59ea13fc..b244ed959f9 100644 --- a/compiler/rustc_codegen_llvm/src/builder.rs +++ b/compiler/rustc_codegen_llvm/src/builder.rs @@ -26,6 +26,7 @@ use rustc_target::abi::{self, call::FnAbi, Align, Size, WrappingRange}; use rustc_target::spec::{HasTargetSpec, SanitizerSet, Target}; use smallvec::SmallVec; use std::borrow::Cow; +use std::fmt::Display; use std::iter; use std::ops::Deref; use std::ptr; @@ -153,14 +154,24 @@ impl<'a, 'll, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'll, 'tcx> { fn set_span(&mut self, _span: Span) {} - fn append_block(cx: &'a CodegenCx<'ll, 'tcx>, llfn: &'ll Value, name: &str) -> &'ll BasicBlock { + fn append_block( + cx: &'a CodegenCx<'ll, 'tcx>, + llfn: &'ll Value, + name: impl Display, + ) -> &'ll BasicBlock { unsafe { - let name = SmallCStr::new(name); - llvm::LLVMAppendBasicBlockInContext(cx.llcx, llfn, name.as_ptr()) + let c_str_name; + let name_ptr = if cx.tcx.sess.fewer_names() { + const { c"".as_ptr().cast() } + } else { + c_str_name = SmallCStr::new(&name.to_string()); + c_str_name.as_ptr() + }; + llvm::LLVMAppendBasicBlockInContext(cx.llcx, llfn, name_ptr) } } - fn append_sibling_block(&mut self, name: &str) -> &'ll BasicBlock { + fn append_sibling_block(&mut self, name: impl Display) -> &'ll BasicBlock { Self::append_block(self.cx, self.llfn(), name) } diff --git a/compiler/rustc_codegen_llvm/src/lib.rs b/compiler/rustc_codegen_llvm/src/lib.rs index c84461e53eb..72e5e2b042e 100644 --- a/compiler/rustc_codegen_llvm/src/lib.rs +++ b/compiler/rustc_codegen_llvm/src/lib.rs @@ -11,6 +11,7 @@ #![feature(exact_size_is_empty)] #![feature(extern_types)] #![feature(hash_raw_entry)] +#![feature(inline_const)] #![feature(iter_intersperse)] #![feature(let_chains)] #![feature(impl_trait_in_assoc_type)] |
