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

fix codegen for getfield of homogeneous tuples #34243

Merged
merged 1 commit into from
Jan 3, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
fix codegen for getfield of homogeneous tuples
fix #34206, fix #34207
  • Loading branch information
JeffBezanson committed Jan 2, 2020
commit 840f6d4e92d0443a0f75d313784e62a83e18d29a
5 changes: 4 additions & 1 deletion src/codegen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2903,8 +2903,11 @@ static bool emit_builtin_call(jl_codectx_t &ctx, jl_cgval_t *ret, jl_value_t *f,
emit_datatype_nfields(ctx, emit_typeof_boxed(ctx, obj)),
jl_true);
}
bool isboxed = !jl_datatype_isinlinealloc(jt);
Value *ptr = maybe_decay_tracked(data_pointer(ctx, obj));
*ret = typed_load(ctx, ptr, vidx, jt, obj.tbaa, nullptr, false);
*ret = typed_load(ctx, ptr, vidx,
Copy link
Member

Choose a reason for hiding this comment

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

The return cgval gets annotated with the type we pass in. Does widening to Any pessimize later codegen?

Copy link
Sponsor Member Author

Choose a reason for hiding this comment

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

I'd guess not really, since codegen generally uses inferred types when it needs type info. We're also doing the same thing for arrayref on pointer arrays, so it'd better work 😛

isboxed ? (jl_value_t*)jl_any_type : jt,
obj.tbaa, nullptr, false);
return true;
}
}
Expand Down
8 changes: 8 additions & 0 deletions test/core.jl
Original file line number Diff line number Diff line change
Expand Up @@ -7156,3 +7156,11 @@ struct B33954
end
@test_broken isbitstype(Tuple{B33954})
@test_broken isbitstype(B33954)

# Issue #34206/34207
function mre34206(a, n)
va = view(a, :)
b = ntuple(_ -> va, n)::Tuple{Vararg{typeof(va)}}
return b[1].offset1
end
@test mre34206([44], 1) == 0