Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions compiler/rustc_codegen_llvm/src/abi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,11 @@ fn get_attrs<'ll>(this: &ArgAttributes, cx: &CodegenCx<'ll, '_>) -> SmallVec<[&'
// Only apply remaining attributes when optimizing
if cx.sess().opts.optimize != config::OptLevel::No {
let deref = this.pointee_size.bytes();
// dereferenceable in LLVM currently implies nofree, so only emit dereferenceable if nofree
// Prior to <https://github.com/llvm/llvm-project/pull/204795> dereferenceable in LLVM
// implied nofree, so only emit dereferenceable on older versions of LLVM if nofree
// is also set.
if deref != 0 && regular.contains(ArgAttribute::NoFree) {
let llvm_version = crate::llvm_util::get_version();
if deref != 0 && (llvm_version >= (23, 0, 0) || regular.contains(ArgAttribute::NoFree)) {
if regular.contains(ArgAttribute::NonNull) {
attrs.push(llvm::CreateDereferenceableAttr(cx.llcx, deref));
} else {
Expand Down
Loading