diff options
author | clubby789 <jamie@hill-daniel.co.uk> | 2025-06-04 08:35:20 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-06-04 09:35:20 +0200 |
commit | c7c79d259025f0e5edf778a46e03aeb6affd7c73 (patch) | |
tree | f0066601438f302e6ce007d950fedc84db6ee16b /llvm/lib/IR/Attributes.cpp | |
parent | b3ce9883f32e3b5b16e2b5fa54c3d98e85b66869 (diff) | |
download | llvm-c7c79d259025f0e5edf778a46e03aeb6affd7c73.zip llvm-c7c79d259025f0e5edf778a46e03aeb6affd7c73.tar.gz llvm-c7c79d259025f0e5edf778a46e03aeb6affd7c73.tar.bz2 |
[IR][DSE] Support non-malloc functions in malloc+memset->calloc fold (#138299)
Add a `alloc-variant-zeroed` function attribute which can be used to
inform folding allocation+memset. This addresses
https://github.com/rust-lang/rust/issues/104847, where LLVM does not
know how to perform this transformation for non-C languages.
Co-authored-by: Jamie <jamie@osec.io>
Diffstat (limited to 'llvm/lib/IR/Attributes.cpp')
-rw-r--r-- | llvm/lib/IR/Attributes.cpp | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/llvm/lib/IR/Attributes.cpp b/llvm/lib/IR/Attributes.cpp index 5b0ceb3..ed485f9 100644 --- a/llvm/lib/IR/Attributes.cpp +++ b/llvm/lib/IR/Attributes.cpp @@ -300,6 +300,10 @@ Attribute::getWithAllocSizeArgs(LLVMContext &Context, unsigned ElemSizeArg, return get(Context, AllocSize, packAllocSizeArgs(ElemSizeArg, NumElemsArg)); } +Attribute Attribute::getWithAllocKind(LLVMContext &Context, AllocFnKind Kind) { + return get(Context, AllocKind, static_cast<uint64_t>(Kind)); +} + Attribute Attribute::getWithVScaleRangeArgs(LLVMContext &Context, unsigned MinValue, unsigned MaxValue) { |