-
Notifications
You must be signed in to change notification settings - Fork 13k
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
Additional cleanup to rustc_trans #38756
Conversation
@@ -57,6 +79,32 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { | |||
} | |||
} | |||
|
|||
pub fn build_new_block<'b>(&self, name: &'b str) -> Builder<'a, 'tcx> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd call this build_sibling_block
.
@@ -46,6 +50,24 @@ fn noname() -> *const c_char { | |||
} | |||
|
|||
impl<'a, 'tcx> Builder<'a, 'tcx> { | |||
pub fn entry_block(ccx: &'a CrateContext<'a, 'tcx>, llfn: ValueRef) -> Self { | |||
Builder::new_block(ccx, llfn, "entry-block") | |||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, I think it would be nice if this was actually encapsulated in define_fn
but I'm not sure that actually works out well.
@@ -295,14 +296,16 @@ impl ArgType { | |||
} | |||
} | |||
|
|||
pub fn store_fn_arg(&self, bcx: &BlockAndBuilder, idx: &mut usize, dst: ValueRef) { | |||
pub fn store_fn_arg( | |||
&self, bcx: &Builder, idx: &mut usize, dst: ValueRef |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: style
} else { | ||
MaybeSizedValue::unsized_(lvalue.llval, lvalue.llextra) | ||
LvalueRef::new_unsized_ty(lvalue.llval, lvalue.llextra, ty) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These two branches could reuse lvalue
and only mutate the llval
field if it needs a cast.
!self.llextra.is_null() | ||
} | ||
|
||
pub fn struct_field_ptr( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this just a helper or does this need to be public?
} else { | ||
tr_base.llextra | ||
LvalueRef::new_unsized(tr_base.llval, tr_base.llextra, tr_base.ty) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Again, this is just recreating tr_base
.
let args = &[ptr.llval, ptr.llextra][..1 + ptr.has_extra() as usize]; | ||
if bcx.ccx.shared().type_is_sized(ty) { | ||
assert!(lvalue.llextra == ptr::null_mut()); | ||
if drop_ty != ty { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The two conditions can be collapsed, I believe.
let llprojected = base.trans_field_ptr(bcx, field.index()); | ||
(llprojected, base.llextra) | ||
if self.ccx.shared().type_is_sized(projected_ty.to_ty(tcx)) { | ||
tr_base.llextra = ptr::null_mut(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wouldn't mutate tr_base
here but rather have a different variable (since it ends up in llextra
anyway).
2c76dd3
to
63790cc
Compare
adt_def: adt_def, | ||
substs: substs, | ||
variant_index: variant_index, | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not do this in the caller? Or at least at the start of the function, only once.
ptr.ty = LvalueTy::Downcast { | ||
adt_def: adt, | ||
substs: substs, | ||
variant_index: Disr::from(discr).0 as usize, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How is this even a thing for AdtKind::Struct
? This should never need downcasts. What is even VariantInfo
?!
ty: sig.output(), | ||
}; | ||
self.store_return(&ret_bcx, ret_dest, fn_ty.ret, op); | ||
ret_bcx.position_at_end(ret_bcx.llbb()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The builder is dead after this point so it shouldn't be needed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The builder is dead after this point so it shouldn't be needed.
I’m confused why all the repositioning is necessary at all anymore (somebody forgot to remove the hack?) if the blocks are translated in reverse-postorder.
Can we see if the stuff sstill works if both repositions are removed?
@bors r+ |
📌 Commit 0846c0e has been approved by |
⌛ Testing commit 0846c0e with merge c5c2083... |
💔 Test failed - status-travis |
Looks like a network error? LLVM's submodule couldn't be cloned. |
@bors retry |
☔ The latest upstream changes (presumably #38670) made this pull request unmergeable. Please resolve the merge conflicts. |
This makes a slow transition to block construction happening only from MirContext easier.
Renames iter_variant to iter_variant_fields to more clearly communicate the purpose of the function.
0846c0e
to
b01b6e1
Compare
Rebased. |
@bors r+ |
📌 Commit b01b6e1 has been approved by |
Additional cleanup to rustc_trans Removes `BlockAndBuilder`, `FunctionContext`, and `MaybeSizedValue`. `LvalueRef` is used instead of `MaybeSizedValue`, which has the added benefit of making functions operating on `Lvalue`s be able to take just that (since it encodes the type with an `LvalueTy`, which can carry discriminant information) instead of a `MaybeSizedValue` and a discriminant. r? @eddyb
☀️ Test successful - status-appveyor, status-travis |
Removes
BlockAndBuilder
,FunctionContext
, andMaybeSizedValue
.LvalueRef
is used instead ofMaybeSizedValue
, which has the added benefit of making functions operating onLvalue
s be able to take just that (since it encodes the type with anLvalueTy
, which can carry discriminant information) instead of aMaybeSizedValue
and a discriminant.r? @eddyb