[llvm] 533706c - [InstCombine] Slightly extend alloc optimization test (NFC)

Nikita Popov via llvm-commits llvm-commits at lists.llvm.org
Fri Jul 22 00:43:16 PDT 2022


Author: Nikita Popov
Date: 2022-07-22T09:43:08+02:00
New Revision: 533706c969c70cac314dfd1ec966345ae3ec2d40

URL: https://github.com/llvm/llvm-project/commit/533706c969c70cac314dfd1ec966345ae3ec2d40
DIFF: https://github.com/llvm/llvm-project/commit/533706c969c70cac314dfd1ec966345ae3ec2d40.diff

LOG: [InstCombine] Slightly extend alloc optimization test (NFC)

Also test realloc, and dead writes to the allocation.

Added: 
    

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

Removed: 
    


################################################################################
diff  --git a/llvm/test/Transforms/InstCombine/out-of-tree-allocator-optimizes-away.ll b/llvm/test/Transforms/InstCombine/out-of-tree-allocator-optimizes-away.ll
index e02448bc70bc1..f505eb103d11a 100644
--- a/llvm/test/Transforms/InstCombine/out-of-tree-allocator-optimizes-away.ll
+++ b/llvm/test/Transforms/InstCombine/out-of-tree-allocator-optimizes-away.ll
@@ -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"


        


More information about the llvm-commits mailing list