[llvm] [InstCombine] Add user-count bailout to isAllocSiteRemovable (PR #190347)
Yingwei Zheng via llvm-commits
llvm-commits at lists.llvm.org
Sun Apr 5 11:56:54 PDT 2026
================
@@ -3922,8 +3932,25 @@ Instruction *InstCombinerImpl::visitAllocSite(Instruction &MI) {
F.hasFnAttribute(Attribute::SanitizeAddress))
KnowInitUndef = false;
+ // Skip alloc sites with many direct users -- they are almost never removable
+ // and the transitive user walk in isAllocSiteRemovable is expensive.
+ {
+ unsigned DirectUserCount = 0;
+ for (auto UI = MI.user_begin(), UE = MI.user_end(); UI != UE; ++UI) {
+ if (++DirectUserCount > MaxAllocSiteRemovableUsers)
+ break;
+ }
+ if (DirectUserCount > MaxAllocSiteRemovableUsers)
+ return nullptr;
+ }
----------------
dtcxzyw wrote:
```suggestion
if (MI.hasNUsesOrMore(MaxAllocSiteRemovableUsers))
return nullptr;
```
https://github.com/llvm/llvm-project/pull/190347
More information about the llvm-commits
mailing list