Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
This repository was archived by the owner on May 28, 2025. It is now read-only.
/rustPublic archive
forked fromrust-lang/rust

Commitae9f501

Browse files
committed
Auto merge ofrust-lang#129647 - tgross35:rollup-jume49s, r=tgross35
Rollup of 9 pull requestsSuccessful merges: -rust-lang#126985 (Implement `-Z embed-source` (DWARFv5 source code embedding extension)) -rust-lang#127922 (Add unsafe to extern blocks in style guide) -rust-lang#128731 (simd_shuffle intrinsic: allow argument to be passed as vector) -rust-lang#128935 (More work on `zstd` compression) -rust-lang#128942 (miri weak memory emulation: put previous value into initial store buffer) -rust-lang#129418 (rustc: Simplify getting sysroot library directory) -rust-lang#129490 (Add Trusty OS as tier 3 target) -rust-lang#129536 (Add `f16` and `f128` inline ASM support for `aarch64`) -rust-lang#129559 (float types: document NaN bit pattern guarantees)r? `@ghost``@rustbot` modify labels: rollup
2 parentsbf662eb +75ae913 commitae9f501

File tree

58 files changed

+1009
-310
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

58 files changed

+1009
-310
lines changed

‎compiler/rustc_codegen_cranelift/src/intrinsics/simd.rs‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,14 @@ pub(super) fn codegen_simd_intrinsic_call<'tcx>(
191191
})
192192
.try_into()
193193
.unwrap(),
194+
_if idx_ty.is_simd()
195+
&&matches!(
196+
idx_ty.simd_size_and_type(fx.tcx).1.kind(),
197+
ty::Uint(ty::UintTy::U32)
198+
) =>
199+
{
200+
idx_ty.simd_size_and_type(fx.tcx).0.try_into().unwrap()
201+
}
194202
_ =>{
195203
fx.tcx.dcx().span_err(
196204
span,
@@ -213,6 +221,8 @@ pub(super) fn codegen_simd_intrinsic_call<'tcx>(
213221

214222
let total_len = lane_count*2;
215223

224+
// FIXME: this is a terrible abstraction-breaking hack.
225+
// Find a way to reuse `immediate_const_vector` from `codegen_ssa` instead.
216226
let indexes ={
217227
use rustc_middle::mir::interpret::*;
218228
let idx_const =match&idx.node{

‎compiler/rustc_codegen_gcc/src/builder.rs‎

Lines changed: 30 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1923,15 +1923,11 @@ impl<'a, 'gcc, 'tcx> Builder<'a, 'gcc, 'tcx> {
19231923
v2:RValue<'gcc>,
19241924
mask:RValue<'gcc>,
19251925
) ->RValue<'gcc>{
1926-
let struct_type = mask.get_type().is_struct().expect("mask should be of struct type");
1927-
19281926
// TODO(antoyo): use a recursive unqualified() here.
19291927
let vector_type = v1.get_type().unqualified().dyncast_vector().expect("vector type");
19301928
let element_type = vector_type.get_element_type();
19311929
let vec_num_units = vector_type.get_num_units();
19321930

1933-
let mask_num_units = struct_type.get_field_count();
1934-
letmut vector_elements =vec![];
19351931
let mask_element_type =if element_type.is_integral(){
19361932
element_type
19371933
}else{
@@ -1942,19 +1938,39 @@ impl<'a, 'gcc, 'tcx> Builder<'a, 'gcc, 'tcx> {
19421938
#[cfg(not(feature ="master"))]
19431939
self.int_type
19441940
};
1945-
for iin0..mask_num_units{
1946-
let field = struct_type.get_field(iasi32);
1947-
vector_elements.push(self.context.new_cast(
1948-
self.location,
1949-
mask.access_field(self.location, field).to_rvalue(),
1950-
mask_element_type,
1951-
));
1952-
}
1941+
1942+
letmut mask_elements =ifletSome(vector_type) = mask.get_type().dyncast_vector(){
1943+
let mask_num_units = vector_type.get_num_units();
1944+
letmut mask_elements =vec![];
1945+
for iin0..mask_num_units{
1946+
let index =self.context.new_rvalue_from_long(self.cx.type_u32(), ias_);
1947+
mask_elements.push(self.context.new_cast(
1948+
self.location,
1949+
self.extract_element(mask, index).to_rvalue(),
1950+
mask_element_type,
1951+
));
1952+
}
1953+
mask_elements
1954+
}else{
1955+
let struct_type = mask.get_type().is_struct().expect("mask should be of struct type");
1956+
let mask_num_units = struct_type.get_field_count();
1957+
letmut mask_elements =vec![];
1958+
for iin0..mask_num_units{
1959+
let field = struct_type.get_field(iasi32);
1960+
mask_elements.push(self.context.new_cast(
1961+
self.location,
1962+
mask.access_field(self.location, field).to_rvalue(),
1963+
mask_element_type,
1964+
));
1965+
}
1966+
mask_elements
1967+
};
1968+
let mask_num_units = mask_elements.len();
19531969

19541970
// NOTE: the mask needs to be the same length as the input vectors, so add the missing
19551971
// elements in the mask if needed.
19561972
for _in mask_num_units..vec_num_units{
1957-
vector_elements.push(self.context.new_rvalue_zero(mask_element_type));
1973+
mask_elements.push(self.context.new_rvalue_zero(mask_element_type));
19581974
}
19591975

19601976
let result_type =self.context.new_vector_type(element_type, mask_num_unitsasu64);
@@ -1998,7 +2014,7 @@ impl<'a, 'gcc, 'tcx> Builder<'a, 'gcc, 'tcx> {
19982014

19992015
let new_mask_num_units = std::cmp::max(mask_num_units, vec_num_units);
20002016
let mask_type =self.context.new_vector_type(mask_element_type, new_mask_num_unitsasu64);
2001-
let mask =self.context.new_rvalue_from_vector(self.location, mask_type,&vector_elements);
2017+
let mask =self.context.new_rvalue_from_vector(self.location, mask_type,&mask_elements);
20022018
let result =self.context.new_rvalue_vector_perm(self.location, v1, v2, mask);
20032019

20042020
if vec_num_units != mask_num_units{

‎compiler/rustc_codegen_gcc/src/intrinsic/simd.rs‎

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -353,19 +353,24 @@ pub fn generic_simd_intrinsic<'a, 'gcc, 'tcx>(
353353
}
354354

355355
if name == sym::simd_shuffle{
356-
// Make sure this is actually an array, since typeck only checks the length-suffixed
356+
// Make sure this is actually an array or SIMD vector, since typeck only checks the length-suffixed
357357
// version of this intrinsic.
358-
let n:u64 =match*args[2].layout.ty.kind(){
358+
let idx_ty = args[2].layout.ty;
359+
let n:u64 =match idx_ty.kind(){
359360
ty::Array(ty, len)ifmatches!(*ty.kind(), ty::Uint(ty::UintTy::U32)) =>{
360361
len.try_eval_target_usize(bx.cx.tcx, ty::ParamEnv::reveal_all()).unwrap_or_else(
361362
||span_bug!(span,"could not evaluate shuffle index array length"),
362363
)
363364
}
364-
_ =>return_error!(InvalidMonomorphization::SimdShuffle{
365-
span,
366-
name,
367-
ty: args[2].layout.ty
368-
}),
365+
_if idx_ty.is_simd()
366+
&&matches!(
367+
idx_ty.simd_size_and_type(bx.cx.tcx).1.kind(),
368+
ty::Uint(ty::UintTy::U32)
369+
) =>
370+
{
371+
idx_ty.simd_size_and_type(bx.cx.tcx).0
372+
}
373+
_ =>return_error!(InvalidMonomorphization::SimdShuffle{ span, name, ty: idx_ty}),
369374
};
370375
require_simd!(ret_ty,InvalidMonomorphization::SimdReturn{ span, name, ty: ret_ty});
371376

‎compiler/rustc_codegen_llvm/src/asm.rs‎

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -913,8 +913,10 @@ fn llvm_asm_scalar_type<'ll>(cx: &CodegenCx<'ll, '_>, scalar: Scalar) -> &'ll Ty
913913
Primitive::Int(Integer::I16, _) => cx.type_i16(),
914914
Primitive::Int(Integer::I32, _) => cx.type_i32(),
915915
Primitive::Int(Integer::I64, _) => cx.type_i64(),
916+
Primitive::Float(Float::F16) => cx.type_f16(),
916917
Primitive::Float(Float::F32) => cx.type_f32(),
917918
Primitive::Float(Float::F64) => cx.type_f64(),
919+
Primitive::Float(Float::F128) => cx.type_f128(),
918920
// FIXME(erikdesjardins): handle non-default addrspace ptr sizes
919921
Primitive::Pointer(_) => cx.type_from_integer(dl.ptr_sized_integer()),
920922
_ =>unreachable!(),
@@ -948,7 +950,9 @@ fn llvm_fixup_input<'ll, 'tcx>(
948950
value
949951
}
950952
}
951-
(InlineAsmRegClass::AArch64(AArch64InlineAsmRegClass::vreg_low16),Abi::Scalar(s)) =>{
953+
(InlineAsmRegClass::AArch64(AArch64InlineAsmRegClass::vreg_low16),Abi::Scalar(s))
954+
if s.primitive() !=Primitive::Float(Float::F128) =>
955+
{
952956
let elem_ty =llvm_asm_scalar_type(bx.cx, s);
953957
let count =16 / layout.size.bytes();
954958
let vec_ty = bx.cx.type_vector(elem_ty, count);
@@ -1090,7 +1094,9 @@ fn llvm_fixup_output<'ll, 'tcx>(
10901094
value
10911095
}
10921096
}
1093-
(InlineAsmRegClass::AArch64(AArch64InlineAsmRegClass::vreg_low16),Abi::Scalar(s)) =>{
1097+
(InlineAsmRegClass::AArch64(AArch64InlineAsmRegClass::vreg_low16),Abi::Scalar(s))
1098+
if s.primitive() !=Primitive::Float(Float::F128) =>
1099+
{
10941100
value = bx.extract_element(value, bx.const_i32(0));
10951101
ifletPrimitive::Pointer(_) = s.primitive(){
10961102
value = bx.inttoptr(value, layout.llvm_type(bx.cx));
@@ -1222,7 +1228,9 @@ fn llvm_fixup_output_type<'ll, 'tcx>(
12221228
layout.llvm_type(cx)
12231229
}
12241230
}
1225-
(InlineAsmRegClass::AArch64(AArch64InlineAsmRegClass::vreg_low16),Abi::Scalar(s)) =>{
1231+
(InlineAsmRegClass::AArch64(AArch64InlineAsmRegClass::vreg_low16),Abi::Scalar(s))
1232+
if s.primitive() !=Primitive::Float(Float::F128) =>
1233+
{
12261234
let elem_ty =llvm_asm_scalar_type(cx, s);
12271235
let count =16 / layout.size.bytes();
12281236
cx.type_vector(elem_ty, count)

‎compiler/rustc_codegen_llvm/src/debuginfo/metadata.rs‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -629,6 +629,9 @@ pub(crate) fn file_metadata<'ll>(cx: &CodegenCx<'ll, '_>, source_file: &SourceFi
629629
};
630630
let hash_value =hex_encode(source_file.src_hash.hash_bytes());
631631

632+
let source =
633+
cx.sess().opts.unstable_opts.embed_source.then_some(()).and(source_file.src.as_ref());
634+
632635
unsafe{
633636
llvm::LLVMRustDIBuilderCreateFile(
634637
DIB(cx),
@@ -639,6 +642,8 @@ pub(crate) fn file_metadata<'ll>(cx: &CodegenCx<'ll, '_>, source_file: &SourceFi
639642
hash_kind,
640643
hash_value.as_ptr().cast(),
641644
hash_value.len(),
645+
source.map_or(ptr::null(), |x| x.as_ptr().cast()),
646+
source.map_or(0, |x| x.len()),
642647
)
643648
}
644649
}
@@ -659,6 +664,8 @@ fn unknown_file_metadata<'ll>(cx: &CodegenCx<'ll, '_>) -> &'ll DIFile {
659664
llvm::ChecksumKind::None,
660665
hash_value.as_ptr().cast(),
661666
hash_value.len(),
667+
ptr::null(),
668+
0,
662669
)
663670
})
664671
}
@@ -943,6 +950,8 @@ pub(crate) fn build_compile_unit_di_node<'ll, 'tcx>(
943950
llvm::ChecksumKind::None,
944951
ptr::null(),
945952
0,
953+
ptr::null(),
954+
0,
946955
);
947956

948957
let unit_metadata = llvm::LLVMRustDIBuilderCreateCompileUnit(

‎compiler/rustc_codegen_llvm/src/intrinsic.rs‎

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1287,19 +1287,24 @@ fn generic_simd_intrinsic<'ll, 'tcx>(
12871287
}
12881288

12891289
if name == sym::simd_shuffle{
1290-
// Make sure this is actually an array, since typeck only checks the length-suffixed
1290+
// Make sure this is actually an array or SIMD vector, since typeck only checks the length-suffixed
12911291
// version of this intrinsic.
1292-
let n:u64 =match args[2].layout.ty.kind(){
1292+
let idx_ty = args[2].layout.ty;
1293+
let n:u64 =match idx_ty.kind(){
12931294
ty::Array(ty, len)ifmatches!(ty.kind(), ty::Uint(ty::UintTy::U32)) =>{
12941295
len.try_eval_target_usize(bx.cx.tcx, ty::ParamEnv::reveal_all()).unwrap_or_else(
12951296
||span_bug!(span,"could not evaluate shuffle index array length"),
12961297
)
12971298
}
1298-
_ =>return_error!(InvalidMonomorphization::SimdShuffle{
1299-
span,
1300-
name,
1301-
ty: args[2].layout.ty
1302-
}),
1299+
_if idx_ty.is_simd()
1300+
&&matches!(
1301+
idx_ty.simd_size_and_type(bx.cx.tcx).1.kind(),
1302+
ty::Uint(ty::UintTy::U32)
1303+
) =>
1304+
{
1305+
idx_ty.simd_size_and_type(bx.cx.tcx).0
1306+
}
1307+
_ =>return_error!(InvalidMonomorphization::SimdShuffle{ span, name, ty: idx_ty}),
13031308
};
13041309

13051310
let(out_len, out_ty) =require_simd!(ret_ty,SimdReturn);

‎compiler/rustc_codegen_llvm/src/llvm/ffi.rs‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1860,6 +1860,8 @@ extern "C" {
18601860
CSKind:ChecksumKind,
18611861
Checksum:*constc_char,
18621862
ChecksumLen:size_t,
1863+
Source:*constc_char,
1864+
SourceLen:size_t,
18631865
) ->&'aDIFile;
18641866

18651867
pubfnLLVMRustDIBuilderCreateSubroutineType<'a>(

‎compiler/rustc_codegen_ssa/src/back/link.rs‎

Lines changed: 11 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1317,11 +1317,9 @@ fn link_sanitizer_runtime(
13171317
name:&str,
13181318
){
13191319
fnfind_sanitizer_runtime(sess:&Session,filename:&str) ->PathBuf{
1320-
let session_tlib =
1321-
filesearch::make_target_lib_path(&sess.sysroot, sess.opts.target_triple.triple());
1322-
let path = session_tlib.join(filename);
1320+
let path = sess.target_tlib_path.dir.join(filename);
13231321
if path.exists(){
1324-
returnsession_tlib;
1322+
returnsess.target_tlib_path.dir.clone();
13251323
}else{
13261324
let default_sysroot =
13271325
filesearch::get_or_default_sysroot().expect("Failed finding sysroot");
@@ -1612,19 +1610,18 @@ fn print_native_static_libs(
16121610
}
16131611

16141612
fnget_object_file_path(sess:&Session,name:&str,self_contained:bool) ->PathBuf{
1615-
let fs = sess.target_filesearch(PathKind::Native);
1616-
let file_path = fs.get_lib_path().join(name);
1613+
let file_path = sess.target_tlib_path.dir.join(name);
16171614
if file_path.exists(){
16181615
return file_path;
16191616
}
16201617
// Special directory with objects used only in self-contained linkage mode
16211618
if self_contained{
1622-
let file_path =fs.get_self_contained_lib_path().join(name);
1619+
let file_path =sess.target_tlib_path.dir.join("self-contained").join(name);
16231620
if file_path.exists(){
16241621
return file_path;
16251622
}
16261623
}
1627-
for search_pathinfs.search_paths(){
1624+
for search_pathinsess.target_filesearch(PathKind::Native).search_paths(){
16281625
let file_path = search_path.dir.join(name);
16291626
if file_path.exists(){
16301627
return file_path;
@@ -2131,7 +2128,7 @@ fn add_library_search_dirs(
21312128
|LinkSelfContainedComponents::UNWIND
21322129
|LinkSelfContainedComponents::MINGW,
21332130
){
2134-
let lib_path = sess.target_filesearch(PathKind::Native).get_self_contained_lib_path();
2131+
let lib_path = sess.target_tlib_path.dir.join("self-contained");
21352132
cmd.include_path(&fix_windows_verbatim_for_gcc(&lib_path));
21362133
}
21372134

@@ -2146,8 +2143,7 @@ fn add_library_search_dirs(
21462143
|| sess.target.os =="fuchsia"
21472144
|| sess.target.is_like_osx && !sess.opts.unstable_opts.sanitizer.is_empty()
21482145
{
2149-
let lib_path = sess.target_filesearch(PathKind::Native).get_lib_path();
2150-
cmd.include_path(&fix_windows_verbatim_for_gcc(&lib_path));
2146+
cmd.include_path(&fix_windows_verbatim_for_gcc(&sess.target_tlib_path.dir));
21512147
}
21522148

21532149
// Mac Catalyst uses the macOS SDK, but to link to iOS-specific frameworks
@@ -2859,15 +2855,14 @@ fn add_upstream_native_libraries(
28592855
//
28602856
// The returned path will always have `fix_windows_verbatim_for_gcc()` applied to it.
28612857
fnrehome_sysroot_lib_dir(sess:&Session,lib_dir:&Path) ->PathBuf{
2862-
let sysroot_lib_path = sess.target_filesearch(PathKind::All).get_lib_path();
2858+
let sysroot_lib_path =&sess.target_tlib_path.dir;
28632859
let canonical_sysroot_lib_path =
2864-
{try_canonicalize(&sysroot_lib_path).unwrap_or_else(|_| sysroot_lib_path.clone())};
2860+
{try_canonicalize(sysroot_lib_path).unwrap_or_else(|_| sysroot_lib_path.clone())};
28652861

28662862
let canonical_lib_dir =try_canonicalize(lib_dir).unwrap_or_else(|_| lib_dir.to_path_buf());
28672863
if canonical_lib_dir == canonical_sysroot_lib_path{
2868-
// This path, returned by `target_filesearch().get_lib_path()`, has
2869-
// already had `fix_windows_verbatim_for_gcc()` applied if needed.
2870-
sysroot_lib_path
2864+
// This path already had `fix_windows_verbatim_for_gcc()` applied if needed.
2865+
sysroot_lib_path.clone()
28712866
}else{
28722867
fix_windows_verbatim_for_gcc(lib_dir)
28732868
}

‎compiler/rustc_const_eval/src/interpret/memory.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1014,7 +1014,7 @@ impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> {
10141014
///
10151015
/// We do this so Miri's allocation access tracking does not show the validation
10161016
/// reads as spurious accesses.
1017-
pub(super)fnrun_for_validation<R>(&self,f:implFnOnce() ->R) ->R{
1017+
pubfnrun_for_validation<R>(&self,f:implFnOnce() ->R) ->R{
10181018
// This deliberately uses `==` on `bool` to follow the pattern
10191019
// `assert!(val.replace(new) == old)`.
10201020
assert!(

‎compiler/rustc_interface/src/tests.rs‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -774,6 +774,7 @@ fn test_unstable_options_tracking_hash() {
774774
tracked!(direct_access_external_data,Some(true));
775775
tracked!(dual_proc_macros,true);
776776
tracked!(dwarf_version,Some(5));
777+
tracked!(embed_source,true);
777778
tracked!(emit_thin_lto,false);
778779
tracked!(export_executable_symbols,true);
779780
tracked!(fewer_names,Some(true));

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp