Skip to content

Rollup of 8 pull requests #143753

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 46 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
e101e38
std_detect: Tidying of slice length
a4lg Jun 29, 2025
bb2d169
use `is_multiple_of` to check if an addr is aligned
folkertdev Jul 5, 2025
e8d9e80
Add empty rust-version file
Kobzol Jun 26, 2025
f697f81
Add josh synchronization scripts
Kobzol Jun 26, 2025
8ae4e6a
Update stabilization version of certain x86 intrinsics to 1.89
Amanieu Jun 30, 2025
e46d220
Use simd_extract! macro instead of calling simd_extract directly
clarfonthey Jun 30, 2025
600497f
Mark `avx` broadcast intrinsics as safe
okaneco Jun 23, 2025
b535003
Remove std-detect dev dependency in core_arch
Kobzol Jul 4, 2025
816f029
Update README.md
kilavvy Jun 29, 2025
8600192
Add config files for `rustc-josh-sync`
Kobzol Jul 4, 2025
ce73251
Prepare for merging from rust-lang/rust
Kobzol Jul 4, 2025
1bc289d
std_detect: RISC-V Linux: Ergonomic querying with `riscv_hwprobe`
a4lg Jun 29, 2025
fddd05b
some clippy fixes
hkBst Jul 6, 2025
658b5c8
Use `simd_funnel_sh{l,r}` and `simd_round_ties_even` to remove uses o…
sayantn Jul 7, 2025
a95bd00
Remove custom josh-sync scripts
Kobzol Jul 8, 2025
07d5fbb
Update README with link to `josh-sync`
Kobzol Jul 8, 2025
82126a6
fix whitespace in `aarch64.spec.yml`
folkertdev Jul 8, 2025
323c646
remote intermediate assignment
folkertdev Jul 8, 2025
92701fe
shorten array literals
folkertdev Jul 8, 2025
061a941
remove unneeded cast
folkertdev Jul 8, 2025
701d222
Reset rust-version
Kobzol Jul 8, 2025
3c9297c
Prepare for merging from rust-lang/rust
Kobzol Jul 8, 2025
bdead41
Merge ref '040e2f8b9ff2' from rust-lang/rust
Kobzol Jul 8, 2025
a310bdd
Merge pull request #1853 from Kobzol/pull-fixed
Amanieu Jul 8, 2025
d54c3ea
Preserve the .debug_gdb_scripts section
sebastianpoeplau Jul 3, 2025
e47eb32
Rename `*AsmOperandRef::Const` to `Interpolate`
nbdd0121 Oct 17, 2024
2028157
Add `InlineAsmOperandRef::Const`
nbdd0121 Oct 17, 2024
b38ec0d
Implement asm_const_ptr for inline asm
nbdd0121 Oct 24, 2024
60179d3
Give global_asm mangled names
nbdd0121 Mar 12, 2025
363fd49
Collect constants within `global_asm!` in collector
nbdd0121 Mar 12, 2025
81a4b3e
Implement asm_const_ptr for global_asm and naked_asm
nbdd0121 Mar 14, 2025
3e675f4
Fix `--skip-std-check-if-no-download-rustc`
Kobzol Jul 9, 2025
84eeca2
Make some "safe" llvm ops actually sound
oli-obk Jul 10, 2025
7632c55
extract single_import_can_define_name and finalize_glob_module_binding
b-naber Jul 10, 2025
7dfc3e9
Rework borrowing suggestions to use `Expr` instead of just `Span`
estebank Jul 10, 2025
0674eca
Make `Diag::multipart_suggestions` always verbose
estebank Jul 10, 2025
d692444
Update test
estebank Jul 10, 2025
341f12d
Properly track the depth when expanding free alias types
fmease Jul 10, 2025
0fa707b
Rollup merge of #138618 - nbdd0121:asm_const_ptr, r=compiler-errors
tgross35 Jul 10, 2025
00f2a41
Rollup merge of #143642 - Kobzol:stdarch-push, r=Amanieu
tgross35 Jul 10, 2025
5a09646
Rollup merge of #143679 - sebastianpoeplau:preserve-debug-gdb-scripts…
tgross35 Jul 10, 2025
e0eab83
Rollup merge of #143707 - Kobzol:bootstrap-std-check, r=jieyouxu
tgross35 Jul 10, 2025
4476dbe
Rollup merge of #143722 - oli-obk:sound-llvm, r=dianqk
tgross35 Jul 10, 2025
3ebdb8b
Rollup merge of #143728 - LorrensP-2158466:refactor-resolve-extractio…
tgross35 Jul 10, 2025
a85c1bb
Rollup merge of #143742 - estebank:borrow-suggestion, r=compiler-errors
tgross35 Jul 10, 2025
6cd0b1c
Rollup merge of #143744 - fmease:lta-expand-proper-depth, r=compiler-…
tgross35 Jul 10, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions compiler/rustc_codegen_cranelift/src/global_asm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ use std::sync::Arc;

use rustc_ast::{InlineAsmOptions, InlineAsmTemplatePiece};
use rustc_codegen_ssa::traits::{AsmCodegenMethods, GlobalAsmOperandRef};
use rustc_middle::ty::TyCtxt;
use rustc_middle::ty::layout::{
FnAbiError, FnAbiOfHelpers, FnAbiRequest, HasTyCtxt, HasTypingEnv, LayoutError, LayoutOfHelpers,
};
use rustc_middle::ty::{Instance, TyCtxt};
use rustc_session::config::{OutputFilenames, OutputType};
use rustc_target::asm::InlineAsmArch;

Expand All @@ -29,6 +29,7 @@ impl<'tcx> AsmCodegenMethods<'tcx> for GlobalAsmContext<'_, 'tcx> {
operands: &[GlobalAsmOperandRef<'tcx>],
options: InlineAsmOptions,
_line_spans: &[Span],
_instance: Instance<'_>,
) {
codegen_global_asm_inner(self.tcx, self.global_asm, template, operands, options);
}
Expand Down Expand Up @@ -104,7 +105,7 @@ fn codegen_global_asm_inner<'tcx>(
InlineAsmTemplatePiece::String(ref s) => global_asm.push_str(s),
InlineAsmTemplatePiece::Placeholder { operand_idx, modifier: _, span } => {
match operands[operand_idx] {
GlobalAsmOperandRef::Const { ref string } => {
GlobalAsmOperandRef::Interpolate { ref string } => {
global_asm.push_str(string);
}
GlobalAsmOperandRef::SymFn { instance } => {
Expand Down Expand Up @@ -132,6 +133,12 @@ fn codegen_global_asm_inner<'tcx>(
let symbol = tcx.symbol_name(instance);
global_asm.push_str(symbol.name);
}
GlobalAsmOperandRef::ConstPointer { value: _ } => {
tcx.dcx().span_err(
span,
"asm! and global_asm! const pointer operands are not yet supported",
);
}
}
}
}
Expand Down
150 changes: 119 additions & 31 deletions compiler/rustc_codegen_gcc/src/asm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@

use std::borrow::Cow;

use gccjit::{LValue, RValue, ToRValue, Type};
use gccjit::{GlobalKind, LValue, RValue, ToRValue, Type};
use rustc_ast::ast::{InlineAsmOptions, InlineAsmTemplatePiece};
use rustc_codegen_ssa::mir::operand::OperandValue;
use rustc_codegen_ssa::mir::place::PlaceRef;
use rustc_codegen_ssa::traits::{
AsmBuilderMethods, AsmCodegenMethods, BaseTypeCodegenMethods, BuilderMethods,
GlobalAsmOperandRef, InlineAsmOperandRef,
};
use rustc_middle::bug;
use rustc_middle::ty::Instance;
use rustc_middle::{bug, mir};
use rustc_span::Span;
use rustc_target::asm::*;

Expand Down Expand Up @@ -296,10 +296,18 @@ impl<'a, 'gcc, 'tcx> AsmBuilderMethods<'tcx> for Builder<'a, 'gcc, 'tcx> {
}
}

InlineAsmOperandRef::Const { ref string } => {
InlineAsmOperandRef::Interpolate { ref string } => {
constants_len += string.len() + att_dialect as usize;
}

InlineAsmOperandRef::Const { value } => {
inputs.push(AsmInOperand {
constraint: Cow::Borrowed("i"),
rust_idx,
val: value.immediate(),
});
}

InlineAsmOperandRef::SymFn { instance } => {
// TODO(@Amanieu): Additional mangling is needed on
// some targets to add a leading underscore (Mach-O)
Expand Down Expand Up @@ -411,6 +419,10 @@ impl<'a, 'gcc, 'tcx> AsmBuilderMethods<'tcx> for Builder<'a, 'gcc, 'tcx> {
});
}

InlineAsmOperandRef::Interpolate { .. } => {
// processed in the previous pass
}

InlineAsmOperandRef::Const { .. } => {
// processed in the previous pass
}
Expand Down Expand Up @@ -488,6 +500,15 @@ impl<'a, 'gcc, 'tcx> AsmBuilderMethods<'tcx> for Builder<'a, 'gcc, 'tcx> {
push_to_template(modifier, gcc_index);
}

InlineAsmOperandRef::Const { .. } => {
let in_gcc_index = inputs
.iter()
.position(|op| operand_idx == op.rust_idx)
.expect("wrong rust index");
let gcc_index = in_gcc_index + outputs.len();
push_to_template(None, gcc_index);
}

InlineAsmOperandRef::SymFn { instance } => {
// TODO(@Amanieu): Additional mangling is needed on
// some targets to add a leading underscore (Mach-O)
Expand All @@ -504,7 +525,7 @@ impl<'a, 'gcc, 'tcx> AsmBuilderMethods<'tcx> for Builder<'a, 'gcc, 'tcx> {
template_str.push_str(name);
}

InlineAsmOperandRef::Const { ref string } => {
InlineAsmOperandRef::Interpolate { ref string } => {
template_str.push_str(string);
}

Expand Down Expand Up @@ -837,13 +858,106 @@ impl<'gcc, 'tcx> AsmCodegenMethods<'tcx> for CodegenCx<'gcc, 'tcx> {
operands: &[GlobalAsmOperandRef<'tcx>],
options: InlineAsmOptions,
_line_spans: &[Span],
instance: Instance<'tcx>,
) {
let asm_arch = self.tcx.sess.asm_arch.unwrap();

// Default to Intel syntax on x86
let att_dialect = matches!(asm_arch, InlineAsmArch::X86 | InlineAsmArch::X86_64)
&& options.contains(InlineAsmOptions::ATT_SYNTAX);

// Convert all operands to string interpolations
let converted_operands = operands
.iter()
.enumerate()
.map(|(operand_idx, operand)| {
match *operand {
GlobalAsmOperandRef::Interpolate { ref string } => {
// Const operands get injected directly into the
// template. Note that we don't need to escape $
// here unlike normal inline assembly.
string.to_owned()
}
GlobalAsmOperandRef::ConstPointer { value } => {
let (prov, offset) = value.prov_and_relative_offset();
let global_alloc = self.tcx.global_alloc(prov.alloc_id());
let symbol = 'sym: {
let alloc = match global_alloc {
mir::interpret::GlobalAlloc::Function { instance } => {
let function = get_fn(self, instance);
self.add_used_function(function);
// TODO(@Amanieu): Additional mangling is needed on
// some targets to add a leading underscore (Mach-O)
// or byte count suffixes (x86 Windows).
break 'sym self.tcx.symbol_name(instance).name.to_owned();
}
mir::interpret::GlobalAlloc::VTable(ty, dyn_ty) => self
.tcx
.global_alloc(self.tcx.vtable_allocation((
ty,
dyn_ty.principal().map(|principal| {
self.tcx
.instantiate_bound_regions_with_erased(principal)
}),
)))
.unwrap_memory(),
mir::interpret::GlobalAlloc::Static(def_id) => {
// TODO(antoyo): set the global variable as used.
// TODO(@Amanieu): Additional mangling is needed on
// some targets to add a leading underscore (Mach-O).
let instance = Instance::mono(self.tcx, def_id);
break 'sym self.tcx.symbol_name(instance).name.to_owned();
}
mir::interpret::GlobalAlloc::Memory(alloc) => alloc,
};

// For ZSTs directly codegen an aligned pointer.
if alloc.inner().len() == 0 {
assert_eq!(offset.bytes(), 0);
return format!("{}", alloc.inner().align.bytes());
}

let asm_name = self.tcx.symbol_name(instance);
let sym_name = format!("{asm_name}.{operand_idx}");

let init = crate::consts::const_alloc_to_gcc_uncached(self, alloc);
let alloc = alloc.inner();
let typ = self.val_ty(init).get_aligned(alloc.align.bytes());

let global = self.declare_global_with_linkage(
&sym_name,
typ,
GlobalKind::Exported,
);
global.global_set_initializer_rvalue(init);
// TODO(nbdd0121): set unnamed address.
// TODO(nbdd0121): set the global variable as used.

sym_name
};

let offset = offset.bytes();
if offset != 0 { format!("{symbol}+{offset}") } else { symbol }
}
GlobalAsmOperandRef::SymFn { instance } => {
let function = get_fn(self, instance);
self.add_used_function(function);
// TODO(@Amanieu): Additional mangling is needed on
// some targets to add a leading underscore (Mach-O)
// or byte count suffixes (x86 Windows).
self.tcx.symbol_name(instance).name.to_owned()
}
GlobalAsmOperandRef::SymStatic { def_id } => {
// TODO(antoyo): set the global variable as used.
// TODO(@Amanieu): Additional mangling is needed on
// some targets to add a leading underscore (Mach-O).
let instance = Instance::mono(self.tcx, def_id);
self.tcx.symbol_name(instance).name.to_owned()
}
}
})
.collect::<Vec<_>>();

// Build the template string
let mut template_str = ".pushsection .text\n".to_owned();
if att_dialect {
Expand All @@ -867,33 +981,7 @@ impl<'gcc, 'tcx> AsmCodegenMethods<'tcx> for CodegenCx<'gcc, 'tcx> {
}
}
InlineAsmTemplatePiece::Placeholder { operand_idx, modifier: _, span: _ } => {
match operands[operand_idx] {
GlobalAsmOperandRef::Const { ref string } => {
// Const operands get injected directly into the
// template. Note that we don't need to escape %
// here unlike normal inline assembly.
template_str.push_str(string);
}

GlobalAsmOperandRef::SymFn { instance } => {
let function = get_fn(self, instance);
self.add_used_function(function);
// TODO(@Amanieu): Additional mangling is needed on
// some targets to add a leading underscore (Mach-O)
// or byte count suffixes (x86 Windows).
let name = self.tcx.symbol_name(instance).name;
template_str.push_str(name);
}

GlobalAsmOperandRef::SymStatic { def_id } => {
// TODO(antoyo): set the global variable as used.
// TODO(@Amanieu): Additional mangling is needed on
// some targets to add a leading underscore (Mach-O).
let instance = Instance::mono(self.tcx, def_id);
let name = self.tcx.symbol_name(instance).name;
template_str.push_str(name);
}
}
template_str.push_str(&converted_operands[operand_idx]);
}
}
}
Expand Down
7 changes: 2 additions & 5 deletions compiler/rustc_codegen_gcc/src/debuginfo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,6 @@ impl<'a, 'gcc, 'tcx> DebugInfoBuilderMethods for Builder<'a, 'gcc, 'tcx> {
_variable_alloca.set_location(_dbg_loc);
}

fn insert_reference_to_gdb_debug_scripts_section_global(&mut self) {
// TODO(antoyo): insert reference to gdb debug scripts section global.
}

/// FIXME(tempdragon): Currently, this function is not yet implemented. It seems that the
/// debug name and the mangled name should both be included in the LValues.
/// Besides, a function to get the rvalue type(m_is_lvalue) should also be included.
Expand Down Expand Up @@ -254,7 +250,8 @@ impl<'gcc, 'tcx> DebugInfoCodegenMethods<'tcx> for CodegenCx<'gcc, 'tcx> {
// TODO(antoyo): implement.
}

fn debuginfo_finalize(&self) {
fn debuginfo_finalize(&mut self) {
// TODO: emit section `.debug_gdb_scripts`.
self.context.set_debug_info(true)
}

Expand Down
Loading
Loading