Skip to content

Commit 8e64fc9

Browse files
committed
Address review comments
1 parent c2fd26a commit 8e64fc9

File tree

3 files changed

+6
-9
lines changed

3 files changed

+6
-9
lines changed

compiler/rustc_codegen_llvm/src/type_of.rs

-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ fn uncached_llvm_type<'a, 'tcx>(
2626
let element = layout.scalar_llvm_type_at(cx, element);
2727
return cx.type_vector(element, count);
2828
}
29-
// Treat ScalarPair like a normal aggregate for the purposes of in-memory representation.
3029
Abi::Uninhabited | Abi::Aggregate { .. } | Abi::ScalarPair(..) => {}
3130
}
3231

compiler/rustc_codegen_ssa/src/mir/place.rs

+5-7
Original file line numberDiff line numberDiff line change
@@ -108,19 +108,17 @@ impl<'a, 'tcx, V: CodegenObject> PlaceRef<'tcx, V> {
108108
// Also handles the first field of Scalar, ScalarPair, and Vector layouts.
109109
self.llval
110110
}
111-
Abi::ScalarPair(a, b)
112-
if offset == a.size(bx.cx()).align_to(b.align(bx.cx()).abi) =>
113-
{
114-
// Offset matches second field.
111+
Abi::ScalarPair(..) => {
112+
// FIXME(nikic): Generate this for all ABIs.
115113
bx.inbounds_gep(bx.type_i8(), self.llval, &[bx.const_usize(offset.bytes())])
116114
}
117-
Abi::Scalar(_) | Abi::ScalarPair(..) | Abi::Vector { .. } if field.is_zst() => {
115+
Abi::Scalar(_) | Abi::Vector { .. } if field.is_zst() => {
118116
// ZST fields (even some that require alignment) are not included in Scalar,
119117
// ScalarPair, and Vector layouts, so manually offset the pointer.
120118
bx.gep(bx.cx().type_i8(), self.llval, &[bx.const_usize(offset.bytes())])
121119
}
122-
Abi::Scalar(_) | Abi::ScalarPair(..) => {
123-
// All fields of Scalar and ScalarPair layouts must have been handled by this point.
120+
Abi::Scalar(_) => {
121+
// All fields of Scalar layouts must have been handled by this point.
124122
// Vector layouts have additional fields for each element of the vector, so don't panic in that case.
125123
bug!(
126124
"offset of non-ZST field `{:?}` does not match layout `{:#?}`",

tests/codegen/zst-offset.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ pub fn scalar_layout(s: &(u64, ())) {
2222
// CHECK-LABEL: @scalarpair_layout
2323
#[no_mangle]
2424
pub fn scalarpair_layout(s: &(u64, u32, ())) {
25-
// CHECK: getelementptr i8, {{.+}}, [[USIZE]] 12
25+
// CHECK: getelementptr inbounds i8, {{.+}}, [[USIZE]] 12
2626
let x = &s.2;
2727
witness(&x); // keep variable in an alloca
2828
}

0 commit comments

Comments
 (0)