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

Commitdebf88a

Browse files
author
The Miri Cronjob Bot
committed
Merge from rustc
2 parents9ce95c3 +e2ef4e1 commitdebf88a

File tree

381 files changed

+2830
-1407
lines changed

Some content is hidden

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

381 files changed

+2830
-1407
lines changed

‎compiler/rustc_ast/src/tokenstream.rs‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -661,11 +661,11 @@ impl TokenStream {
661661
if attr_style ==AttrStyle::Inner{
662662
vec![
663663
TokenTree::token_joint(token::Pound, span),
664-
TokenTree::token_alone(token::Not, span),
664+
TokenTree::token_joint_hidden(token::Not, span),
665665
body,
666666
]
667667
}else{
668-
vec![TokenTree::token_alone(token::Pound, span), body]
668+
vec![TokenTree::token_joint_hidden(token::Pound, span), body]
669669
}
670670
}
671671
}

‎compiler/rustc_ast_pretty/src/pprust/state.rs‎

Lines changed: 29 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -681,22 +681,40 @@ pub trait PrintState<'a>: std::ops::Deref<Target = pp::Printer> + std::ops::Dere
681681
}
682682
}
683683

684+
// The easiest way to implement token stream pretty printing would be to
685+
// print each token followed by a single space. But that would produce ugly
686+
// output, so we go to some effort to do better.
687+
//
688+
// First, we track whether each token that appears in source code is
689+
// followed by a space, with `Spacing`, and reproduce that in the output.
690+
// This works well in a lot of cases. E.g. `stringify!(x + y)` produces
691+
// "x + y" and `stringify!(x+y)` produces "x+y".
692+
//
693+
// But this doesn't work for code produced by proc macros (which have no
694+
// original source text representation) nor for code produced by decl
695+
// macros (which are tricky because the whitespace after tokens appearing
696+
// in macro rules isn't always what you want in the produced output). For
697+
// these we mostly use `Spacing::Alone`, which is the conservative choice.
698+
//
699+
// So we have a backup mechanism for when `Spacing::Alone` occurs between a
700+
// pair of tokens: we check if that pair of tokens can obviously go
701+
// together without a space between them. E.g. token `x` followed by token
702+
// `,` is better printed as `x,` than `x ,`. (Even if the original source
703+
// code was `x ,`.)
704+
//
705+
// Finally, we must be careful about changing the output. Token pretty
706+
// printing is used by `stringify!` and `impl Display for
707+
// proc_macro::TokenStream`, and some programs rely on the output having a
708+
// particular form, even though they shouldn't. In particular, some proc
709+
// macros do `format!({stream})` on a token stream and then "parse" the
710+
// output with simple string matching that can't handle whitespace changes.
711+
// E.g. we have seen cases where a proc macro can handle `a :: b` but not
712+
// `a::b`. See #117433 for some examples.
684713
fnprint_tts(&mutself,tts:&TokenStream,convert_dollar_crate:bool){
685714
letmut iter = tts.trees().peekable();
686715
whileletSome(tt) = iter.next(){
687716
let spacing =self.print_tt(tt, convert_dollar_crate);
688717
ifletSome(next) = iter.peek(){
689-
// Should we print a space after `tt`? There are two guiding
690-
// factors.
691-
// - `spacing` is the more important and accurate one. Most
692-
// tokens have good spacing information, and
693-
// `Joint`/`JointHidden` get used a lot.
694-
// - `space_between` is the backup. Code produced by proc
695-
// macros has worse spacing information, with no
696-
// `JointHidden` usage and too much `Alone` usage, which
697-
// would result in over-spaced output such as
698-
// `( x () , y . z )`. `space_between` avoids some of the
699-
// excess whitespace.
700718
if spacing ==Spacing::Alone &&space_between(tt, next){
701719
self.space();
702720
}

‎compiler/rustc_builtin_macros/src/assert/context.rs‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ impl<'cx, 'a> Context<'cx, 'a> {
153153
fnbuild_panic(&self,expr_str:&str,panic_path:Path) ->P<Expr>{
154154
let escaped_expr_str =escape_to_fmt(expr_str);
155155
let initial =[
156-
TokenTree::token_joint_hidden(
156+
TokenTree::token_joint(
157157
token::Literal(token::Lit{
158158
kind: token::LitKind::Str,
159159
symbol:Symbol::intern(&ifself.fmt_string.is_empty(){
@@ -172,7 +172,7 @@ impl<'cx, 'a> Context<'cx, 'a> {
172172
];
173173
let captures =self.capture_decls.iter().flat_map(|cap|{
174174
[
175-
TokenTree::token_joint_hidden(
175+
TokenTree::token_joint(
176176
token::Ident(cap.ident.name,IdentIsRaw::No),
177177
cap.ident.span,
178178
),

‎compiler/rustc_builtin_macros/src/deriving/default.rs‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use crate::deriving::generic::*;
33
usecrate::errors;
44
use core::ops::ControlFlow;
55
use rustc_astas ast;
6-
use rustc_ast::visit::walk_list;
6+
use rustc_ast::visit::visit_opt;
77
use rustc_ast::{attr,EnumDef,VariantData};
88
use rustc_expand::base::{Annotatable,DummyResult,ExtCtxt};
99
use rustc_span::symbol::Ident;
@@ -224,7 +224,7 @@ impl<'a, 'b> rustc_ast::visit::Visitor<'a> for DetectNonVariantDefaultAttr<'a, '
224224
self.visit_ident(v.ident);
225225
self.visit_vis(&v.vis);
226226
self.visit_variant_data(&v.data);
227-
walk_list!(self, visit_anon_const,&v.disr_expr);
227+
visit_opt!(self, visit_anon_const,&v.disr_expr);
228228
for attrin&v.attrs{
229229
rustc_ast::visit::walk_attribute(self, attr);
230230
}

‎compiler/rustc_codegen_cranelift/src/driver/aot.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ fn produce_final_output_artifacts(
200200
// to get rid of it.
201201
for output_typein crate_output.outputs.keys(){
202202
match*output_type{
203-
OutputType::Bitcode =>{
203+
OutputType::Bitcode|OutputType::ThinLinkBitcode=>{
204204
// Cranelift doesn't have bitcode
205205
// user_wants_bitcode = true;
206206
// // Copy to .bc, but always keep the .0.bc. There is a later

‎compiler/rustc_codegen_gcc/src/lib.rs‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -335,6 +335,10 @@ impl ThinBufferMethods for ThinBuffer {
335335
fndata(&self) ->&[u8]{
336336
unimplemented!();
337337
}
338+
339+
fnthin_link_data(&self) ->&[u8]{
340+
unimplemented!();
341+
}
338342
}
339343

340344
pubstructGccContext{
@@ -414,7 +418,7 @@ impl WriteBackendMethods for GccCodegenBackend {
414418
back::write::codegen(cgcx, dcx, module, config)
415419
}
416420

417-
fnprepare_thin(_module:ModuleCodegen<Self::Module>) ->(String,Self::ThinBuffer){
421+
fnprepare_thin(_module:ModuleCodegen<Self::Module>,_emit_summary:bool) ->(String,Self::ThinBuffer){
418422
unimplemented!();
419423
}
420424

‎compiler/rustc_codegen_llvm/src/asm.rs‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ use rustc_middle::{bug, span_bug, ty::Instance};
1616
use rustc_span::{Pos,Span};
1717
use rustc_target::abi::*;
1818
use rustc_target::asm::*;
19+
use tracing::debug;
1920

2021
use libc::{c_char, c_uint};
2122
use smallvec::SmallVec;

‎compiler/rustc_codegen_llvm/src/back/archive.rs‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ use rustc_codegen_ssa::back::archive::{
1818
get_native_object_symbols, try_extract_macho_fat_archive,ArArchiveBuilder,
1919
ArchiveBuildFailure,ArchiveBuilder,ArchiveBuilderBuilder,UnknownArchiveKind,
2020
};
21+
use tracing::trace;
2122

2223
use rustc_session::cstore::DllImport;
2324
use rustc_session::Session;

‎compiler/rustc_codegen_llvm/src/back/lto.rs‎

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ use rustc_middle::bug;
2020
use rustc_middle::dep_graph::WorkProduct;
2121
use rustc_middle::middle::exported_symbols::{SymbolExportInfo,SymbolExportLevel};
2222
use rustc_session::config::{self,CrateType,Lto};
23+
use tracing::{debug, info};
2324

2425
use std::collections::BTreeMap;
2526
use std::ffi::{CStr,CString};
@@ -229,9 +230,12 @@ pub(crate) fn run_thin(
229230
thin_lto(cgcx,&dcx, modules, upstream_modules, cached_modules,&symbols_below_threshold)
230231
}
231232

232-
pub(crate)fnprepare_thin(module:ModuleCodegen<ModuleLlvm>) ->(String,ThinBuffer){
233+
pub(crate)fnprepare_thin(
234+
module:ModuleCodegen<ModuleLlvm>,
235+
emit_summary:bool,
236+
) ->(String,ThinBuffer){
233237
let name = module.name;
234-
let buffer =ThinBuffer::new(module.module_llvm.llmod(),true);
238+
let buffer =ThinBuffer::new(module.module_llvm.llmod(),true, emit_summary);
235239
(name, buffer)
236240
}
237241

@@ -671,9 +675,9 @@ unsafe impl Send for ThinBuffer {}
671675
unsafeimplSyncforThinBuffer{}
672676

673677
implThinBuffer{
674-
pubfnnew(m:&llvm::Module,is_thin:bool) ->ThinBuffer{
678+
pubfnnew(m:&llvm::Module,is_thin:bool,emit_summary:bool) ->ThinBuffer{
675679
unsafe{
676-
let buffer = llvm::LLVMRustThinLTOBufferCreate(m, is_thin);
680+
let buffer = llvm::LLVMRustThinLTOBufferCreate(m, is_thin, emit_summary);
677681
ThinBuffer(buffer)
678682
}
679683
}
@@ -687,6 +691,14 @@ impl ThinBufferMethods for ThinBuffer {
687691
slice::from_raw_parts(ptr, len)
688692
}
689693
}
694+
695+
fnthin_link_data(&self) ->&[u8]{
696+
unsafe{
697+
let ptr = llvm::LLVMRustThinLTOBufferThinLinkDataPtr(self.0)as*const_;
698+
let len = llvm::LLVMRustThinLTOBufferThinLinkDataLen(self.0);
699+
slice::from_raw_parts(ptr, len)
700+
}
701+
}
690702
}
691703

692704
implDropforThinBuffer{

‎compiler/rustc_codegen_llvm/src/back/write.rs‎

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ use rustc_session::Session;
3535
use rustc_span::symbol::sym;
3636
use rustc_span::InnerSpan;
3737
use rustc_target::spec::{CodeModel,RelocModel,SanitizerSet,SplitDebuginfo,TlsModel};
38+
use tracing::debug;
3839

3940
usecrate::llvm::diagnostic::OptimizationDiagnosticKind;
4041
use libc::{c_char, c_int, c_void, size_t};
@@ -708,13 +709,15 @@ pub(crate) unsafe fn codegen(
708709
// asm from LLVM and use `gcc` to create the object file.
709710

710711
let bc_out = cgcx.output_filenames.temp_path(OutputType::Bitcode, module_name);
712+
let bc_summary_out =
713+
cgcx.output_filenames.temp_path(OutputType::ThinLinkBitcode, module_name);
711714
let obj_out = cgcx.output_filenames.temp_path(OutputType::Object, module_name);
712715

713716
if config.bitcode_needed(){
714717
let _timer = cgcx
715718
.prof
716719
.generic_activity_with_arg("LLVM_module_codegen_make_bitcode",&*module.name);
717-
let thin =ThinBuffer::new(llmod, config.emit_thin_lto);
720+
let thin =ThinBuffer::new(llmod, config.emit_thin_lto, config.emit_thin_lto_summary);
718721
let data = thin.data();
719722

720723
ifletSome(bitcode_filename) = bc_out.file_name(){
@@ -725,6 +728,25 @@ pub(crate) unsafe fn codegen(
725728
);
726729
}
727730

731+
if config.emit_thin_lto_summary
732+
&&letSome(thin_link_bitcode_filename) = bc_summary_out.file_name()
733+
{
734+
let summary_data = thin.thin_link_data();
735+
cgcx.prof.artifact_size(
736+
"llvm_bitcode_summary",
737+
thin_link_bitcode_filename.to_string_lossy(),
738+
summary_data.len()asu64,
739+
);
740+
741+
let _timer = cgcx.prof.generic_activity_with_arg(
742+
"LLVM_module_codegen_emit_bitcode_summary",
743+
&*module.name,
744+
);
745+
ifletErr(err) = fs::write(&bc_summary_out, summary_data){
746+
dcx.emit_err(WriteBytecode{path:&bc_summary_out, err});
747+
}
748+
}
749+
728750
if config.emit_bc || config.emit_obj ==EmitObj::Bitcode{
729751
let _timer = cgcx
730752
.prof

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp