Address review comments
This commit is contained in:
parent
c2fd26a115
commit
8e64fc94d8
3 changed files with 6 additions and 9 deletions
|
@ -26,7 +26,6 @@ fn uncached_llvm_type<'a, 'tcx>(
|
||||||
let element = layout.scalar_llvm_type_at(cx, element);
|
let element = layout.scalar_llvm_type_at(cx, element);
|
||||||
return cx.type_vector(element, count);
|
return cx.type_vector(element, count);
|
||||||
}
|
}
|
||||||
// Treat ScalarPair like a normal aggregate for the purposes of in-memory representation.
|
|
||||||
Abi::Uninhabited | Abi::Aggregate { .. } | Abi::ScalarPair(..) => {}
|
Abi::Uninhabited | Abi::Aggregate { .. } | Abi::ScalarPair(..) => {}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -108,19 +108,17 @@ impl<'a, 'tcx, V: CodegenObject> PlaceRef<'tcx, V> {
|
||||||
// Also handles the first field of Scalar, ScalarPair, and Vector layouts.
|
// Also handles the first field of Scalar, ScalarPair, and Vector layouts.
|
||||||
self.llval
|
self.llval
|
||||||
}
|
}
|
||||||
Abi::ScalarPair(a, b)
|
Abi::ScalarPair(..) => {
|
||||||
if offset == a.size(bx.cx()).align_to(b.align(bx.cx()).abi) =>
|
// FIXME(nikic): Generate this for all ABIs.
|
||||||
{
|
|
||||||
// Offset matches second field.
|
|
||||||
bx.inbounds_gep(bx.type_i8(), self.llval, &[bx.const_usize(offset.bytes())])
|
bx.inbounds_gep(bx.type_i8(), self.llval, &[bx.const_usize(offset.bytes())])
|
||||||
}
|
}
|
||||||
Abi::Scalar(_) | Abi::ScalarPair(..) | Abi::Vector { .. } if field.is_zst() => {
|
Abi::Scalar(_) | Abi::Vector { .. } if field.is_zst() => {
|
||||||
// ZST fields (even some that require alignment) are not included in Scalar,
|
// ZST fields (even some that require alignment) are not included in Scalar,
|
||||||
// ScalarPair, and Vector layouts, so manually offset the pointer.
|
// ScalarPair, and Vector layouts, so manually offset the pointer.
|
||||||
bx.gep(bx.cx().type_i8(), self.llval, &[bx.const_usize(offset.bytes())])
|
bx.gep(bx.cx().type_i8(), self.llval, &[bx.const_usize(offset.bytes())])
|
||||||
}
|
}
|
||||||
Abi::Scalar(_) | Abi::ScalarPair(..) => {
|
Abi::Scalar(_) => {
|
||||||
// All fields of Scalar and ScalarPair layouts must have been handled by this point.
|
// All fields of Scalar layouts must have been handled by this point.
|
||||||
// Vector layouts have additional fields for each element of the vector, so don't panic in that case.
|
// Vector layouts have additional fields for each element of the vector, so don't panic in that case.
|
||||||
bug!(
|
bug!(
|
||||||
"offset of non-ZST field `{:?}` does not match layout `{:#?}`",
|
"offset of non-ZST field `{:?}` does not match layout `{:#?}`",
|
||||||
|
|
|
@ -22,7 +22,7 @@ pub fn scalar_layout(s: &(u64, ())) {
|
||||||
// CHECK-LABEL: @scalarpair_layout
|
// CHECK-LABEL: @scalarpair_layout
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub fn scalarpair_layout(s: &(u64, u32, ())) {
|
pub fn scalarpair_layout(s: &(u64, u32, ())) {
|
||||||
// CHECK: getelementptr i8, {{.+}}, [[USIZE]] 12
|
// CHECK: getelementptr inbounds i8, {{.+}}, [[USIZE]] 12
|
||||||
let x = &s.2;
|
let x = &s.2;
|
||||||
witness(&x); // keep variable in an alloca
|
witness(&x); // keep variable in an alloca
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue