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

Commit4b2a005

Browse files
committed
Auto merge ofrust-lang#127056 - matthiaskrgr:rollup-9cyvjqp, r=matthiaskrgr
Rollup of 9 pull requestsSuccessful merges: -rust-lang#123237 (Various rustc_codegen_ssa cleanups) -rust-lang#123714 (Add test for fn pointer duplication.) -rust-lang#124091 (Update AST validation module docs) -rust-lang#126835 (Simplifications in match lowering) -rust-lang#126963 (Add basic Serde serialization capabilities to Stable MIR) -rust-lang#127010 (Update browser-ui-test version to `0.18.0`) -rust-lang#127015 (Switch back `non_local_definitions` lint to allow-by-default) -rust-lang#127029 (Fix Markdown tables in platform-support.md) -rust-lang#127032 (Enable const casting for `f16` and `f128`)r? `@ghost``@rustbot` modify labels: rollup
2 parents9c3bc80 +11cff7d commit4b2a005

File tree

67 files changed

+942
-790
lines changed

Some content is hidden

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

67 files changed

+942
-790
lines changed

‎Cargo.lock‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5261,6 +5261,7 @@ name = "stable_mir"
52615261
version ="0.1.0-preview"
52625262
dependencies = [
52635263
"scoped-tls",
5264+
"serde",
52645265
]
52655266

52665267
[[package]]

‎compiler/rustc_ast_passes/src/ast_validation.rs‎

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,20 @@
1-
// Validate AST before lowering it to HIR.
2-
//
3-
// This pass is supposed to catch things that fit into AST data structures,
4-
// but not permitted by the language. It runs after expansion when AST is frozen,
5-
// so it can check for erroneous constructions produced by syntax extensions.
6-
// This pass is supposed to perform only simple checks not requiring name resolution
7-
// or type checking or some other kind of complex analysis.
1+
//! Validate AST before lowering it to HIR.
2+
//!
3+
//! This pass intends to check that the constructed AST is *syntactically valid* to allow the rest
4+
//! of the compiler to assume that the AST is valid. These checks cannot be performed during parsing
5+
//! because attribute macros are allowed to accept certain pieces of invalid syntax such as a
6+
//! function without body outside of a trait definition:
7+
//!
8+
//! ```ignore (illustrative)
9+
//! #[my_attribute]
10+
//! mod foo {
11+
//! fn missing_body();
12+
//! }
13+
//! ```
14+
//!
15+
//! These checks are run post-expansion, after AST is frozen, to be able to check for erroneous
16+
//! constructions produced by proc macros. This pass is only intended for simple checks that do not
17+
//! require name resolution or type checking, or other kinds of complex analysis.
818
919
use itertools::{Either,Itertools};
1020
use rustc_ast::ptr::P;

‎compiler/rustc_codegen_gcc/src/common.rs‎

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,19 @@ impl<'gcc, 'tcx> CodegenCx<'gcc, 'tcx> {
2828
global
2929
// TODO(antoyo): set linkage.
3030
}
31+
32+
pubfnconst_bitcast(&self,value:RValue<'gcc>,typ:Type<'gcc>) ->RValue<'gcc>{
33+
if value.get_type() ==self.bool_type.make_pointer(){
34+
ifletSome(pointee) = typ.get_pointee(){
35+
if pointee.dyncast_vector().is_some(){
36+
panic!()
37+
}
38+
}
39+
}
40+
// NOTE: since bitcast makes a value non-constant, don't bitcast if not necessary as some
41+
// SIMD builtins require a constant value.
42+
self.bitcast_if_needed(value, typ)
43+
}
3144
}
3245

3346
pubfnbytes_in_context<'gcc,'tcx>(cx:&CodegenCx<'gcc,'tcx>,bytes:&[u8]) ->RValue<'gcc>{
@@ -239,19 +252,6 @@ impl<'gcc, 'tcx> ConstMethods<'tcx> for CodegenCx<'gcc, 'tcx> {
239252
const_alloc_to_gcc(self, alloc)
240253
}
241254

242-
fnconst_bitcast(&self,value:RValue<'gcc>,typ:Type<'gcc>) ->RValue<'gcc>{
243-
if value.get_type() ==self.bool_type.make_pointer(){
244-
ifletSome(pointee) = typ.get_pointee(){
245-
if pointee.dyncast_vector().is_some(){
246-
panic!()
247-
}
248-
}
249-
}
250-
// NOTE: since bitcast makes a value non-constant, don't bitcast if not necessary as some
251-
// SIMD builtins require a constant value.
252-
self.bitcast_if_needed(value, typ)
253-
}
254-
255255
fnconst_ptr_byte_offset(&self,base_addr:Self::Value,offset: abi::Size) ->Self::Value{
256256
self.context
257257
.new_array_access(None, base_addr,self.const_usize(offset.bytes()))

‎compiler/rustc_codegen_gcc/src/context.rs‎

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ use crate::callee::get_fn;
2727
usecrate::common::SignType;
2828

2929
pubstructCodegenCx<'gcc,'tcx>{
30-
pubcheck_overflow:bool,
3130
pubcodegen_unit:&'tcxCodegenUnit<'tcx>,
3231
pubcontext:&'gccContext<'gcc>,
3332

@@ -134,8 +133,6 @@ impl<'gcc, 'tcx> CodegenCx<'gcc, 'tcx> {
134133
tcx:TyCtxt<'tcx>,
135134
supports_128bit_integers:bool,
136135
) ->Self{
137-
let check_overflow = tcx.sess.overflow_checks();
138-
139136
let create_type = |ctype, rust_type|{
140137
let layout = tcx.layout_of(ParamEnv::reveal_all().and(rust_type)).unwrap();
141138
let align = layout.align.abi.bytes();
@@ -271,7 +268,6 @@ impl<'gcc, 'tcx> CodegenCx<'gcc, 'tcx> {
271268
}
272269

273270
letmut cx =Self{
274-
check_overflow,
275271
codegen_unit,
276272
context,
277273
current_func:RefCell::new(None),
@@ -511,10 +507,6 @@ impl<'gcc, 'tcx> MiscMethods<'tcx> for CodegenCx<'gcc, 'tcx> {
511507
&self.tcx.sess
512508
}
513509

514-
fncheck_overflow(&self) ->bool{
515-
self.check_overflow
516-
}
517-
518510
fncodegen_unit(&self) ->&'tcxCodegenUnit<'tcx>{
519511
self.codegen_unit
520512
}

‎compiler/rustc_codegen_gcc/src/type_.rs‎

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -89,13 +89,34 @@ impl<'gcc, 'tcx> CodegenCx<'gcc, 'tcx> {
8989
ty::FloatTy::F128 =>self.type_f128(),
9090
}
9191
}
92-
}
9392

94-
impl<'gcc,'tcx>BaseTypeMethods<'tcx>forCodegenCx<'gcc,'tcx>{
95-
fntype_i1(&self) ->Type<'gcc>{
93+
pubfntype_i1(&self) ->Type<'gcc>{
9694
self.bool_type
9795
}
9896

97+
pubfntype_struct(&self,fields:&[Type<'gcc>],packed:bool) ->Type<'gcc>{
98+
let types = fields.to_vec();
99+
ifletSome(typ) =self.struct_types.borrow().get(fields){
100+
return*typ;
101+
}
102+
let fields:Vec<_> = fields
103+
.iter()
104+
.enumerate()
105+
.map(|(index, field)|{
106+
self.context.new_field(None,*field,format!("field{}_TODO", index))
107+
})
108+
.collect();
109+
let typ =self.context.new_struct_type(None,"struct",&fields).as_type();
110+
if packed{
111+
#[cfg(feature ="master")]
112+
typ.set_packed();
113+
}
114+
self.struct_types.borrow_mut().insert(types, typ);
115+
typ
116+
}
117+
}
118+
119+
impl<'gcc,'tcx>BaseTypeMethods<'tcx>forCodegenCx<'gcc,'tcx>{
99120
fntype_i8(&self) ->Type<'gcc>{
100121
self.i8_type
101122
}
@@ -131,7 +152,7 @@ impl<'gcc, 'tcx> BaseTypeMethods<'tcx> for CodegenCx<'gcc, 'tcx> {
131152
fntype_f64(&self) ->Type<'gcc>{
132153
self.double_type
133154
}
134-
155+
135156
fntype_f128(&self) ->Type<'gcc>{
136157
unimplemented!("f16_f128")
137158
}
@@ -140,27 +161,6 @@ impl<'gcc, 'tcx> BaseTypeMethods<'tcx> for CodegenCx<'gcc, 'tcx> {
140161
self.context.new_function_pointer_type(None, return_type, params,false)
141162
}
142163

143-
fntype_struct(&self,fields:&[Type<'gcc>],packed:bool) ->Type<'gcc>{
144-
let types = fields.to_vec();
145-
ifletSome(typ) =self.struct_types.borrow().get(fields){
146-
return*typ;
147-
}
148-
let fields:Vec<_> = fields
149-
.iter()
150-
.enumerate()
151-
.map(|(index, field)|{
152-
self.context.new_field(None,*field,format!("field{}_TODO", index))
153-
})
154-
.collect();
155-
let typ =self.context.new_struct_type(None,"struct",&fields).as_type();
156-
if packed{
157-
#[cfg(feature ="master")]
158-
typ.set_packed();
159-
}
160-
self.struct_types.borrow_mut().insert(types, typ);
161-
typ
162-
}
163-
164164
fntype_kind(&self,typ:Type<'gcc>) ->TypeKind{
165165
ifself.is_int_type_or_bool(typ){
166166
TypeKind::Integer

‎compiler/rustc_codegen_llvm/src/common.rs‎

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -329,10 +329,6 @@ impl<'ll, 'tcx> ConstMethods<'tcx> for CodegenCx<'ll, 'tcx> {
329329
const_alloc_to_llvm(self, alloc,/*static*/false)
330330
}
331331

332-
fnconst_bitcast(&self,val:&'llValue,ty:&'llType) ->&'llValue{
333-
self.const_bitcast(val, ty)
334-
}
335-
336332
fnconst_ptr_byte_offset(&self,base_addr:Self::Value,offset: abi::Size) ->Self::Value{
337333
unsafe{
338334
llvm::LLVMConstInBoundsGEP2(

‎compiler/rustc_codegen_llvm/src/context.rs‎

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ use crate::back::write::to_llvm_code_model;
33
usecrate::callee::get_fn;
44
usecrate::coverageinfo;
55
usecrate::debuginfo;
6+
usecrate::debuginfo::metadata::apply_vcall_visibility_metadata;
67
usecrate::llvm;
78
usecrate::llvm_util;
89
usecrate::type_::Type;
@@ -43,7 +44,6 @@ use std::str;
4344
/// All other LLVM data structures in the `CodegenCx` are tied to that `llvm::Context`.
4445
pubstructCodegenCx<'ll,'tcx>{
4546
pubtcx:TyCtxt<'tcx>,
46-
pubcheck_overflow:bool,
4747
pubuse_dll_storage_attrs:bool,
4848
pubtls_model: llvm::ThreadLocalMode,
4949

@@ -441,8 +441,6 @@ impl<'ll, 'tcx> CodegenCx<'ll, 'tcx> {
441441
// start) and then strongly recommending static linkage on Windows!
442442
let use_dll_storage_attrs = tcx.sess.target.is_like_windows;
443443

444-
let check_overflow = tcx.sess.overflow_checks();
445-
446444
let tls_model =to_llvm_tls_model(tcx.sess.tls_model());
447445

448446
let(llcx, llmod) =(&*llvm_module.llcx, llvm_module.llmod());
@@ -466,7 +464,6 @@ impl<'ll, 'tcx> CodegenCx<'ll, 'tcx> {
466464

467465
CodegenCx{
468466
tcx,
469-
check_overflow,
470467
use_dll_storage_attrs,
471468
tls_model,
472469
llmod,
@@ -522,6 +519,15 @@ impl<'ll, 'tcx> MiscMethods<'tcx> for CodegenCx<'ll, 'tcx> {
522519
&self.vtables
523520
}
524521

522+
fnapply_vcall_visibility_metadata(
523+
&self,
524+
ty:Ty<'tcx>,
525+
poly_trait_ref:Option<ty::PolyExistentialTraitRef<'tcx>>,
526+
vtable:&'llValue,
527+
){
528+
apply_vcall_visibility_metadata(self, ty, poly_trait_ref, vtable);
529+
}
530+
525531
fnget_fn(&self,instance:Instance<'tcx>) ->&'llValue{
526532
get_fn(self, instance)
527533
}
@@ -596,10 +602,6 @@ impl<'ll, 'tcx> MiscMethods<'tcx> for CodegenCx<'ll, 'tcx> {
596602
self.tcx.sess
597603
}
598604

599-
fncheck_overflow(&self) ->bool{
600-
self.check_overflow
601-
}
602-
603605
fncodegen_unit(&self) ->&'tcxCodegenUnit<'tcx>{
604606
self.codegen_unit
605607
}

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

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1449,12 +1449,18 @@ fn build_vtable_type_di_node<'ll, 'tcx>(
14491449
.di_node
14501450
}
14511451

1452-
fnvcall_visibility_metadata<'ll,'tcx>(
1452+
pub(crate)fnapply_vcall_visibility_metadata<'ll,'tcx>(
14531453
cx:&CodegenCx<'ll,'tcx>,
14541454
ty:Ty<'tcx>,
14551455
trait_ref:Option<PolyExistentialTraitRef<'tcx>>,
14561456
vtable:&'llValue,
14571457
){
1458+
// FIXME(flip1995): The virtual function elimination optimization only works with full LTO in
1459+
// LLVM at the moment.
1460+
if !cx.sess().opts.unstable_opts.virtual_function_elimination || cx.sess().lto() !=Lto::Fat{
1461+
return;
1462+
}
1463+
14581464
enumVCallVisibility{
14591465
Public =0,
14601466
LinkageUnit =1,
@@ -1531,12 +1537,6 @@ pub fn create_vtable_di_node<'ll, 'tcx>(
15311537
poly_trait_ref:Option<ty::PolyExistentialTraitRef<'tcx>>,
15321538
vtable:&'llValue,
15331539
){
1534-
// FIXME(flip1995): The virtual function elimination optimization only works with full LTO in
1535-
// LLVM at the moment.
1536-
if cx.sess().opts.unstable_opts.virtual_function_elimination && cx.sess().lto() ==Lto::Fat{
1537-
vcall_visibility_metadata(cx, ty, poly_trait_ref, vtable);
1538-
}
1539-
15401540
if cx.dbg_cx.is_none(){
15411541
return;
15421542
}

‎compiler/rustc_codegen_llvm/src/lib.rs‎

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -274,10 +274,11 @@ impl CodegenBackend for LlvmCodegenBackend {
274274
|tcx,()| llvm_util::global_llvm_features(tcx.sess,true)
275275
}
276276

277-
fnprint(&self,req:&PrintRequest,out:&mutdynPrintBackendInfo,sess:&Session){
277+
fnprint(&self,req:&PrintRequest,out:&mutString,sess:&Session){
278+
use std::fmt::Write;
278279
match req.kind{
279280
PrintKind::RelocationModels =>{
280-
writeln!(out,"Available relocation models:");
281+
writeln!(out,"Available relocation models:").unwrap();
281282
for namein&[
282283
"static",
283284
"pic",
@@ -288,25 +289,25 @@ impl CodegenBackend for LlvmCodegenBackend {
288289
"ropi-rwpi",
289290
"default",
290291
]{
291-
writeln!(out," {name}");
292+
writeln!(out," {name}").unwrap();
292293
}
293-
writeln!(out);
294+
writeln!(out).unwrap();
294295
}
295296
PrintKind::CodeModels =>{
296-
writeln!(out,"Available code models:");
297+
writeln!(out,"Available code models:").unwrap();
297298
for namein&["tiny","small","kernel","medium","large"]{
298-
writeln!(out," {name}");
299+
writeln!(out," {name}").unwrap();
299300
}
300-
writeln!(out);
301+
writeln!(out).unwrap();
301302
}
302303
PrintKind::TlsModels =>{
303-
writeln!(out,"Available TLS models:");
304+
writeln!(out,"Available TLS models:").unwrap();
304305
for namein
305306
&["global-dynamic","local-dynamic","initial-exec","local-exec","emulated"]
306307
{
307-
writeln!(out," {name}");
308+
writeln!(out," {name}").unwrap();
308309
}
309-
writeln!(out);
310+
writeln!(out).unwrap();
310311
}
311312
PrintKind::StackProtectorStrategies =>{
312313
writeln!(
@@ -332,7 +333,8 @@ impl CodegenBackend for LlvmCodegenBackend {
332333
none
333334
Do not generate stack canaries.
334335
"#
335-
);
336+
)
337+
.unwrap();
336338
}
337339
_other => llvm_util::print(req, out, sess),
338340
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp