Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

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

compiler/rustc_codegen_llvm/src/attributes.rs

Lines changed: 5 additions & 3 deletions
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
}

compiler/rustc_codegen_llvm/src/back/lto.rs

Lines changed: 6 additions & 6 deletions
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 {

compiler/rustc_codegen_llvm/src/back/owned_target_machine.rs

Lines changed: 5 additions & 3 deletions
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
}

compiler/rustc_codegen_llvm/src/back/write.rs

Lines changed: 4 additions & 3 deletions
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

compiler/rustc_codegen_llvm/src/builder.rs

Lines changed: 5 additions & 5 deletions
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] =

compiler/rustc_codegen_llvm/src/consts.rs

Lines changed: 11 additions & 10 deletions
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) {

compiler/rustc_codegen_llvm/src/context.rs

Lines changed: 2 additions & 1 deletion
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 {

compiler/rustc_codegen_llvm/src/coverageinfo/ffi.rs

Lines changed: 2 additions & 1 deletion
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`.

compiler/rustc_codegen_llvm/src/coverageinfo/mod.rs

Lines changed: 6 additions & 7 deletions
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

compiler/rustc_codegen_llvm/src/debuginfo/gdb.rs

Lines changed: 2 additions & 1 deletion
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,

0 commit comments

Comments
 (0)