Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
MemoryBuiltins: accept non-TLI funcs with attribs as allocator funcs
This allows us to accept annotations from out-of-tree languages (the example test is derived from Rust) so they can enjoy the benefits of LLVM's optimizations without requiring LLVM to have language-specific knowledge. Differential Revision: https://reviews.llvm.org/D123091
- Loading branch information
Showing
2 changed files
with
29 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
llvm/test/Transforms/InstCombine/out-of-tree-allocator-optimizes-away.ll
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
; 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){ | ||
; 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) | ||
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 void @__rust_dealloc(i8* allocptr, i64, i64) unnamed_addr nounwind nonlazybind uwtable allockind("free") "alloc-family"="__rust_alloc" |