Skip to content

Avoid unnecessary temporaries when ref'ing a DST value #28787

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

Merged
merged 1 commit into from
Oct 2, 2015

Conversation

dotdash
Copy link
Contributor

@dotdash dotdash commented Oct 1, 2015

A DST value and a fat pointer to it have the same representation, all we
have to do is to adjust the type of the datum holding the pointer.

@rust-highfive
Copy link
Contributor

r? @pcwalton

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

@dotdash
Copy link
Contributor Author

dotdash commented Oct 1, 2015

r? @eddyb

@rust-highfive rust-highfive assigned eddyb and unassigned pcwalton Oct 1, 2015
@@ -1709,8 +1699,11 @@ fn trans_addr_of<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
let mut bcx = bcx;
let sub_datum = unpack_datum!(bcx, trans_to_lvalue(bcx, subexpr, "addr_of"));
if !type_is_sized(bcx.tcx(), sub_datum.ty) {
// DST lvalue, close to a fat pointer
ref_fat_ptr(bcx, sub_datum)
let dest_ty = bcx.tcx().mk_imm_ref(bcx.tcx().mk_region(ty::ReStatic), sub_datum.ty);
Copy link
Contributor

Choose a reason for hiding this comment

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

expr_ty?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks, fixed!

A DST value and a fat pointer to it have the same representation, all we
have to do is to adjust the type of the datum holding the pointer.
@dotdash dotdash force-pushed the no_more___fat_ptr branch from 6ae43a0 to bda083f Compare October 1, 2015 13:25
@eddyb
Copy link
Member

eddyb commented Oct 1, 2015

@bors r+

@bors
Copy link
Collaborator

bors commented Oct 1, 2015

📌 Commit bda083f has been approved by eddyb

@bors
Copy link
Collaborator

bors commented Oct 1, 2015

⌛ Testing commit bda083f with merge 168a23e...

bors added a commit that referenced this pull request Oct 1, 2015
A DST value and a fat pointer to it have the same representation, all we
have to do is to adjust the type of the datum holding the pointer.
@bors bors merged commit bda083f into rust-lang:master Oct 2, 2015
@brson brson added the relnotes Marks issues that should be documented in the release notes of the next release. label Oct 2, 2015
@brson
Copy link
Contributor

brson commented Oct 2, 2015

Codegen improvements. Any numbers?

@dotdash
Copy link
Contributor Author

dotdash commented Oct 3, 2015

Pretty negligible as far as optimized builds are concerned AFAICT. Didn't
bother to check unoptimized builds as this seems to be rather uncommon in
general. Just had me confused when looking at specific IR results.
Am 02.10.2015 20:27 schrieb "Brian Anderson" [email protected]:

Codegen improvements. Any numbers?


Reply to this email directly or view it on GitHub
#28787 (comment).

@dotdash dotdash deleted the no_more___fat_ptr branch January 31, 2016 15:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
relnotes Marks issues that should be documented in the release notes of the next release.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants