Skip to content

Commit 1f35940

Browse files
committed
Reformat some comments.
So they are less than 100 chars.
1 parent 5fd16df commit 1f35940

File tree

15 files changed

+78
-66
lines changed

15 files changed

+78
-66
lines changed

Diff for: compiler/rustc_codegen_llvm/src/attributes.rs

+5-3
Original file line numberDiff line numberDiff line change
@@ -403,8 +403,9 @@ pub(crate) fn llfn_attrs_from_instance<'ll, 'tcx>(
403403
if codegen_fn_attrs.flags.contains(CodegenFnAttrFlags::NAKED) {
404404
to_add.push(AttributeKind::Naked.create_attr(cx.llcx));
405405
// HACK(jubilee): "indirect branch tracking" works by attaching prologues to functions.
406-
// And it is a module-level attribute, so the alternative is pulling naked functions into new LLVM modules.
407-
// Otherwise LLVM's "naked" functions come with endbr prefixes per https://github.com/rust-lang/rust/issues/98768
406+
// And it is a module-level attribute, so the alternative is pulling naked functions into
407+
// new LLVM modules. Otherwise LLVM's "naked" functions come with endbr prefixes per
408+
// https://github.com/rust-lang/rust/issues/98768
408409
to_add.push(AttributeKind::NoCfCheck.create_attr(cx.llcx));
409410
if llvm_util::get_version() < (19, 0, 0) {
410411
// Prior to LLVM 19, branch-target-enforcement was disabled by setting the attribute to
@@ -454,7 +455,8 @@ pub(crate) fn llfn_attrs_from_instance<'ll, 'tcx>(
454455
flags |= AllocKindFlags::Zeroed;
455456
}
456457
to_add.push(llvm::CreateAllocKindAttr(cx.llcx, flags));
457-
// apply to return place instead of function (unlike all other attributes applied in this function)
458+
// apply to return place instead of function (unlike all other attributes applied in this
459+
// function)
458460
let no_alias = AttributeKind::NoAlias.create_attr(cx.llcx);
459461
attributes::apply_to_llfn(llfn, AttributePlace::ReturnValue, &[no_alias]);
460462
}

Diff for: compiler/rustc_codegen_llvm/src/back/lto.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -156,15 +156,15 @@ fn get_bitcode_slice_from_object_data<'a>(
156156
obj: &'a [u8],
157157
cgcx: &CodegenContext<LlvmCodegenBackend>,
158158
) -> Result<&'a [u8], LtoBitcodeFromRlib> {
159-
// We're about to assume the data here is an object file with sections, but if it's raw LLVM IR that
160-
// won't work. Fortunately, if that's what we have we can just return the object directly, so we sniff
161-
// the relevant magic strings here and return.
159+
// We're about to assume the data here is an object file with sections, but if it's raw LLVM IR
160+
// that won't work. Fortunately, if that's what we have we can just return the object directly,
161+
// so we sniff the relevant magic strings here and return.
162162
if obj.starts_with(b"\xDE\xC0\x17\x0B") || obj.starts_with(b"BC\xC0\xDE") {
163163
return Ok(obj);
164164
}
165-
// We drop the "__LLVM," prefix here because on Apple platforms there's a notion of "segment name"
166-
// which in the public API for sections gets treated as part of the section name, but internally
167-
// in MachOObjectFile.cpp gets treated separately.
165+
// We drop the "__LLVM," prefix here because on Apple platforms there's a notion of "segment
166+
// name" which in the public API for sections gets treated as part of the section name, but
167+
// internally in MachOObjectFile.cpp gets treated separately.
168168
let section_name = bitcode_section_name(cgcx).trim_start_matches("__LLVM,");
169169
let mut len = 0;
170170
let data = unsafe {

Diff for: compiler/rustc_codegen_llvm/src/back/owned_target_machine.rs

+5-3
Original file line numberDiff line numberDiff line change
@@ -86,15 +86,17 @@ impl Deref for OwnedTargetMachine {
8686
type Target = llvm::TargetMachine;
8787

8888
fn deref(&self) -> &Self::Target {
89-
// SAFETY: constructing ensures we have a valid pointer created by llvm::LLVMRustCreateTargetMachine
89+
// SAFETY: constructing ensures we have a valid pointer created by
90+
// llvm::LLVMRustCreateTargetMachine.
9091
unsafe { self.tm_unique.as_ref() }
9192
}
9293
}
9394

9495
impl Drop for OwnedTargetMachine {
9596
fn drop(&mut self) {
96-
// SAFETY: constructing ensures we have a valid pointer created by llvm::LLVMRustCreateTargetMachine
97-
// OwnedTargetMachine is not copyable so there is no double free or use after free
97+
// SAFETY: constructing ensures we have a valid pointer created by
98+
// llvm::LLVMRustCreateTargetMachine OwnedTargetMachine is not copyable so there is no
99+
// double free or use after free.
98100
unsafe {
99101
llvm::LLVMRustDisposeTargetMachine(self.tm_unique.as_mut());
100102
}

Diff for: compiler/rustc_codegen_llvm/src/back/write.rs

+4-3
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,8 @@ fn to_pass_builder_opt_level(cfg: config::OptLevel) -> llvm::PassBuilderOptLevel
157157
fn to_llvm_relocation_model(relocation_model: RelocModel) -> llvm::RelocModel {
158158
match relocation_model {
159159
RelocModel::Static => llvm::RelocModel::Static,
160-
// LLVM doesn't have a PIE relocation model, it represents PIE as PIC with an extra attribute.
160+
// LLVM doesn't have a PIE relocation model, it represents PIE as PIC with an extra
161+
// attribute.
161162
RelocModel::Pic | RelocModel::Pie => llvm::RelocModel::PIC,
162163
RelocModel::DynamicNoPic => llvm::RelocModel::DynamicNoPic,
163164
RelocModel::Ropi => llvm::RelocModel::ROPI,
@@ -188,8 +189,8 @@ pub(crate) fn target_machine_factory(
188189
let use_softfp = if sess.target.arch == "arm" && sess.target.abi == "eabihf" {
189190
sess.opts.cg.soft_float
190191
} else {
191-
// `validate_commandline_args_with_session_available` has already warned about this being ignored.
192-
// Let's make sure LLVM doesn't suddenly start using this flag on more targets.
192+
// `validate_commandline_args_with_session_available` has already warned about this being
193+
// ignored. Let's make sure LLVM doesn't suddenly start using this flag on more targets.
193194
false
194195
};
195196

Diff for: compiler/rustc_codegen_llvm/src/builder.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -673,11 +673,11 @@ impl<'a, 'll, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'll, 'tcx> {
673673
// for performance. LLVM doesn't seem to care about this, and will happily treat
674674
// `!nontemporal` stores as-if they were normal stores (for reordering optimizations
675675
// etc) even on x86, despite later lowering them to MOVNT which do *not* behave like
676-
// regular stores but require special fences.
677-
// So we keep a list of architectures where `!nontemporal` is known to be truly just
678-
// a hint, and use regular stores everywhere else.
679-
// (In the future, we could alternatively ensure that an sfence gets emitted after a sequence of movnt
680-
// before any kind of synchronizing operation. But it's not clear how to do that with LLVM.)
676+
// regular stores but require special fences. So we keep a list of architectures
677+
// where `!nontemporal` is known to be truly just a hint, and use regular stores
678+
// everywhere else. (In the future, we could alternatively ensure that an sfence
679+
// gets emitted after a sequence of movnt before any kind of synchronizing
680+
// operation. But it's not clear how to do that with LLVM.)
681681
// For more context, see <https://github.com/rust-lang/rust/issues/114582> and
682682
// <https://github.com/llvm/llvm-project/issues/64521>.
683683
const WELL_BEHAVED_NONTEMPORAL_ARCHS: &[&str] =

Diff for: compiler/rustc_codegen_llvm/src/consts.rs

+11-10
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,8 @@ pub(crate) fn const_alloc_to_llvm<'ll>(
7373

7474
// Generating partially-uninit consts is limited to small numbers of chunks,
7575
// to avoid the cost of generating large complex const expressions.
76-
// For example, `[(u32, u8); 1024 * 1024]` contains uninit padding in each element,
77-
// and would result in `{ [5 x i8] zeroinitializer, [3 x i8] undef, ...repeat 1M times... }`.
76+
// For example, `[(u32, u8); 1024 * 1024]` contains uninit padding in each element, and
77+
// would result in `{ [5 x i8] zeroinitializer, [3 x i8] undef, ...repeat 1M times... }`.
7878
let max = cx.sess().opts.unstable_opts.uninit_const_chunk_threshold;
7979
let allow_uninit_chunks = chunks.clone().take(max.saturating_add(1)).count() <= max;
8080

@@ -249,8 +249,8 @@ impl<'ll> CodegenCx<'ll, '_> {
249249
trace!(?instance);
250250

251251
let DefKind::Static { nested, .. } = self.tcx.def_kind(def_id) else { bug!() };
252-
// Nested statics do not have a type, so pick a dummy type and let `codegen_static` figure out
253-
// the llvm type from the actual evaluated initializer.
252+
// Nested statics do not have a type, so pick a dummy type and let `codegen_static` figure
253+
// out the llvm type from the actual evaluated initializer.
254254
let llty = if nested {
255255
self.type_i8()
256256
} else {
@@ -320,15 +320,16 @@ impl<'ll> CodegenCx<'ll, '_> {
320320
}
321321

322322
if !def_id.is_local() {
323-
let needs_dll_storage_attr = self.use_dll_storage_attrs && !self.tcx.is_foreign_item(def_id) &&
323+
let needs_dll_storage_attr = self.use_dll_storage_attrs
324+
&& !self.tcx.is_foreign_item(def_id)
324325
// Local definitions can never be imported, so we must not apply
325326
// the DLLImport annotation.
326-
!dso_local &&
327+
&& !dso_local
327328
// ThinLTO can't handle this workaround in all cases, so we don't
328329
// emit the attrs. Instead we make them unnecessary by disallowing
329330
// dynamic linking when linker plugin based LTO is enabled.
330-
!self.tcx.sess.opts.cg.linker_plugin_lto.enabled() &&
331-
self.tcx.sess.lto() != Lto::Thin;
331+
&& !self.tcx.sess.opts.cg.linker_plugin_lto.enabled()
332+
&& self.tcx.sess.lto() != Lto::Thin;
332333

333334
// If this assertion triggers, there's something wrong with commandline
334335
// argument validation.
@@ -551,8 +552,8 @@ impl<'ll> CodegenCx<'ll, '_> {
551552
// `#[used(compiler)]` is explicitly requested. This is to avoid similar breakage
552553
// on other targets, in particular MachO targets have *their* static constructor
553554
// lists broken if `llvm.compiler.used` is emitted rather than `llvm.used`. However,
554-
// that check happens when assigning the `CodegenFnAttrFlags` in `rustc_hir_analysis`,
555-
// so we don't need to take care of it here.
555+
// that check happens when assigning the `CodegenFnAttrFlags` in
556+
// `rustc_hir_analysis`, so we don't need to take care of it here.
556557
self.add_compiler_used_global(g);
557558
}
558559
if attrs.flags.contains(CodegenFnAttrFlags::USED_LINKER) {

Diff for: compiler/rustc_codegen_llvm/src/context.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,8 @@ pub(crate) unsafe fn create_module<'ll>(
231231
}
232232
}
233233

234-
// Enable LTO unit splitting if specified or if CFI is enabled. (See https://reviews.llvm.org/D53891.)
234+
// Enable LTO unit splitting if specified or if CFI is enabled. (See
235+
// https://reviews.llvm.org/D53891.)
235236
if sess.is_split_lto_unit_enabled() || sess.is_sanitizer_cfi_enabled() {
236237
let enable_split_lto_unit = c"EnableSplitLTOUnit".as_ptr();
237238
unsafe {

Diff for: compiler/rustc_codegen_llvm/src/coverageinfo/ffi.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,8 @@ mod mcdc {
121121
num_conditions: u16,
122122
}
123123

124-
// ConditionId in llvm is `unsigned int` at 18 while `int16_t` at [19](https://github.com/llvm/llvm-project/pull/81257)
124+
// ConditionId in llvm is `unsigned int` at 18 while `int16_t` at
125+
// [19](https://github.com/llvm/llvm-project/pull/81257).
125126
type LLVMConditionId = i16;
126127

127128
/// Must match the layout of `LLVMRustMCDCBranchParameters`.

Diff for: compiler/rustc_codegen_llvm/src/coverageinfo/mod.rs

+6-7
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,10 @@ impl<'ll, 'tcx> CrateCoverageContext<'ll, 'tcx> {
4848
self.function_coverage_map.replace(FxIndexMap::default())
4949
}
5050

51-
/// LLVM use a temp value to record evaluated mcdc test vector of each decision, which is called condition bitmap.
52-
/// In order to handle nested decisions, several condition bitmaps can be
53-
/// allocated for a function body.
54-
/// These values are named `mcdc.addr.{i}` and are a 32-bit integers.
55-
/// They respectively hold the condition bitmaps for decisions with a depth of `i`.
51+
/// LLVM use a temp value to record evaluated mcdc test vector of each decision, which is
52+
/// called condition bitmap. In order to handle nested decisions, several condition bitmaps can
53+
/// be allocated for a function body. These values are named `mcdc.addr.{i}` and are a 32-bit
54+
/// integers. They respectively hold the condition bitmaps for decisions with a depth of `i`.
5655
fn try_get_mcdc_condition_bitmap(
5756
&self,
5857
instance: &Instance<'tcx>,
@@ -157,8 +156,8 @@ impl<'tcx> CoverageInfoBuilderMethods<'tcx> for Builder<'_, '_, 'tcx> {
157156
),
158157
CoverageKind::CounterIncrement { id } => {
159158
func_coverage.mark_counter_id_seen(id);
160-
// We need to explicitly drop the `RefMut` before calling into `instrprof_increment`,
161-
// as that needs an exclusive borrow.
159+
// We need to explicitly drop the `RefMut` before calling into
160+
// `instrprof_increment`, as that needs an exclusive borrow.
162161
drop(coverage_map);
163162

164163
// The number of counters passed to `llvm.instrprof.increment` might

Diff for: compiler/rustc_codegen_llvm/src/debuginfo/gdb.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,8 @@ pub(crate) fn get_or_insert_gdb_debug_scripts_section_global<'ll>(
4444
// Add the pretty printers for the standard library first.
4545
section_contents.extend_from_slice(b"\x01gdb_load_rust_pretty_printers.py\0");
4646

47-
// Next, add the pretty printers that were specified via the `#[debugger_visualizer]` attribute.
47+
// Next, add the pretty printers that were specified via the `#[debugger_visualizer]`
48+
// attribute.
4849
let visualizers = collect_debugger_visualizers_transitive(
4950
cx.tcx,
5051
DebuggerVisualizerType::GdbPrettyPrinter,

Diff for: compiler/rustc_codegen_llvm/src/debuginfo/metadata.rs

+12-12
Original file line numberDiff line numberDiff line change
@@ -216,8 +216,9 @@ fn build_pointer_or_reference_di_node<'ll, 'tcx>(
216216
// need to make sure that we don't break existing debuginfo consumers
217217
// by doing that (at least not without a warning period).
218218
let layout_type = if ptr_type.is_box() {
219-
// The assertion at the start of this function ensures we have a ZST allocator.
220-
// We'll make debuginfo "skip" all ZST allocators, not just the default allocator.
219+
// The assertion at the start of this function ensures we have a ZST
220+
// allocator. We'll make debuginfo "skip" all ZST allocators, not just the
221+
// default allocator.
221222
Ty::new_mut_ptr(cx.tcx, pointee_type)
222223
} else {
223224
ptr_type
@@ -280,8 +281,7 @@ fn build_subroutine_type_di_node<'ll, 'tcx>(
280281
cx: &CodegenCx<'ll, 'tcx>,
281282
unique_type_id: UniqueTypeId<'tcx>,
282283
) -> DINodeCreationResult<'ll> {
283-
// It's possible to create a self-referential
284-
// type in Rust by using 'impl trait':
284+
// It's possible to create a self-referential type in Rust by using 'impl trait':
285285
//
286286
// fn foo() -> impl Copy { foo }
287287
//
@@ -573,14 +573,14 @@ pub(crate) fn file_metadata<'ll>(cx: &CodegenCx<'ll, '_>, source_file: &SourceFi
573573
{
574574
// If the compiler's working directory (which also is the DW_AT_comp_dir of
575575
// the compilation unit) is a prefix of the path we are about to emit, then
576-
// only emit the part relative to the working directory.
577-
// Because of path remapping we sometimes see strange things here: `abs_path`
578-
// might actually look like a relative path
579-
// (e.g. `<crate-name-and-version>/src/lib.rs`), so if we emit it without
580-
// taking the working directory into account, downstream tooling will
581-
// interpret it as `<working-directory>/<crate-name-and-version>/src/lib.rs`,
582-
// which makes no sense. Usually in such cases the working directory will also
583-
// be remapped to `<crate-name-and-version>` or some other prefix of the path
576+
// only emit the part relative to the working directory. Because of path
577+
// remapping we sometimes see strange things here: `abs_path` might
578+
// actually look like a relative path (e.g.
579+
// `<crate-name-and-version>/src/lib.rs`), so if we emit it without taking
580+
// the working directory into account, downstream tooling will interpret it
581+
// as `<working-directory>/<crate-name-and-version>/src/lib.rs`, which
582+
// makes no sense. Usually in such cases the working directory will also be
583+
// remapped to `<crate-name-and-version>` or some other prefix of the path
584584
// we are remapping, so we end up with
585585
// `<crate-name-and-version>/<crate-name-and-version>/src/lib.rs`.
586586
// By moving the working directory portion into the `directory` part of the

Diff for: compiler/rustc_codegen_llvm/src/intrinsic.rs

+6-4
Original file line numberDiff line numberDiff line change
@@ -404,7 +404,8 @@ impl<'ll, 'tcx> IntrinsicCallBuilderMethods<'tcx> for Builder<'_, 'll, 'tcx> {
404404
let llvm_name =
405405
&format!("llvm.fsh{}.i{}", if is_left { 'l' } else { 'r' }, width);
406406

407-
// llvm expects shift to be the same type as the values, but rust always uses `u32`
407+
// llvm expects shift to be the same type as the values, but rust
408+
// always uses `u32`.
408409
let raw_shift = self.intcast(raw_shift, self.val_ty(val), false);
409410

410411
self.call_intrinsic(llvm_name, &[val, val, raw_shift])
@@ -573,8 +574,8 @@ impl<'ll, 'tcx> IntrinsicCallBuilderMethods<'tcx> for Builder<'_, 'll, 'tcx> {
573574
span,
574575
) {
575576
Ok(llval) => llval,
576-
// If there was an error, just skip this invocation... we'll abort compilation anyway,
577-
// but we can keep codegen'ing to find more errors.
577+
// If there was an error, just skip this invocation... we'll abort compilation
578+
// anyway, but we can keep codegen'ing to find more errors.
578579
Err(()) => return Ok(()),
579580
}
580581
}
@@ -1847,7 +1848,8 @@ fn generic_simd_intrinsic<'ll, 'tcx>(
18471848
require!(
18481849
matches!(
18491850
*pointer_ty.kind(),
1850-
ty::RawPtr(p_ty, p_mutbl) if p_ty == values_elem && p_ty.kind() == values_elem.kind() && p_mutbl.is_mut()
1851+
ty::RawPtr(p_ty, p_mutbl)
1852+
if p_ty == values_elem && p_ty.kind() == values_elem.kind() && p_mutbl.is_mut()
18511853
),
18521854
InvalidMonomorphization::ExpectedElementType {
18531855
span,

Diff for: compiler/rustc_codegen_llvm/src/llvm/ffi.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -2150,7 +2150,8 @@ unsafe extern "C" {
21502150

21512151
pub fn LLVMRustGetHostCPUName(len: *mut usize) -> *const c_char;
21522152

2153-
// This function makes copies of pointed to data, so the data's lifetime may end after this function returns
2153+
// This function makes copies of pointed to data, so the data's lifetime may end after this
2154+
// function returns.
21542155
pub fn LLVMRustCreateTargetMachine(
21552156
Triple: *const c_char,
21562157
CPU: *const c_char,

0 commit comments

Comments
 (0)