Skip to content

Better test coverage for AggregateKind::RawPtr #124998

Closed as not planned
Closed as not planned

Description

@scottmcm

I noticed this today, so making this as a reminder, but if you see it and thing it sounds interesting, please pick it up!

Now that #123886 has landed, the general logic for aggregating immediates ought to work for pointers too, but seemingly it doesn't. We should add tests for whatever the problem is, so that it'll be easier for someone to validate a fix.

Steps:

  1. Delete this block that handles RawPtr specially:

mir::Rvalue::Aggregate(box mir::AggregateKind::RawPtr(..), ref fields) => {
let ty = rvalue.ty(self.mir, self.cx.tcx());
let layout = self.cx.layout_of(self.monomorphize(ty));
let [data, meta] = &*fields.raw else {
bug!("RawPtr fields: {fields:?}");
};
let data = self.codegen_operand(bx, data);
let meta = self.codegen_operand(bx, meta);
match (data.val, meta.val) {
(p @ OperandValue::Immediate(_), OperandValue::ZeroSized) => {
OperandRef { val: p, layout }
}
(OperandValue::Immediate(p), OperandValue::Immediate(m)) => {
OperandRef { val: OperandValue::Pair(p, m), layout }
}
_ => bug!("RawPtr operands {data:?} {meta:?}"),
}
}

  1. Build code to find an ICE. I'm not exactly what code it is, but it might be something related to crossbeam-utils. Might work to just ./x test --stage 2 tests/codegen, since it looks like it failed in the stage2 build in my other PR.

  2. Add minimal code to https://github.com/rust-lang/rust/blob/master/tests/codegen/mir-aggregate-no-alloca.rs that produces the same ICE when running ./x test --stage 1 tests/codegen.

  3. Undo the change from step 1 and add basic validation to the codegen test, similar to that done by the other tests in the file.

  4. Send a PR with the new tests.

  5. (Stretch goal) Delete the block mentioned in step 1 again and fix cg_ssa to pass the new test :D

Activity

  1. added
    A-codegenArea: Code generation
    E-mentorCall for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion.
    E-mediumCall for participation: Medium difficulty. Experience needed to fix: Intermediate.
    on May 11, 2024
  2. added
    needs-triageThis issue may need triage. Remove when done. See docs forge.rust-lang.org/release/issue-triaging
    on May 11, 2024
  3. removed
    E-mentorCall for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion.
    E-mediumCall for participation: Medium difficulty. Experience needed to fix: Intermediate.
    on May 11, 2024
  4. self-assigned this
    on May 11, 2024
  5. scottmcm commented on May 11, 2024

    @scottmcm
    MemberAuthor

    Oh, nvm, this isn't what I thought it was. I have a bug elsewhere.

  6. removed
    A-codegenArea: Code generation
    needs-triageThis issue may need triage. Remove when done. See docs forge.rust-lang.org/release/issue-triaging
    on May 11, 2024
  7. removed their assignment
    on May 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions