[all-commits] [llvm/llvm-project] 740167: [DSE] Update dereferenceable attributes when adjus...
Björn Pettersson via All-commits
all-commits at lists.llvm.org
Tue Feb 18 08:51:38 PST 2025
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: 74016728e34ff4fcc6f0e0c412415cf70c2584e5
https://github.com/llvm/llvm-project/commit/74016728e34ff4fcc6f0e0c412415cf70c2584e5
Author: Björn Pettersson <bjorn.a.pettersson at ericsson.com>
Date: 2025-02-18 (Tue, 18 Feb 2025)
Changed paths:
M llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp
M llvm/test/Transforms/DeadStoreElimination/OverwriteStoreBegin.ll
Log Message:
-----------
[DSE] Update dereferenceable attributes when adjusting memintrinsic ptr (#125073)
Consider IR like this
call void @llvm.memset.p0.i64(ptr dereferenceable(28) %p, i8 0, i64 28,
i1 false)
store i32 1, ptr %p
In the past it has been optimized like this:
%p2 = getelementptr inbounds i8, ptr %p, i64 4
call void @llvm.memset.p0.i64(ptr dereferenceable(28) %p2, i8 0, i64 24,
i1 false)
store i32 1, ptr %p
As the input IR doesn't guarantee that it is OK to deref 28 bytes
starting at the adjusted pointer %p2 the transformation has been a bit
flawed.
With this patch we make sure to drop any
dereferenceable/dereferenceable_or_null attributes when doing such
transforms. An alternative would have been to adjust the amount of
dereferenceable bytes, but since a memset with a constant length already
implies dereferenceability by itself it is simpler to just drop the
attributes.
The new filtering of attributes is done using a helper that only keep
attributes that we explicitly handle. For the adjusted mem instrinsic
pointers that currently involve "NonNull", "NoUndef" and "Alignment"
(when the alignment is known to be fulfilled also after offsetting the
pointer).
Fixes #115976
To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications
More information about the All-commits
mailing list