about summary refs log tree commit diff
path: root/tests/codegen
diff options
context:
space:
mode:
authorNikita Popov <npopov@redhat.com>2025-02-19 11:06:11 +0100
committerNikita Popov <npopov@redhat.com>2025-02-19 11:32:32 +0100
commit31cc4c074d9df22110daa59d8f5486ae02bac3bd (patch)
tree87805ff6b65f543402be362593e39acb64927554 /tests/codegen
parent5e9d8a7d55fbf1771d1b83ff2f15bdc75c9216d8 (diff)
downloadrust-31cc4c074d9df22110daa59d8f5486ae02bac3bd.tar.gz
rust-31cc4c074d9df22110daa59d8f5486ae02bac3bd.zip
Emit getelementptr inbounds nuw for pointer::add()
Diffstat (limited to 'tests/codegen')
-rw-r--r--tests/codegen/gep-index.rs4
-rw-r--r--tests/codegen/intrinsics/offset.rs2
-rw-r--r--tests/codegen/intrinsics/ptr_metadata.rs2
-rw-r--r--tests/codegen/ptr-arithmetic.rs2
4 files changed, 5 insertions, 5 deletions
diff --git a/tests/codegen/gep-index.rs b/tests/codegen/gep-index.rs
index 1f5e8855910..6b45692bea1 100644
--- a/tests/codegen/gep-index.rs
+++ b/tests/codegen/gep-index.rs
@@ -18,7 +18,7 @@ fn index_on_struct(a: &[Foo], index: usize) -> &Foo {
 // CHECK-LABEL: @offset_on_struct(
 #[no_mangle]
 fn offset_on_struct(a: *const Foo, index: usize) -> *const Foo {
-    // CHECK: getelementptr inbounds %Foo, ptr %a, {{i64|i32}} %index
+    // CHECK: getelementptr inbounds{{( nuw)?}} %Foo, ptr %a, {{i64|i32}} %index
     unsafe { a.add(index) }
 }
 
@@ -32,6 +32,6 @@ fn index_on_i32(a: &[i32], index: usize) -> &i32 {
 // CHECK-LABEL: @offset_on_i32(
 #[no_mangle]
 fn offset_on_i32(a: *const i32, index: usize) -> *const i32 {
-    // CHECK: getelementptr inbounds i32, ptr %a, {{i64|i32}} %index
+    // CHECK: getelementptr inbounds{{( nuw)?}} i32, ptr %a, {{i64|i32}} %index
     unsafe { a.add(index) }
 }
diff --git a/tests/codegen/intrinsics/offset.rs b/tests/codegen/intrinsics/offset.rs
index d76d3e705ab..cf0c7c7ac7d 100644
--- a/tests/codegen/intrinsics/offset.rs
+++ b/tests/codegen/intrinsics/offset.rs
@@ -27,7 +27,7 @@ pub unsafe fn offset_isize(p: *const u32, d: isize) -> *const u32 {
 // CHECK-SAME: (ptr noundef %p, [[SIZE]] noundef %d)
 #[no_mangle]
 pub unsafe fn offset_usize(p: *const u64, d: usize) -> *const u64 {
-    // CHECK: %[[R:.*]] = getelementptr inbounds i64, ptr %p, [[SIZE]] %d
+    // CHECK: %[[R:.*]] = getelementptr inbounds{{( nuw)?}} i64, ptr %p, [[SIZE]] %d
     // CHECK-NEXT: ret ptr %[[R]]
     offset(p, d)
 }
diff --git a/tests/codegen/intrinsics/ptr_metadata.rs b/tests/codegen/intrinsics/ptr_metadata.rs
index 87a32fa3d24..044dbc20486 100644
--- a/tests/codegen/intrinsics/ptr_metadata.rs
+++ b/tests/codegen/intrinsics/ptr_metadata.rs
@@ -28,7 +28,7 @@ pub unsafe fn dyn_byte_offset(
     p: *const dyn std::fmt::Debug,
     n: usize,
 ) -> *const dyn std::fmt::Debug {
-    // CHECK: %[[Q:.+]] = getelementptr inbounds i8, ptr %p.0, i64 %n
+    // CHECK: %[[Q:.+]] = getelementptr inbounds{{( nuw)?}} i8, ptr %p.0, i64 %n
     // CHECK: %[[TEMP1:.+]] = insertvalue { ptr, ptr } poison, ptr %[[Q]], 0
     // CHECK: %[[TEMP2:.+]] = insertvalue { ptr, ptr } %[[TEMP1]], ptr %p.1, 1
     // CHECK: ret { ptr, ptr } %[[TEMP2]]
diff --git a/tests/codegen/ptr-arithmetic.rs b/tests/codegen/ptr-arithmetic.rs
index ecb44b30f5c..fc4441ef448 100644
--- a/tests/codegen/ptr-arithmetic.rs
+++ b/tests/codegen/ptr-arithmetic.rs
@@ -6,7 +6,7 @@
 // CHECK-SAME: [[WORD:i[0-9]+]] noundef %n)
 #[no_mangle]
 pub unsafe fn i32_add(p: *const i32, n: usize) -> *const i32 {
-    // CHECK: %[[TEMP:.+]] = getelementptr inbounds i32, ptr %p, [[WORD]] %n
+    // CHECK: %[[TEMP:.+]] = getelementptr inbounds{{( nuw)?}} i32, ptr %p, [[WORD]] %n
     // CHECK: ret ptr %[[TEMP]]
     p.add(n)
 }