diff options
Diffstat (limited to 'compiler/rustc_codegen_llvm/src/builder.rs')
| -rw-r--r-- | compiler/rustc_codegen_llvm/src/builder.rs | 19 |
1 files changed, 15 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) } |
