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

[MIR] Initial implementation for translating calls. #30364

Merged
merged 1 commit into from
Dec 19, 2015

Conversation

luqmana
Copy link
Member

@luqmana luqmana commented Dec 13, 2015

@rust-highfive
Copy link
Collaborator

r? @jroesch

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

@@ -49,8 +68,11 @@ impl<'bcx, 'tcx> MirContext<'bcx, 'tcx> {
{
let constant_ty = bcx.monomorphize(&constant.ty);
match constant.literal {
mir::Literal::Item { .. } => {
unimplemented!()
mir::Literal::Item { def_id, substs } => {
Copy link
Member

Choose a reason for hiding this comment

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

Wait until #29907 is landed?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yea sure, ended up seeing it later and it's definitely nicer and more complete. I'll rebase on top of that instead.

@nikomatsakis
Copy link
Contributor

r? @nikomatsakis

@nikomatsakis nikomatsakis assigned nikomatsakis and unassigned jroesch Dec 14, 2015
fn test2(a: isize) -> isize {
// Test passing a single argument.
// Not using out pointer.
fn callee(a: isize) -> isize {
Copy link
Contributor

Choose a reason for hiding this comment

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

can you add some tests using trait dispatch? (or does that not work yet)

Copy link
Member Author

Choose a reason for hiding this comment

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

Added some more tests for calling methods in different ways. #29907 + this pull also allow calling trait static methods which i've also included a test for.

@bors
Copy link
Contributor

bors commented Dec 18, 2015

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

@nikomatsakis
Copy link
Contributor

So #29907 has landed. I see that this PR was rebased, presumably to account for that?

@nikomatsakis
Copy link
Contributor

@bors r+

Thanks @luqmana! Exciting. This is a big hurdle.

@bors
Copy link
Contributor

bors commented Dec 18, 2015

📌 Commit fefe4e8 has been approved by nikomatsakis

@bors
Copy link
Contributor

bors commented Dec 18, 2015

⌛ Testing commit fefe4e8 with merge b784e6c...

@bors
Copy link
Contributor

bors commented Dec 18, 2015

💔 Test failed - auto-win-msvc-64-opt

@dotdash
Copy link
Contributor

dotdash commented Dec 18, 2015

@luqmana That failure on windows is legit. The call to callee in test1 moves the Box, but still drops it. Valgrind also complains about that on linux.

==9625==    at 0x148878: je_valgrind_freelike_block (valgrind.c:33)
==9625==    by 0x10CE9F: heap::deallocate::ha08705e845151bb14ea (in /home/doener/src/rust-origin/mir_trans_calls)
==9625==    by 0x10CE44: heap::exchange_free::h2c2ccc188aeabd2akga (in /home/doener/src/rust-origin/mir_trans_calls)
==9625==    by 0x10CE11: Box$LT$i32$GT$::drop.3501::h2325578bde125039 (in /home/doener/src/rust-origin/mir_trans_calls)
==9625==    by 0x10CD31: test1::h2cd52b4aff680550eaa (in /home/doener/src/rust-origin/mir_trans_calls)
==9625==    by 0x10D219: main::h31e20355ce7fed41xda (in /home/doener/src/rust-origin/mir_trans_calls)
==9625==    by 0x115704: sys_common::unwind::try::try_fn::h7505552440393768204 (in /home/doener/src/rust-origin/mir_trans_calls)
==9625==    by 0x1132E8: __rust_try (in /home/doener/src/rust-origin/mir_trans_calls)
==9625==    by 0x1153A6: rt::lang_start::h347da8ae9f69d42864x (in /home/doener/src/rust-origin/mir_trans_calls)
==9625==    by 0x10F659: main (in /home/doener/src/rust-origin/mir_trans_calls)
==9625==  Address 0x6021048 is 0 bytes inside a block of size 8 free'd
==9625==    at 0x148878: je_valgrind_freelike_block (valgrind.c:33)
==9625==    by 0x10CE9F: heap::deallocate::ha08705e845151bb14ea (in /home/doener/src/rust-origin/mir_trans_calls)
==9625==    by 0x10CE44: heap::exchange_free::h2c2ccc188aeabd2akga (in /home/doener/src/rust-origin/mir_trans_calls)
==9625==    by 0x10CE11: Box$LT$i32$GT$::drop.3501::h2325578bde125039 (in /home/doener/src/rust-origin/mir_trans_calls)
==9625==    by 0x10CD27: test1::h2cd52b4aff680550eaa (in /home/doener/src/rust-origin/mir_trans_calls)
==9625==    by 0x10D219: main::h31e20355ce7fed41xda (in /home/doener/src/rust-origin/mir_trans_calls)
==9625==    by 0x115704: sys_common::unwind::try::try_fn::h7505552440393768204 (in /home/doener/src/rust-origin/mir_trans_calls)
==9625==    by 0x1132E8: __rust_try (in /home/doener/src/rust-origin/mir_trans_calls)
==9625==    by 0x1153A6: rt::lang_start::h347da8ae9f69d42864x (in /home/doener/src/rust-origin/mir_trans_calls)
==9625==    by 0x10F659: main (in /home/doener/src/rust-origin/mir_trans_calls)
==9625==  Block was alloc'd at
==9625==    at 0x11FBD3: je_mallocx (jemalloc.c:1560)
==9625==    by 0x10E4CF: heap::allocate::habdc17f0007099bfPda (in /home/doener/src/rust-origin/mir_trans_calls)
==9625==    by 0x10E442: heap::exchange_malloc::h8c52e41374611846Jfa (in /home/doener/src/rust-origin/mir_trans_calls)
==9625==    by 0x10D1DB: main::h31e20355ce7fed41xda (in /home/doener/src/rust-origin/mir_trans_calls)
==9625==    by 0x115704: sys_common::unwind::try::try_fn::h7505552440393768204 (in /home/doener/src/rust-origin/mir_trans_calls)
==9625==    by 0x1132E8: __rust_try (in /home/doener/src/rust-origin/mir_trans_calls)
==9625==    by 0x1153A6: rt::lang_start::h347da8ae9f69d42864x (in /home/doener/src/rust-origin/mir_trans_calls)
==9625==    by 0x10F659: main (in /home/doener/src/rust-origin/mir_trans_calls)
==9625== 
==9625== Invalid read of size 4
==9625==    at 0x10E64F: cmp::impls::i32.PartialEq::eq::h6dd47283b5ba64938fA (in /home/doener/src/rust-origin/mir_trans_calls)
==9625==    by 0x10E632: boxed::Box$LT$T$GT$.PartialEq::eq::eq::h15679945919347397840 (in /home/doener/src/rust-origin/mir_trans_calls)
==9625==    by 0x10E589: tuple::_$LP$A$C$$u20$B$C$$u20$C$RP$.PartialEq::eq::eq::h13937896417118323772 (in /home/doener/src/rust-origin/mir_trans_calls)
==9625==    by 0x10D3FD: main::h31e20355ce7fed41xda (in /home/doener/src/rust-origin/mir_trans_calls)
==9625==    by 0x115704: sys_common::unwind::try::try_fn::h7505552440393768204 (in /home/doener/src/rust-origin/mir_trans_calls)
==9625==    by 0x1132E8: __rust_try (in /home/doener/src/rust-origin/mir_trans_calls)
==9625==    by 0x1153A6: rt::lang_start::h347da8ae9f69d42864x (in /home/doener/src/rust-origin/mir_trans_calls)
==9625==    by 0x10F659: main (in /home/doener/src/rust-origin/mir_trans_calls)
==9625==  Address 0x6021048 is 0 bytes inside a block of size 8 free'd
==9625==    at 0x148878: je_valgrind_freelike_block (valgrind.c:33)
==9625==    by 0x10CE9F: heap::deallocate::ha08705e845151bb14ea (in /home/doener/src/rust-origin/mir_trans_calls)
==9625==    by 0x10CE44: heap::exchange_free::h2c2ccc188aeabd2akga (in /home/doener/src/rust-origin/mir_trans_calls)
==9625==    by 0x10CE11: Box$LT$i32$GT$::drop.3501::h2325578bde125039 (in /home/doener/src/rust-origin/mir_trans_calls)
==9625==    by 0x10CD27: test1::h2cd52b4aff680550eaa (in /home/doener/src/rust-origin/mir_trans_calls)
==9625==    by 0x10D219: main::h31e20355ce7fed41xda (in /home/doener/src/rust-origin/mir_trans_calls)
==9625==    by 0x115704: sys_common::unwind::try::try_fn::h7505552440393768204 (in /home/doener/src/rust-origin/mir_trans_calls)
==9625==    by 0x1132E8: __rust_try (in /home/doener/src/rust-origin/mir_trans_calls)
==9625==    by 0x1153A6: rt::lang_start::h347da8ae9f69d42864x (in /home/doener/src/rust-origin/mir_trans_calls)
==9625==    by 0x10F659: main (in /home/doener/src/rust-origin/mir_trans_calls)
==9625==  Block was alloc'd at
==9625==    at 0x11FBD3: je_mallocx (jemalloc.c:1560)
==9625==    by 0x10E4CF: heap::allocate::habdc17f0007099bfPda (in /home/doener/src/rust-origin/mir_trans_calls)
==9625==    by 0x10E442: heap::exchange_malloc::h8c52e41374611846Jfa (in /home/doener/src/rust-origin/mir_trans_calls)
==9625==    by 0x10D1DB: main::h31e20355ce7fed41xda (in /home/doener/src/rust-origin/mir_trans_calls)
==9625==    by 0x115704: sys_common::unwind::try::try_fn::h7505552440393768204 (in /home/doener/src/rust-origin/mir_trans_calls)
==9625==    by 0x1132E8: __rust_try (in /home/doener/src/rust-origin/mir_trans_calls)
==9625==    by 0x1153A6: rt::lang_start::h347da8ae9f69d42864x (in /home/doener/src/rust-origin/mir_trans_calls)
==9625==    by 0x10F659: main (in /home/doener/src/rust-origin/mir_trans_calls)

@nagisa
Copy link
Member

nagisa commented Dec 18, 2015

See #29855

@dotdash
Copy link
Contributor

dotdash commented Dec 18, 2015

As @nagisa said on IRC, I think it's fine to just remove the Box argument for now to make the test work.

@nikomatsakis
Copy link
Contributor

On Fri, Dec 18, 2015 at 08:20:02AM -0800, Simonas Kazlauskas wrote:

See #29855

Oh yeah, we probably want to modify trans to zero. Bah. Forgot about
that!

@luqmana
Copy link
Member Author

luqmana commented Dec 18, 2015

@bors: r=nikomatsakis

Just removed Box from the test for now til we get drop working.

@bors
Copy link
Contributor

bors commented Dec 18, 2015

📌 Commit a6b861b has been approved by nikomatsakis

@bors
Copy link
Contributor

bors commented Dec 18, 2015

⌛ Testing commit a6b861b with merge 9e27895...

@bors bors merged commit a6b861b into rust-lang:master Dec 19, 2015
@luqmana luqmana deleted the mir-calls branch December 19, 2015 05:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants