Skip to content

Commit c2901f5

Browse files
committed
Auto merge of rust-lang#122511 - matthiaskrgr:rollup-swzilin, r=matthiaskrgr
Rollup of 10 pull requests Successful merges: - rust-lang#117118 ([AIX] Remove AixLinker's debuginfo() implementation) - rust-lang#121650 (change std::process to drop supplementary groups based on CAP_SETGID) - rust-lang#121764 (Make incremental sessions identity no longer depend on the crate names provided by source code) - rust-lang#122212 (Copy byval argument to alloca if alignment is insufficient) - rust-lang#122322 (coverage: Initial support for branch coverage instrumentation) - rust-lang#122373 (Fix the conflict problem between the diagnostics fixes of lint `unnecessary_qualification` and `unused_imports`) - rust-lang#122479 (Implement `Duration::as_millis_{f64,f32}`) - rust-lang#122487 (Rename `StmtKind::Local` variant into `StmtKind::Let`) - rust-lang#122498 (Update version of cc crate) - rust-lang#122503 (Make `SubdiagMessageOp` well-formed) r? `@ghost` `@rustbot` modify labels: rollup
2 parents f4b771b + 6ce3110 commit c2901f5

File tree

143 files changed

+2023
-393
lines changed

Some content is hidden

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

143 files changed

+2023
-393
lines changed

compiler/rustc_ast/src/ast.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1021,7 +1021,7 @@ impl Stmt {
10211021
#[derive(Clone, Encodable, Decodable, Debug)]
10221022
pub enum StmtKind {
10231023
/// A local (let) binding.
1024-
Local(P<Local>),
1024+
Let(P<Local>),
10251025
/// An item definition.
10261026
Item(P<Item>),
10271027
/// Expr without trailing semi-colon.

compiler/rustc_ast/src/ast_traits.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ impl<T: HasTokens> HasTokens for Option<T> {
182182
impl HasTokens for StmtKind {
183183
fn tokens(&self) -> Option<&LazyAttrTokenStream> {
184184
match self {
185-
StmtKind::Local(local) => local.tokens.as_ref(),
185+
StmtKind::Let(local) => local.tokens.as_ref(),
186186
StmtKind::Item(item) => item.tokens(),
187187
StmtKind::Expr(expr) | StmtKind::Semi(expr) => expr.tokens(),
188188
StmtKind::Empty => return None,
@@ -191,7 +191,7 @@ impl HasTokens for StmtKind {
191191
}
192192
fn tokens_mut(&mut self) -> Option<&mut Option<LazyAttrTokenStream>> {
193193
match self {
194-
StmtKind::Local(local) => Some(&mut local.tokens),
194+
StmtKind::Let(local) => Some(&mut local.tokens),
195195
StmtKind::Item(item) => item.tokens_mut(),
196196
StmtKind::Expr(expr) | StmtKind::Semi(expr) => expr.tokens_mut(),
197197
StmtKind::Empty => return None,
@@ -355,7 +355,7 @@ impl HasAttrs for StmtKind {
355355

356356
fn attrs(&self) -> &[Attribute] {
357357
match self {
358-
StmtKind::Local(local) => &local.attrs,
358+
StmtKind::Let(local) => &local.attrs,
359359
StmtKind::Expr(expr) | StmtKind::Semi(expr) => expr.attrs(),
360360
StmtKind::Item(item) => item.attrs(),
361361
StmtKind::Empty => &[],
@@ -365,7 +365,7 @@ impl HasAttrs for StmtKind {
365365

366366
fn visit_attrs(&mut self, f: impl FnOnce(&mut AttrVec)) {
367367
match self {
368-
StmtKind::Local(local) => f(&mut local.attrs),
368+
StmtKind::Let(local) => f(&mut local.attrs),
369369
StmtKind::Expr(expr) | StmtKind::Semi(expr) => expr.visit_attrs(f),
370370
StmtKind::Item(item) => item.visit_attrs(f),
371371
StmtKind::Empty => {}

compiler/rustc_ast/src/mut_visit.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1567,7 +1567,7 @@ pub fn noop_flat_map_stmt_kind<T: MutVisitor>(
15671567
vis: &mut T,
15681568
) -> SmallVec<[StmtKind; 1]> {
15691569
match kind {
1570-
StmtKind::Local(mut local) => smallvec![StmtKind::Local({
1570+
StmtKind::Let(mut local) => smallvec![StmtKind::Let({
15711571
vis.visit_local(&mut local);
15721572
local
15731573
})],

compiler/rustc_ast/src/visit.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -787,7 +787,7 @@ pub fn walk_block<'a, V: Visitor<'a>>(visitor: &mut V, block: &'a Block) -> V::R
787787

788788
pub fn walk_stmt<'a, V: Visitor<'a>>(visitor: &mut V, statement: &'a Stmt) -> V::Result {
789789
match &statement.kind {
790-
StmtKind::Local(local) => try_visit!(visitor.visit_local(local)),
790+
StmtKind::Let(local) => try_visit!(visitor.visit_local(local)),
791791
StmtKind::Item(item) => try_visit!(visitor.visit_item(item)),
792792
StmtKind::Expr(expr) | StmtKind::Semi(expr) => try_visit!(visitor.visit_expr(expr)),
793793
StmtKind::Empty => {}

compiler/rustc_ast_lowering/src/block.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,11 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
3232
let mut expr = None;
3333
while let [s, tail @ ..] = ast_stmts {
3434
match &s.kind {
35-
StmtKind::Local(local) => {
35+
StmtKind::Let(local) => {
3636
let hir_id = self.lower_node_id(s.id);
3737
let local = self.lower_local(local);
3838
self.alias_attrs(hir_id, local.hir_id);
39-
let kind = hir::StmtKind::Local(local);
39+
let kind = hir::StmtKind::Let(local);
4040
let span = self.lower_span(s.span);
4141
stmts.push(hir::Stmt { hir_id, kind, span });
4242
}

compiler/rustc_ast_lowering/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2356,7 +2356,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
23562356
span: self.lower_span(span),
23572357
ty: None,
23582358
};
2359-
self.stmt(span, hir::StmtKind::Local(self.arena.alloc(local)))
2359+
self.stmt(span, hir::StmtKind::Let(self.arena.alloc(local)))
23602360
}
23612361

23622362
fn block_expr(&mut self, expr: &'hir hir::Expr<'hir>) -> &'hir hir::Block<'hir> {

compiler/rustc_ast_pretty/src/pprust/state.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1212,7 +1212,7 @@ impl<'a> State<'a> {
12121212
fn print_stmt(&mut self, st: &ast::Stmt) {
12131213
self.maybe_print_comment(st.span.lo());
12141214
match &st.kind {
1215-
ast::StmtKind::Local(loc) => {
1215+
ast::StmtKind::Let(loc) => {
12161216
self.print_outer_attributes(&loc.attrs);
12171217
self.space_if_not_bol();
12181218
self.ibox(INDENT_UNIT);

compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -616,7 +616,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
616616

617617
// FIXME: We make sure that this is a normal top-level binding,
618618
// but we could suggest `todo!()` for all uninitalized bindings in the pattern pattern
619-
if let hir::StmtKind::Local(hir::Local { span, ty, init: None, pat, .. }) =
619+
if let hir::StmtKind::Let(hir::Local { span, ty, init: None, pat, .. }) =
620620
&ex.kind
621621
&& let hir::PatKind::Binding(..) = pat.kind
622622
&& span.contains(self.decl_span)

compiler/rustc_borrowck/src/diagnostics/mutability_errors.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -558,7 +558,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
558558
hir::intravisit::walk_stmt(self, stmt);
559559
let expr = match stmt.kind {
560560
hir::StmtKind::Semi(expr) | hir::StmtKind::Expr(expr) => expr,
561-
hir::StmtKind::Local(hir::Local { init: Some(expr), .. }) => expr,
561+
hir::StmtKind::Let(hir::Local { init: Some(expr), .. }) => expr,
562562
_ => {
563563
return;
564564
}
@@ -1305,7 +1305,7 @@ struct BindingFinder {
13051305
impl<'tcx> Visitor<'tcx> for BindingFinder {
13061306
type Result = ControlFlow<hir::HirId>;
13071307
fn visit_stmt(&mut self, s: &'tcx hir::Stmt<'tcx>) -> Self::Result {
1308-
if let hir::StmtKind::Local(local) = s.kind
1308+
if let hir::StmtKind::Let(local) = s.kind
13091309
&& local.pat.span == self.span
13101310
{
13111311
ControlFlow::Break(local.hir_id)

compiler/rustc_codegen_llvm/src/abi.rs

+55-49
Original file line numberDiff line numberDiff line change
@@ -203,57 +203,63 @@ impl<'ll, 'tcx> ArgAbiExt<'ll, 'tcx> for ArgAbi<'tcx, Ty<'tcx>> {
203203
val: &'ll Value,
204204
dst: PlaceRef<'tcx, &'ll Value>,
205205
) {
206-
if self.is_ignore() {
207-
return;
208-
}
209-
if self.is_sized_indirect() {
210-
OperandValue::Ref(val, None, self.layout.align.abi).store(bx, dst)
211-
} else if self.is_unsized_indirect() {
212-
bug!("unsized `ArgAbi` must be handled through `store_fn_arg`");
213-
} else if let PassMode::Cast { cast, pad_i32: _ } = &self.mode {
214-
// FIXME(eddyb): Figure out when the simpler Store is safe, clang
215-
// uses it for i16 -> {i8, i8}, but not for i24 -> {i8, i8, i8}.
216-
let can_store_through_cast_ptr = false;
217-
if can_store_through_cast_ptr {
218-
bx.store(val, dst.llval, self.layout.align.abi);
219-
} else {
220-
// The actual return type is a struct, but the ABI
221-
// adaptation code has cast it into some scalar type. The
222-
// code that follows is the only reliable way I have
223-
// found to do a transform like i64 -> {i32,i32}.
224-
// Basically we dump the data onto the stack then memcpy it.
225-
//
226-
// Other approaches I tried:
227-
// - Casting rust ret pointer to the foreign type and using Store
228-
// is (a) unsafe if size of foreign type > size of rust type and
229-
// (b) runs afoul of strict aliasing rules, yielding invalid
230-
// assembly under -O (specifically, the store gets removed).
231-
// - Truncating foreign type to correct integral type and then
232-
// bitcasting to the struct type yields invalid cast errors.
233-
234-
// We instead thus allocate some scratch space...
235-
let scratch_size = cast.size(bx);
236-
let scratch_align = cast.align(bx);
237-
let llscratch = bx.alloca(cast.llvm_type(bx), scratch_align);
238-
bx.lifetime_start(llscratch, scratch_size);
239-
240-
// ... where we first store the value...
241-
bx.store(val, llscratch, scratch_align);
242-
243-
// ... and then memcpy it to the intended destination.
244-
bx.memcpy(
245-
dst.llval,
246-
self.layout.align.abi,
247-
llscratch,
248-
scratch_align,
249-
bx.const_usize(self.layout.size.bytes()),
250-
MemFlags::empty(),
251-
);
206+
match &self.mode {
207+
PassMode::Ignore => {}
208+
// Sized indirect arguments
209+
PassMode::Indirect { attrs, meta_attrs: None, on_stack: _ } => {
210+
let align = attrs.pointee_align.unwrap_or(self.layout.align.abi);
211+
OperandValue::Ref(val, None, align).store(bx, dst);
212+
}
213+
// Unsized indirect qrguments
214+
PassMode::Indirect { attrs: _, meta_attrs: Some(_), on_stack: _ } => {
215+
bug!("unsized `ArgAbi` must be handled through `store_fn_arg`");
216+
}
217+
PassMode::Cast { cast, pad_i32: _ } => {
218+
// FIXME(eddyb): Figure out when the simpler Store is safe, clang
219+
// uses it for i16 -> {i8, i8}, but not for i24 -> {i8, i8, i8}.
220+
let can_store_through_cast_ptr = false;
221+
if can_store_through_cast_ptr {
222+
bx.store(val, dst.llval, self.layout.align.abi);
223+
} else {
224+
// The actual return type is a struct, but the ABI
225+
// adaptation code has cast it into some scalar type. The
226+
// code that follows is the only reliable way I have
227+
// found to do a transform like i64 -> {i32,i32}.
228+
// Basically we dump the data onto the stack then memcpy it.
229+
//
230+
// Other approaches I tried:
231+
// - Casting rust ret pointer to the foreign type and using Store
232+
// is (a) unsafe if size of foreign type > size of rust type and
233+
// (b) runs afoul of strict aliasing rules, yielding invalid
234+
// assembly under -O (specifically, the store gets removed).
235+
// - Truncating foreign type to correct integral type and then
236+
// bitcasting to the struct type yields invalid cast errors.
237+
238+
// We instead thus allocate some scratch space...
239+
let scratch_size = cast.size(bx);
240+
let scratch_align = cast.align(bx);
241+
let llscratch = bx.alloca(cast.llvm_type(bx), scratch_align);
242+
bx.lifetime_start(llscratch, scratch_size);
243+
244+
// ... where we first store the value...
245+
bx.store(val, llscratch, scratch_align);
246+
247+
// ... and then memcpy it to the intended destination.
248+
bx.memcpy(
249+
dst.llval,
250+
self.layout.align.abi,
251+
llscratch,
252+
scratch_align,
253+
bx.const_usize(self.layout.size.bytes()),
254+
MemFlags::empty(),
255+
);
252256

253-
bx.lifetime_end(llscratch, scratch_size);
257+
bx.lifetime_end(llscratch, scratch_size);
258+
}
259+
}
260+
_ => {
261+
OperandRef::from_immediate_or_packed_pair(bx, val, self.layout).val.store(bx, dst);
254262
}
255-
} else {
256-
OperandRef::from_immediate_or_packed_pair(bx, val, self.layout).val.store(bx, dst);
257263
}
258264
}
259265

compiler/rustc_codegen_llvm/src/coverageinfo/ffi.rs

+9-3
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,15 @@ impl CounterMappingRegion {
164164
end_line,
165165
end_col,
166166
),
167+
MappingKind::Branch { true_term, false_term } => Self::branch_region(
168+
Counter::from_term(true_term),
169+
Counter::from_term(false_term),
170+
local_file_id,
171+
start_line,
172+
start_col,
173+
end_line,
174+
end_col,
175+
),
167176
}
168177
}
169178

@@ -188,9 +197,6 @@ impl CounterMappingRegion {
188197
}
189198
}
190199

191-
// This function might be used in the future; the LLVM API is still evolving, as is coverage
192-
// support.
193-
#[allow(dead_code)]
194200
pub(crate) fn branch_region(
195201
counter: Counter,
196202
false_counter: Counter,

compiler/rustc_codegen_llvm/src/coverageinfo/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ impl<'tcx> CoverageInfoBuilderMethods<'tcx> for Builder<'_, '_, 'tcx> {
8888
match coverage.kind {
8989
// Marker statements have no effect during codegen,
9090
// so return early and don't create `func_coverage`.
91-
CoverageKind::SpanMarker => return,
91+
CoverageKind::SpanMarker | CoverageKind::BlockMarker { .. } => return,
9292
// Match exhaustively to ensure that newly-added kinds are classified correctly.
9393
CoverageKind::CounterIncrement { .. } | CoverageKind::ExpressionUsed { .. } => {}
9494
}
@@ -108,7 +108,7 @@ impl<'tcx> CoverageInfoBuilderMethods<'tcx> for Builder<'_, '_, 'tcx> {
108108

109109
let Coverage { kind } = coverage;
110110
match *kind {
111-
CoverageKind::SpanMarker => unreachable!(
111+
CoverageKind::SpanMarker | CoverageKind::BlockMarker { .. } => unreachable!(
112112
"unexpected marker statement {kind:?} should have caused an early return"
113113
),
114114
CoverageKind::CounterIncrement { id } => {

compiler/rustc_codegen_ssa/src/back/link.rs

+15
Original file line numberDiff line numberDiff line change
@@ -1081,6 +1081,21 @@ fn link_natively<'a>(
10811081
}
10821082
}
10831083

1084+
if sess.target.is_like_aix {
1085+
let stripcmd = "/usr/bin/strip";
1086+
match strip {
1087+
Strip::Debuginfo => {
1088+
// FIXME: AIX's strip utility only offers option to strip line number information.
1089+
strip_symbols_with_external_utility(sess, stripcmd, out_filename, Some("-l"))
1090+
}
1091+
Strip::Symbols => {
1092+
// Must be noted this option might remove symbol __aix_rust_metadata and thus removes .info section which contains metadata.
1093+
strip_symbols_with_external_utility(sess, stripcmd, out_filename, Some("-r"))
1094+
}
1095+
Strip::None => {}
1096+
}
1097+
}
1098+
10841099
Ok(())
10851100
}
10861101

compiler/rustc_codegen_ssa/src/back/linker.rs

+1-10
Original file line numberDiff line numberDiff line change
@@ -1640,16 +1640,7 @@ impl<'a> Linker for AixLinker<'a> {
16401640

16411641
fn ehcont_guard(&mut self) {}
16421642

1643-
fn debuginfo(&mut self, strip: Strip, _: &[PathBuf]) {
1644-
match strip {
1645-
Strip::None => {}
1646-
// FIXME: -s strips the symbol table, line number information
1647-
// and relocation information.
1648-
Strip::Debuginfo | Strip::Symbols => {
1649-
self.cmd.arg("-s");
1650-
}
1651-
}
1652-
}
1643+
fn debuginfo(&mut self, _: Strip, _: &[PathBuf]) {}
16531644

16541645
fn no_crt_objects(&mut self) {}
16551646

compiler/rustc_codegen_ssa/src/mir/mod.rs

+39-23
Original file line numberDiff line numberDiff line change
@@ -377,29 +377,45 @@ fn arg_local_refs<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(
377377
}
378378
}
379379

380-
if arg.is_sized_indirect() {
381-
// Don't copy an indirect argument to an alloca, the caller
382-
// already put it in a temporary alloca and gave it up.
383-
// FIXME: lifetimes
384-
let llarg = bx.get_param(llarg_idx);
385-
llarg_idx += 1;
386-
LocalRef::Place(PlaceRef::new_sized(llarg, arg.layout))
387-
} else if arg.is_unsized_indirect() {
388-
// As the storage for the indirect argument lives during
389-
// the whole function call, we just copy the fat pointer.
390-
let llarg = bx.get_param(llarg_idx);
391-
llarg_idx += 1;
392-
let llextra = bx.get_param(llarg_idx);
393-
llarg_idx += 1;
394-
let indirect_operand = OperandValue::Pair(llarg, llextra);
395-
396-
let tmp = PlaceRef::alloca_unsized_indirect(bx, arg.layout);
397-
indirect_operand.store(bx, tmp);
398-
LocalRef::UnsizedPlace(tmp)
399-
} else {
400-
let tmp = PlaceRef::alloca(bx, arg.layout);
401-
bx.store_fn_arg(arg, &mut llarg_idx, tmp);
402-
LocalRef::Place(tmp)
380+
match arg.mode {
381+
// Sized indirect arguments
382+
PassMode::Indirect { attrs, meta_attrs: None, on_stack: _ } => {
383+
// Don't copy an indirect argument to an alloca, the caller already put it
384+
// in a temporary alloca and gave it up.
385+
// FIXME: lifetimes
386+
if let Some(pointee_align) = attrs.pointee_align
387+
&& pointee_align < arg.layout.align.abi
388+
{
389+
// ...unless the argument is underaligned, then we need to copy it to
390+
// a higher-aligned alloca.
391+
let tmp = PlaceRef::alloca(bx, arg.layout);
392+
bx.store_fn_arg(arg, &mut llarg_idx, tmp);
393+
LocalRef::Place(tmp)
394+
} else {
395+
let llarg = bx.get_param(llarg_idx);
396+
llarg_idx += 1;
397+
LocalRef::Place(PlaceRef::new_sized(llarg, arg.layout))
398+
}
399+
}
400+
// Unsized indirect qrguments
401+
PassMode::Indirect { attrs: _, meta_attrs: Some(_), on_stack: _ } => {
402+
// As the storage for the indirect argument lives during
403+
// the whole function call, we just copy the fat pointer.
404+
let llarg = bx.get_param(llarg_idx);
405+
llarg_idx += 1;
406+
let llextra = bx.get_param(llarg_idx);
407+
llarg_idx += 1;
408+
let indirect_operand = OperandValue::Pair(llarg, llextra);
409+
410+
let tmp = PlaceRef::alloca_unsized_indirect(bx, arg.layout);
411+
indirect_operand.store(bx, tmp);
412+
LocalRef::UnsizedPlace(tmp)
413+
}
414+
_ => {
415+
let tmp = PlaceRef::alloca(bx, arg.layout);
416+
bx.store_fn_arg(arg, &mut llarg_idx, tmp);
417+
LocalRef::Place(tmp)
418+
}
403419
}
404420
})
405421
.collect::<Vec<_>>();

0 commit comments

Comments
 (0)