[llvm] [DSE] Consider the aliasing through global variable while checking clobber (PR #120044)
Haopeng Liu via llvm-commits
llvm-commits at lists.llvm.org
Sat Dec 21 12:27:47 PST 2024
================
@@ -1665,11 +1665,16 @@ struct DSEState {
// original MD. Stop walk.
// If KillingDef is a CallInst with "initializes" attribute, the reads in
// the callee would be dominated by initializations, so it should be safe.
+ // Note that in `getInitializesArgMemLoc`, we only check the aliasing
+ // among arguments. If aliasing through global variables, we consider it
+ // as read clobber.
bool IsKillingDefFromInitAttr = false;
if (IsInitializesAttrMemLoc) {
- if (KillingI == UseInst &&
- KillingUndObj == getUnderlyingObject(MaybeDeadLoc.Ptr))
- IsKillingDefFromInitAttr = true;
+ if (auto *CB = dyn_cast<CallBase>(UseInst))
+ IsKillingDefFromInitAttr =
+ KillingI == UseInst &&
+ KillingUndObj == getUnderlyingObject(MaybeDeadLoc.Ptr) &&
+ CB->onlyAccessesInaccessibleMemOrArgMem();
----------------
haopliu wrote:
Moved this check to inside `getInitializesArgMemLoc`. Thanks!
https://github.com/llvm/llvm-project/pull/120044
More information about the llvm-commits
mailing list