[PATCH] D121415: [FunctionAttrs] Infer argmemonly .

Florian Hahn via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Mar 11 10:30:20 PST 2022


fhahn updated this revision to Diff 414695.
fhahn added a comment.
Herald added a subscriber: jeroen.dobbelaere.

In D121415#3373870 <https://reviews.llvm.org/D121415#3373870>, @nikic wrote:

> Just wondering whether integrating this into checkFunctionMemoryAccess() would make more sense? It already does all the ModRefBehavior queries, so I'd expect it to fit naturally.

Sounds good, I first wanted to see if there's any concerns with adding argmemonly in general here. Updated the code to integrate the logic in checkFunctionMemoryAccess.

I also updated the logic to to allow accesses to allocas in argmemonly functions.

In D121415#3375389 <https://reviews.llvm.org/D121415#3375389>, @reames wrote:

> Working backwards from each memory instruction seems potentially extremely expensive.  We could clearly do a forward walk to identify an OK set, then return false if any memory access is in that set.  Not sure the complexity is worth it though, have you run compile time measurements with this patch?
>
> The other benefit to the forward walk is that you could process the entire SCC at once, and have speculative membership in that set.

The compile-time impact was low for the original version:

  NewPM-O3: +0.01%
  NewPM-ReleaseThinLTO: +0.03%
  NewPM-ReleaseLTO+g: +0.05%

I now updated the code to integrate the checks in the existing checkFunctionMemoryAccess and the impact is similar (+0.02%, +0.04%, +0.04%). The updated version handles a few additional cases than the original one though. https://llvm-compile-time-tracker.com/compare.php?from=1d4268224bedfcbfefbf2c902c9b6417114a688d&to=0192ddd08f36f6b6e8a847d65a4f03a75eca71e6&stat=instructions

I'm not sure if we have access to memoryssa at this point, but MSSA could probably be used to avoid iterating over all instructions in a function.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D121415/new/

https://reviews.llvm.org/D121415

Files:
  llvm/lib/Transforms/IPO/FunctionAttrs.cpp
  llvm/test/Analysis/TypeBasedAliasAnalysis/functionattrs.ll
  llvm/test/Transforms/FunctionAttrs/argmemonly.ll
  llvm/test/Transforms/FunctionAttrs/atomic.ll
  llvm/test/Transforms/FunctionAttrs/nofree.ll
  llvm/test/Transforms/FunctionAttrs/nosync.ll
  llvm/test/Transforms/FunctionAttrs/stats.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D121415.414695.patch
Type: text/x-patch
Size: 18884 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220311/d05a25e4/attachment.bin>


More information about the llvm-commits mailing list