[InstCombine] Slightly extend alloc optimization test (NFC)

Also test realloc, and dead writes to the allocation.
This commit is contained in:
Nikita Popov 2022-07-22 09:42:26 +02:00
parent afda39a566
commit 533706c969
1 changed files with 10 additions and 6 deletions

View 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"