Also use gep inbounds nuw for index projections
This commit is contained in:
parent
31cc4c074d
commit
9e7b1847dc
2 changed files with 3 additions and 3 deletions
|
@ -423,7 +423,7 @@ impl<'a, 'tcx, V: CodegenObject> PlaceRef<'tcx, V> {
|
||||||
layout.size
|
layout.size
|
||||||
};
|
};
|
||||||
|
|
||||||
let llval = bx.inbounds_gep(bx.cx().backend_type(layout), self.val.llval, &[llindex]);
|
let llval = bx.inbounds_nuw_gep(bx.cx().backend_type(layout), self.val.llval, &[llindex]);
|
||||||
let align = self.val.align.restrict_for_offset(offset);
|
let align = self.val.align.restrict_for_offset(offset);
|
||||||
PlaceValue::new_sized(llval, align).with_type(layout)
|
PlaceValue::new_sized(llval, align).with_type(layout)
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,7 +11,7 @@ struct Foo(i32, i32);
|
||||||
// CHECK-LABEL: @index_on_struct(
|
// CHECK-LABEL: @index_on_struct(
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
fn index_on_struct(a: &[Foo], index: usize) -> &Foo {
|
fn index_on_struct(a: &[Foo], index: usize) -> &Foo {
|
||||||
// CHECK: getelementptr inbounds %Foo, ptr %a.0, {{i64|i32}} %index
|
// CHECK: getelementptr inbounds{{( nuw)?}} %Foo, ptr %a.0, {{i64|i32}} %index
|
||||||
&a[index]
|
&a[index]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -25,7 +25,7 @@ fn offset_on_struct(a: *const Foo, index: usize) -> *const Foo {
|
||||||
// CHECK-LABEL: @index_on_i32(
|
// CHECK-LABEL: @index_on_i32(
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
fn index_on_i32(a: &[i32], index: usize) -> &i32 {
|
fn index_on_i32(a: &[i32], index: usize) -> &i32 {
|
||||||
// CHECK: getelementptr inbounds i32, ptr %a.0, {{i64|i32}} %index
|
// CHECK: getelementptr inbounds{{( nuw)?}} i32, ptr %a.0, {{i64|i32}} %index
|
||||||
&a[index]
|
&a[index]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue