Skip to content

Commit 555e1d0

Browse files
committed
Auto merge of rust-lang#140295 - antoyo:subtree-update_cg_gcc_2025-04-25, r=GuillaumeGomez
Subtree update cg_gcc 2025/04/25 r? GuillaumeGomez
2 parents b4c8b0c + 3cd97b6 commit 555e1d0

File tree

10 files changed

+46
-39
lines changed

10 files changed

+46
-39
lines changed
+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
[toolchain]
2-
channel = "nightly-2025-04-17"
2+
channel = "nightly-2025-04-25"
33
components = ["rust-src", "rustc-dev", "llvm-tools-preview"]

compiler/rustc_codegen_gcc/src/asm.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -165,10 +165,10 @@ impl<'a, 'gcc, 'tcx> AsmBuilderMethods<'tcx> for Builder<'a, 'gcc, 'tcx> {
165165
let mut input_registers = vec![];
166166

167167
for op in rust_operands {
168-
if let InlineAsmOperandRef::In { reg, .. } = *op {
169-
if let ConstraintOrRegister::Register(reg_name) = reg_to_gcc(reg) {
170-
input_registers.push(reg_name);
171-
}
168+
if let InlineAsmOperandRef::In { reg, .. } = *op
169+
&& let ConstraintOrRegister::Register(reg_name) = reg_to_gcc(reg)
170+
{
171+
input_registers.push(reg_name);
172172
}
173173
}
174174

compiler/rustc_codegen_gcc/src/common.rs

+5-6
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,11 @@ impl<'gcc, 'tcx> CodegenCx<'gcc, 'tcx> {
3333
}
3434

3535
pub fn const_bitcast(&self, value: RValue<'gcc>, typ: Type<'gcc>) -> RValue<'gcc> {
36-
if value.get_type() == self.bool_type.make_pointer() {
37-
if let Some(pointee) = typ.get_pointee() {
38-
if pointee.dyncast_vector().is_some() {
39-
panic!()
40-
}
41-
}
36+
if value.get_type() == self.bool_type.make_pointer()
37+
&& let Some(pointee) = typ.get_pointee()
38+
&& pointee.dyncast_vector().is_some()
39+
{
40+
panic!()
4241
}
4342
// NOTE: since bitcast makes a value non-constant, don't bitcast if not necessary as some
4443
// SIMD builtins require a constant value.

compiler/rustc_codegen_gcc/src/consts.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -242,10 +242,10 @@ impl<'gcc, 'tcx> CodegenCx<'gcc, 'tcx> {
242242
let fn_attrs = self.tcx.codegen_fn_attrs(def_id);
243243

244244
let global = if def_id.is_local() && !self.tcx.is_foreign_item(def_id) {
245-
if let Some(global) = self.get_declared_value(sym) {
246-
if self.val_ty(global) != self.type_ptr_to(gcc_type) {
247-
span_bug!(self.tcx.def_span(def_id), "Conflicting types for static");
248-
}
245+
if let Some(global) = self.get_declared_value(sym)
246+
&& self.val_ty(global) != self.type_ptr_to(gcc_type)
247+
{
248+
span_bug!(self.tcx.def_span(def_id), "Conflicting types for static");
249249
}
250250

251251
let is_tls = fn_attrs.flags.contains(CodegenFnAttrFlags::THREAD_LOCAL);

compiler/rustc_codegen_gcc/src/debuginfo.rs

+9-8
Original file line numberDiff line numberDiff line change
@@ -126,14 +126,15 @@ fn make_mir_scope<'gcc, 'tcx>(
126126
return;
127127
};
128128

129-
if let Some(ref vars) = *variables {
130-
if !vars.contains(scope) && scope_data.inlined.is_none() {
131-
// Do not create a DIScope if there are no variables defined in this
132-
// MIR `SourceScope`, and it's not `inlined`, to avoid debuginfo bloat.
133-
debug_context.scopes[scope] = parent_scope;
134-
instantiated.insert(scope);
135-
return;
136-
}
129+
if let Some(ref vars) = *variables
130+
&& !vars.contains(scope)
131+
&& scope_data.inlined.is_none()
132+
{
133+
// Do not create a DIScope if there are no variables defined in this
134+
// MIR `SourceScope`, and it's not `inlined`, to avoid debuginfo bloat.
135+
debug_context.scopes[scope] = parent_scope;
136+
instantiated.insert(scope);
137+
return;
137138
}
138139

139140
let loc = cx.lookup_debug_loc(scope_data.span.lo());

compiler/rustc_codegen_gcc/src/gcc_util.rs

+6-8
Original file line numberDiff line numberDiff line change
@@ -136,14 +136,12 @@ pub(crate) fn global_gcc_features(sess: &Session, diagnostics: bool) -> Vec<Stri
136136
});
137137
features.extend(feats);
138138

139-
if diagnostics {
140-
if let Some(f) = check_tied_features(sess, &featsmap) {
141-
sess.dcx().emit_err(TargetFeatureDisableOrEnable {
142-
features: f,
143-
span: None,
144-
missing_features: None,
145-
});
146-
}
139+
if diagnostics && let Some(f) = check_tied_features(sess, &featsmap) {
140+
sess.dcx().emit_err(TargetFeatureDisableOrEnable {
141+
features: f,
142+
span: None,
143+
missing_features: None,
144+
});
147145
}
148146

149147
features

compiler/rustc_codegen_gcc/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
#![warn(rust_2018_idioms)]
2323
#![warn(unused_lifetimes)]
2424
#![deny(clippy::pattern_type_mismatch)]
25-
#![allow(clippy::needless_lifetimes)]
25+
#![allow(clippy::needless_lifetimes, clippy::uninlined_format_args)]
2626

2727
// Some "regular" crates we want to share with rustc
2828
extern crate object;

compiler/rustc_codegen_gcc/src/type_of.rs

+7-7
Original file line numberDiff line numberDiff line change
@@ -102,10 +102,10 @@ fn uncached_gcc_type<'gcc, 'tcx>(
102102
let mut name = with_no_trimmed_paths!(layout.ty.to_string());
103103
if let (&ty::Adt(def, _), &Variants::Single { index }) =
104104
(layout.ty.kind(), &layout.variants)
105+
&& def.is_enum()
106+
&& !def.variants().is_empty()
105107
{
106-
if def.is_enum() && !def.variants().is_empty() {
107-
write!(&mut name, "::{}", def.variant(index).name).unwrap();
108-
}
108+
write!(&mut name, "::{}", def.variant(index).name).unwrap();
109109
}
110110
if let (&ty::Coroutine(_, _), &Variants::Single { index }) =
111111
(layout.ty.kind(), &layout.variants)
@@ -264,10 +264,10 @@ impl<'tcx> LayoutGccExt<'tcx> for TyAndLayout<'tcx> {
264264
}
265265

266266
fn immediate_gcc_type<'gcc>(&self, cx: &CodegenCx<'gcc, 'tcx>) -> Type<'gcc> {
267-
if let BackendRepr::Scalar(ref scalar) = self.backend_repr {
268-
if scalar.is_bool() {
269-
return cx.type_i1();
270-
}
267+
if let BackendRepr::Scalar(ref scalar) = self.backend_repr
268+
&& scalar.is_bool()
269+
{
270+
return cx.type_i1();
271271
}
272272
self.gcc_type(cx)
273273
}

compiler/rustc_codegen_gcc/tests/lang_tests_common.rs

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
//! The common code for `tests/lang_tests_*.rs`
22
3+
#![allow(clippy::uninlined_format_args)]
4+
35
use std::env::{self, current_dir};
46
use std::path::{Path, PathBuf};
57
use std::process::Command;

compiler/rustc_codegen_gcc/tests/run/ptr_cast.rs

+7
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
// stdout: 10
66
// 10
77
// 42
8+
// 1
89

910
#![feature(no_core)]
1011
#![no_std]
@@ -21,13 +22,19 @@ fn int_cast(a: u16, b: i16) -> (u8, u16, u32, usize, i8, i16, i32, isize, u8, u3
2122
)
2223
}
2324

25+
static mut ONE: usize = 1;
26+
2427
#[no_mangle]
2528
extern "C" fn main(argc: i32, _argv: *const *const u8) -> i32 {
2629
let (a, b, c, d, e, f, g, h, i, j) = int_cast(10, 42);
2730
unsafe {
2831
libc::printf(b"%d\n\0" as *const u8 as *const i8, c);
2932
libc::printf(b"%ld\n\0" as *const u8 as *const i8, d);
3033
libc::printf(b"%ld\n\0" as *const u8 as *const i8, j);
34+
35+
let ptr = ONE as *mut usize;
36+
let value = ptr as usize;
37+
libc::printf(b"%ld\n\0" as *const u8 as *const i8, value);
3138
}
3239
0
3340
}

0 commit comments

Comments
 (0)