Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle dyn* coercions for values that are represented with OperandValue::Ref #104694

Closed

Conversation

compiler-errors
Copy link
Member

@compiler-errors compiler-errors commented Nov 21, 2022

I'm not fully certain this is the right fix, but it seems to work fine.

For some reason the codegen backend doesn't want to represent the value (which is usize-sized and aligned) as an Immediate, but instead as as OperandValue::Ref, which means it's alloca'd onto the stack. We handle that by reading it back into an immediate as a usize.

Similarly, during const eval, the read_immediate call in the dyn* cast fails because the value is represented by an Aggregate ABI (even though it has one field). To fix this, instead of reading it to an immediate, just do the write as two parts -- the data and the vtable.

Fixes #104631

@rustbot
Copy link
Collaborator

rustbot commented Nov 21, 2022

r? @jackh726

(rustbot has picked a reviewer for you, use r? to override)

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Nov 21, 2022
@rustbot
Copy link
Collaborator

rustbot commented Nov 21, 2022

Some changes occurred to the CTFE / Miri engine

cc @rust-lang/miri

let val = Immediate::ScalarPair(data, vtable);
self.write_immediate(val, dest)?;
let vtable_dest = self.place_field(dest, 1)?;
self.write_scalar(vtable, &vtable_dest)?;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What would be a test that covers this?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The test I changed from check-pass to build-pass ICEs at the read_immediate I removed, so that exercises these changes I guess.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Uh, that does not sound very confident.^^ Also that test doesn't use const nor Miri so it cannot be a proper test for this.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll commit a Miri version of the test below then.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can add that test in this PR.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(Looking at this again now that I know a bit more about dyn-star)

Yeah the old code assumes a Scalar ABI. Probably this is true throughout codegen and Miri, so tests should be added for types with a different ABI (both codegen tests and Miri tests, the latter relying on #107728):

  • (i32, i32) will give you ScalarPair ABI
  • a repr(C) type will give you Aggregate ABI

The latter cannot be loaded with read_immediate, it needs a copy_op. So the code here makes sense, but we are missing tests.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(i32, i32) will give you ScalarPair ABI

I realized this won't have the right alignment. I don't think it is possible to have a ScalarPair type with size+alignment 8.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah I agree. Forgot to comment that I tried and failed to test a ScalarPair.

@compiler-errors
Copy link
Member Author

@rustbot author

@rustbot rustbot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Dec 1, 2022
@RalfJung
Copy link
Member

For some reason the codegen backend doesn't want to represent the value (which is usize-sized and aligned) as an Immediate, but instead as as OperandValue::Ref, which means it's alloca'd onto the stack. We handle that by reading it back into an immediate as a usize.

This is probably related to the Abi of the type. usize has Scalar ABI, but it is completely normal to have types of the same size&alignment that do have a different ABI.

I don't know what exactly happens with all this in the codegen backend.

@rustbot
Copy link
Collaborator

rustbot commented Feb 26, 2023

The Miri subtree was changed

cc @rust-lang/miri

tcx.mk_array(tcx.types.usize, 3),
),
)
TyMaybeWithLayout::Ty(tcx.mk_imm_ptr(tcx.mk_array(tcx.types.usize, 3)))
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is necessary because if we represent the vtable as a reference, then CTFE wants to validate the pointer. However, the vtable is represented by GlobalAlloc::VTable, which is treated like Size::ZERO. So it complains that we're trying to write 24 bytes into an allocation of size 0.

Alternatively, we could fix this instead I guess:

return (Size::ZERO, self.tcx.data_layout.pointer_align.abi, AllocKind::VTable);

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This shouldn't happen, validity checking should stop at the dyn* and not descend into its components.

Did you rebase? #107728 fixed some issues with dyn* handling in the validity check.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, this is based off of a rebased master.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Strange. Then CTFE should never see this type.

What's the error you are getting otherwise, and for which code? Ideally with RUSTC_CTFE_BACKTRACE=1

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Strange. Then CTFE should never see this type.

Why?

https://github.com/rust-lang/rust/pull/104694/files#diff-60d85c7ca5a99b206384a4ccb596b7e0f9824fd6606ae7241e2d4a4e5ae65025R134

Here we write the vtable to the second part of the scalar pair. So we're trying to write the vtable allocation pointer to a place of type &'static [usize; 3], which then tries to validate that vtable pointer.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, that's where this comes from. But during CTFE we don't do validation on writes... this should only affect Miri. Still a problem though.

However why wouldn't this also be a problem for vtables in wide pointers?

I'm also worried using a raw pointer type here could have bad side-effects, like losing nonnull attributes. IIRC there are two places where we define the layout/type/attributes for fields of wide ptrs and dyn* and I have no idea what happens when they start to diverge.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

However why wouldn't this also be a problem for vtables in wide pointers?

It's probably because we don't explicitly split up the write for &dyn .. writes into two writes like we do for dyn*..

@@ -0,0 +1,191 @@
thread 'rustc' panicked at 'assertion failed: match (base.layout.abi, field_layout.abi) {/n (Abi::Scalar(..), Abi::Scalar(..)) => true,/n (Abi::ScalarPair(..), Abi::ScalarPair(..)) => true,/n _ => false,/n}', /home/ec2-user/rust/compiler/rustc_const_eval/src/interpret/projection.rs:LL:CC
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have no idea what's going on here.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's this assertion

assert!(match (base.layout.abi, field_layout.abi) {
(Abi::Scalar(..), Abi::Scalar(..)) => true,
(Abi::ScalarPair(..), Abi::ScalarPair(..)) => true,
_ => false,
});

So looks like a bad layout... strange that that would not be caught by the layout sanity check.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it because we're storing something with an aggregate abi inside the dyn*'s data part? Then when we try to project to one of the data's fields, it explodes?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the dyn* layout in that case? It can't be ScalarPair -- if the data part is aggregate, the dyn* must also be aggregate.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well dyn* is always a ScalarPair. I don't think it can be conditional based on what the data part is. Maybe it should always be represented as aggregate? I guess in that case codegen would need some tweaking.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm, this is nasty. Usually the solution for issues like this is to do force_allocation, but then unpack_dyn_star requires &mut self and we are using it from the visitor which is supposed to work with &self...

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I tried that too and ran into exactly the &mut problem you talked about. It did work, though, except for the fact that I had to comment out some validation code that only had access to &self 🥲

Copy link
Member

@RalfJung RalfJung Mar 20, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would be good to get some codegen expertise here. Looks like this PR adds a bunch of ptr casts to codegen to align things; no idea if that breaks some invariants somewhere.

On the Miri side this is pretty fundamental: we could start out with an Immediate(ScalarPair) of type dyn*, and then after resolving to the actual dynamic type we realize the layout is Abi::Aggregate which cannot usually ever be stored in an immediate. This could happen in the middle of the immutable visitor, so we can't force a new allocation either -- we are entirely stuck. Either we somehow make Miri work with Immediate::Scalar that do not have Abi::Scalar (:scream:) or dyn* has to be Aggregate from the start (which also affects codegen so it doesn't seem great that Miri would force such a choice).

Cc @oli-obk @eddyb

EDIT: Ah in codegen this cannot possibly break anything, since codegen could never go from a dyn* to a value of the underlying type...

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well I guess another option would be to not allow dyn* for types with Abi::Aggregate.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm happy to further constrain the PointerLike trait (enforcing dyn* coerceability) to require that the type is scalar. In the future, we may want to allow (e.g.) repr(C) data types to be coerced into a dyn*, but for now I'm not convinced it requires the additional complications that Ralf elaborated above.

@rust-log-analyzer
Copy link
Collaborator

The job x86_64-gnu-llvm-14 failed! Check out the build log: (web) (plain)

Click to see the possible cause of the failure (guessed by this bot)
Prepare all required actions
Getting action download info
Download action repository 'actions/checkout@v3' (SHA:ac593985615ec2ede58e132d2e21d2b1cbd6127c)
Download action repository 'rust-lang/simpleinfra@master' (SHA:697bea7ddceb6696743da8f159f268aef8bfb3c6)
Complete job name: PR (x86_64-gnu-llvm-14, false, ubuntu-20.04-xl)
git config --global core.autocrlf false
shell: /usr/bin/bash --noprofile --norc -e -o pipefail {0}
env:
  CI_JOB_NAME: x86_64-gnu-llvm-14
---
Check compiletest suite=codegen mode=codegen (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu)

running 409 tests
i.....i..i............i....i..ii.................iii........i.i.i........i.............. 88/409
.....ii.................i..............i.....i...............i....i...iiii.F.....i..i... 176/409
...............ii........................i.i.ii.i.i...............i....i....i..iii...... 352/409
Some tests failed in compiletest suite=codegen mode=codegen host=x86_64-unknown-linux-gnu target=x86_64-unknown-linux-gnu
.i...i......................iiiiiiii.i...................
failures:
failures:

---- [codegen] tests/codegen/function-arguments.rs stdout ----

error: verification with 'FileCheck' failed
status: exit status: 1
command: "/usr/lib/llvm-14/bin/FileCheck" "--input-file" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/codegen/function-arguments/function-arguments.ll" "/checkout/tests/codegen/function-arguments.rs" "--allow-unused-prefixes" "--check-prefixes" "CHECK,NONMSVC" "--dump-input-context" "100"
stdout: none
--- stderr -------------------------------
/checkout/tests/codegen/function-arguments.rs:284:11: error: CHECK: expected string not found in input
// CHECK: { {{\{\}\*|ptr}}, {{.+}} } @dyn_star({{\{\}\*|ptr}} noundef %x.0, {{.+}} noalias noundef readonly align {{.*}} dereferenceable({{.*}}) %x.1)
          ^
/checkout/obj/build/x86_64-unknown-linux-gnu/test/codegen/function-arguments/function-arguments.ll:643:63: note: scanning from here
define { i8, i8 } @enum_id_2(i1 noundef zeroext %x.0, i8 %x.1) unnamed_addr #0 {

Input file: /checkout/obj/build/x86_64-unknown-linux-gnu/test/codegen/function-arguments/function-arguments.ll
Check file: /checkout/tests/codegen/function-arguments.rs


-dump-input=help explains the following input dump.
Input was:
<<<<<<
           .
           .
           .
           .
         543: } 
         544:  
         545: ; Function Attrs: nonlazybind uwtable 
         546: define void @helper(i64 noundef %_1) unnamed_addr #0 { 
         548:  ret void 
         549: } 
         550:  
         550:  
         551: ; Function Attrs: nonlazybind uwtable 
         552: define void @slice([0 x i8]* noalias noundef nonnull readonly align 1 %_1.0, i64 noundef %_1.1) unnamed_addr #0 { 
         554:  ret void 
         555: } 
         556:  
         556:  
         557: ; Function Attrs: nonlazybind uwtable 
         558: define void @mutable_slice([0 x i8]* noalias noundef nonnull align 1 %_1.0, i64 noundef %_1.1) unnamed_addr #0 { 
         560:  ret void 
         561: } 
         562:  
         562:  
         563: ; Function Attrs: nonlazybind uwtable 
         564: define void @unsafe_slice([0 x i16]* noundef nonnull align 2 %_1.0, i64 noundef %_1.1) unnamed_addr #0 { 
         566:  ret void 
         567: } 
         568:  
         568:  
         569: ; Function Attrs: nonlazybind uwtable 
         570: define void @raw_slice([0 x i8]* noundef %_1.0, i64 noundef %_1.1) unnamed_addr #0 { 
         572:  ret void 
         573: } 
         574:  
         574:  
         575: ; Function Attrs: nonlazybind uwtable 
         576: define void @str([0 x i8]* noalias noundef nonnull readonly align 1 %_1.0, i64 noundef %_1.1) unnamed_addr #0 { 
         578:  ret void 
         579: } 
         580:  
         580:  
         581: ; Function Attrs: nonlazybind uwtable 
         582: define void @trait_borrow({}* noundef nonnull align 1 %_1.0, [3 x i64]* noalias noundef readonly align 8 dereferenceable(24) %_1.1) unnamed_addr #0 { 
         584:  ret void 
         585: } 
         586:  
         586:  
         587: ; Function Attrs: nonlazybind uwtable 
         588: define void @option_trait_borrow(i8* noundef align 1 %x.0, i8* %x.1) unnamed_addr #0 { 
         590:  ret void 
         591: } 
         592:  
         592:  
         593: ; Function Attrs: nonlazybind uwtable 
         594: define void @option_trait_borrow_mut(i8* noundef align 1 %x.0, i8* %x.1) unnamed_addr #0 { 
         596:  ret void 
         597: } 
         598:  
         598:  
         599: ; Function Attrs: nonlazybind uwtable 
         600: define void @trait_raw({}* noundef %_1.0, [3 x i64]* noalias noundef readonly align 8 dereferenceable(24) %_1.1) unnamed_addr #0 { 
         602:  ret void 
         603: } 
         604:  
         604:  
         605: ; Function Attrs: nonlazybind uwtable 
         606: define void @trait_box({}* noalias noundef nonnull align 1 %0, [3 x i64]* noalias noundef readonly align 8 dereferenceable(24) %1) unnamed_addr #0 { 
         607: start: 
         608:  %_1 = alloca { {}*, [3 x i64]* }, align 8 
         609:  %2 = getelementptr inbounds { {}*, [3 x i64]* }, { {}*, [3 x i64]* }* %_1, i32 0, i32 0 
         610:  store {}* %0, {}** %2, align 8 
         611:  %3 = getelementptr inbounds { {}*, [3 x i64]* }, { {}*, [3 x i64]* }* %_1, i32 0, i32 1 
         612:  store [3 x i64]* %1, [3 x i64]** %3, align 8 
         613: ; call core::ptr::drop_in_place<alloc::boxed::Box<dyn core::ops::drop::Drop+core::marker::Unpin>> 
         614:  call void @"_ZN4core3ptr99drop_in_place$LT$alloc..boxed..Box$LT$dyn$u20$core..ops..drop..Drop$u2b$core..marker..Unpin$GT$$GT$17h415ae239c7e70498E"({ {}*, [3 x i64]* }* noundef %_1) 
         615:  ret void 
         616: } 
         617:  
         618: ; Function Attrs: nonlazybind uwtable 
         619: define { i8*, i8* } @trait_option(i8* noalias noundef align 1 %x.0, i8* %x.1) unnamed_addr #0 { 
         620: start: 
         621:  %0 = insertvalue { i8*, i8* } undef, i8* %x.0, 0 
         622:  %1 = insertvalue { i8*, i8* } %0, i8* %x.1, 1 
         623:  ret { i8*, i8* } %1 
         624: } 
         625:  
         626: ; Function Attrs: nonlazybind uwtable 
         627: define { [0 x i16]*, i64 } @return_slice([0 x i16]* noalias noundef nonnull readonly align 2 %x.0, i64 noundef %x.1) unnamed_addr #0 { 
         628: start: 
         629:  %0 = insertvalue { [0 x i16]*, i64 } undef, [0 x i16]* %x.0, 0 
         630:  %1 = insertvalue { [0 x i16]*, i64 } %0, i64 %x.1, 1 
         631:  ret { [0 x i16]*, i64 } %1 
         632: } 
         633:  
         634: ; Function Attrs: nonlazybind uwtable 
         635: define { i16, i16 } @enum_id_1(i16 noundef %x.0, i16 %x.1) unnamed_addr #0 { 
         636: start: 
         637:  %0 = insertvalue { i16, i16 } undef, i16 %x.0, 0 
         638:  %1 = insertvalue { i16, i16 } %0, i16 %x.1, 1 
         639:  ret { i16, i16 } %1 
         640: } 
         641:  
         642: ; Function Attrs: nonlazybind uwtable 
         643: define { i8, i8 } @enum_id_2(i1 noundef zeroext %x.0, i8 %x.1) unnamed_addr #0 { 
check:284                                                                   X~~~~~~~~~~~~~~~~~~ error: no match found
check:284     ~~~~~~~
check:284     ~~~~~~~
         645:  %0 = zext i1 %x.0 to i8 
check:284     ~~~~~~~~~~~~~~~~~~~~~~~~~
         646:  %1 = insertvalue { i8, i8 } undef, i8 %0, 0 
check:284     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
         647:  %2 = insertvalue { i8, i8 } %1, i8 %x.1, 1 
check:284     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
         648:  ret { i8, i8 } %2 
         649: } 
check:284     ~~
         650:  
check:284     ~
check:284     ~
         651: ; Function Attrs: nonlazybind uwtable 
check:284     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
         652: define { {}*, [3 x i64]* } @dyn_star({}* noundef %x.0, [3 x i64]* noundef nonnull %x.1) unnamed_addr #0 { 
         653: start: 
check:284     ~~~~~~~
check:284     ~~~~~~~
         654:  %0 = insertvalue { {}*, [3 x i64]* } undef, {}* %x.0, 0 
check:284     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
         655:  %1 = insertvalue { {}*, [3 x i64]* } %0, [3 x i64]* %x.1, 1 
check:284     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
         656:  ret { {}*, [3 x i64]* } %1 
         657: } 
check:284     ~~
         658:  
check:284     ~
check:284     ~
         659: ; Function Attrs: argmemonly nofree nosync nounwind willreturn 
check:284     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
         660: declare void @llvm.lifetime.start.p0i8(i64 immarg, i8* nocapture) #2 
         661:  
check:284     ~
check:284     ~
         662: ; Function Attrs: argmemonly nofree nosync nounwind willreturn 
check:284     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
         663: declare void @llvm.lifetime.end.p0i8(i64 immarg, i8* nocapture) #2 
         664:  
check:284     ~
         665: ; core::panicking::panic_nounwind 
check:284     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
check:284     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
         666: ; Function Attrs: cold noinline noreturn nounwind nonlazybind uwtable 
check:284     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
         667: declare void @_ZN4core9panicking14panic_nounwind17hd14c3d7b8c5401bfE([0 x i8]* noalias noundef nonnull readonly align 1, i64 noundef) unnamed_addr #3 
         668:  
check:284     ~
check:284     ~
         669: ; Function Attrs: nonlazybind uwtable 
check:284     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
         670: declare noundef i32 @rust_eh_personality(i32 noundef, i32 noundef, i64 noundef, %"unwind::libunwind::_Unwind_Exception"* noundef, %"unwind::libunwind::_Unwind_Context"* noundef) unnamed_addr #0 
         671:  
check:284     ~
         672: ; core::panicking::panic_cannot_unwind 
check:284     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
check:284     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
         673: ; Function Attrs: cold noinline noreturn nounwind nonlazybind uwtable 
check:284     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
         674: declare void @_ZN4core9panicking19panic_cannot_unwind17hed29291bf070713aE() unnamed_addr #3 
         675:  
check:284     ~
check:284     ~
         676: ; Function Attrs: nofree nosync nounwind readnone speculatable willreturn 
check:284     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
         677: declare i64 @llvm.ctpop.i64(i64) #4 
         678:  
check:284     ~
check:284     ~
         679: ; Function Attrs: inaccessiblememonly nofree nosync nounwind willreturn 
check:284     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
         680: declare void @llvm.assume(i1 noundef) #5 
         681:  
check:284     ~
check:284     ~
         682: ; Function Attrs: nounwind nonlazybind uwtable 
check:284     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
         683: declare void @__rust_dealloc(i8* noundef, i64 noundef, i64 noundef) unnamed_addr #6 
         684:  
check:284     ~
check:284     ~
         685: ; Function Attrs: argmemonly nofree nounwind willreturn 
check:284     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
         686: declare void @llvm.memcpy.p0i8.p0i8.i64(i8* noalias nocapture writeonly, i8* noalias nocapture readonly, i64, i1 immarg) #7 
         687:  
check:284     ~
check:284     ~
         688: attributes #0 = { nonlazybind uwtable "probe-stack"="__rust_probestack" "target-cpu"="x86-64" } 
check:284     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
         689: attributes #1 = { inlinehint nonlazybind uwtable "probe-stack"="__rust_probestack" "target-cpu"="x86-64" } 
check:284     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
         690: attributes #2 = { argmemonly nofree nosync nounwind willreturn } 
check:284     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
         691: attributes #3 = { cold noinline noreturn nounwind nonlazybind uwtable "probe-stack"="__rust_probestack" "target-cpu"="x86-64" } 
check:284     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
         692: attributes #4 = { nofree nosync nounwind readnone speculatable willreturn } 
check:284     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
         693: attributes #5 = { inaccessiblememonly nofree nosync nounwind willreturn } 
check:284     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
         694: attributes #6 = { nounwind nonlazybind uwtable "probe-stack"="__rust_probestack" "target-cpu"="x86-64" } 
check:284     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
         695: attributes #7 = { argmemonly nofree nounwind willreturn } 
check:284     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
         696: attributes #8 = { noreturn nounwind } 
check:284     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
         697: attributes #9 = { noinline } 
check:284     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
         698: attributes #10 = { noinline noreturn nounwind } 
check:284     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
         699: attributes #11 = { nounwind } 
         700:  
check:284     ~
check:284     ~
         701: !llvm.module.flags = !{!0, !1} 
         702:  
check:284     ~
check:284     ~
         703: !0 = !{i32 7, !"PIC Level", i32 2} 
check:284     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
         704: !1 = !{i32 2, !"RtLibUseGOT", i32 1} 
check:284     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
         705: !2 = !{} 
check:284     ~~~~~~~~~
         706: !3 = !{i64 8} 
check:284     ~~~~~~~~~~~~~~
         707: !4 = !{i64 0, i64 -9223372036854775808} 
check:284     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
         708: !5 = !{i64 1, i64 0} 
check:284     ~~~~~~~~~~~~~~~~~~~~~
         709: !6 = !{i64 1, i64 -9223372036854775807} 
>>>>>>
------------------------------------------


bors added a commit to rust-lang-ci/rust that referenced this pull request Apr 9, 2023
…cjgillot

Enforce that `PointerLike` requires a pointer-like ABI

At least temporarily, let's ban coercing things that are pointer-sized and pointer-aligned but *not* `Abi::Scalar(..)` into `dyn*`. See: rust-lang#104694 (comment)

This can be lifted in the future if we decie that we *want* to be able to coerce something `repr(C)` into a `dyn*`, but we'll have to figure out what to do with Miri and codegen...

r? compiler
@bors
Copy link
Contributor

bors commented Apr 9, 2023

☔ The latest upstream changes (presumably #109413) made this pull request unmergeable. Please resolve the merge conflicts.

@compiler-errors
Copy link
Member Author

Well, given that we now just don't support dyn* at all for non-Scalar ABI, I'm gonna close this.

@compiler-errors compiler-errors deleted the dyn-star-not-imm branch August 11, 2023 19:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ICE: primitive read not possible for type: AlignedUsize
6 participants