[InstCombine] Slightly extend alloc optimization test (NFC)
authorNikita Popov <npopov@redhat.com>
Fri, 22 Jul 2022 07:42:26 +0000 (09:42 +0200)
committerNikita Popov <npopov@redhat.com>
Fri, 22 Jul 2022 07:43:08 +0000 (09:43 +0200)
Also test realloc, and dead writes to the allocation.

llvm/test/Transforms/InstCombine/out-of-tree-allocator-optimizes-away.ll

index e02448b..f505eb1 100644 (file)
@@ -1,18 +1,22 @@
 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
 ; RUN: opt -S -passes=instcombine %s | FileCheck %s
 
-; Function Attrs: nonlazybind uwtable
-define void @alloc_elides_test(i32 %data){
+define void @alloc_elides_test(i32 %data) {
 ; CHECK-LABEL: @alloc_elides_test(
 ; CHECK-NEXT:  start:
 ; CHECK-NEXT:    ret void
 ;
 start:
-  %0 = tail call i8* @__rust_alloc(i64 4, i64 32)
-  tail call void @__rust_dealloc(i8* nonnull %0, i64 4, i64 32)
+  %alloc = call ptr @__rust_alloc(i64 4, i64 32)
+  store i32 0, ptr %alloc
+  %alloc2 = call ptr @__rust_realloc(ptr %alloc, i64 4, i64 32, i64 8)
+  store i32 1, ptr %alloc2
+  call void @__rust_dealloc(ptr %alloc2, i64 4, i64 32)
   ret void
 }
 
-declare noalias i8* @__rust_alloc(i64, i64 allocalign) unnamed_addr nounwind nonlazybind allocsize(0) uwtable allockind("alloc,uninitialized,aligned") "alloc-family"="__rust_alloc"
+declare noalias ptr @__rust_alloc(i64, i64 allocalign) nounwind allocsize(0) allockind("alloc,uninitialized,aligned") "alloc-family"="__rust_alloc"
 
-declare void @__rust_dealloc(i8* allocptr, i64, i64) unnamed_addr nounwind nonlazybind uwtable allockind("free") "alloc-family"="__rust_alloc"
+declare noalias ptr @__rust_realloc(ptr allocptr, i64, i64 allocalign, i64) nounwind allocsize(3) allockind("alloc,uninitialized,aligned") "alloc-family"="__rust_alloc"
+
+declare void @__rust_dealloc(ptr allocptr, i64, i64) nounwind allockind("free") "alloc-family"="__rust_alloc"