[PATCH] D152241: [CaptureTracking] Do not capture compares of same object

Joshua Cao via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Jun 6 01:08:17 PDT 2023


caojoshua created this revision.
Herald added subscribers: JDevlieghere, hiraditya.
Herald added a project: All.
caojoshua added reviewers: nikic, goldstein.w.n.
Herald added a subscriber: StephenFan.
caojoshua updated this revision to Diff 528728.
caojoshua added a comment.
caojoshua updated this revision to Diff 528735.
caojoshua updated this revision to Diff 528736.
caojoshua edited the summary of this revision.
caojoshua published this revision for review.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

rebase


caojoshua added a comment.

@nikic could you try running compile time on this? Uploaded to https://github.com/caojoshua/llvm-project/tree/underlyingicmp.

I tried a couple runs locally. Last run saw this patch increase mean compile time of CTMark by +0.003%. I trust your runs more than the runs on my local machine.


caojoshua added a comment.

fix typo


caojoshua added a comment.

Update commit msg


Compares of the same object do not leak any bits.

This patch introduces getUnderlyingObjectLookThrough. It looks at the
output of getUnderlyingObject. If it is a PHI, it looks at all the
incoming underlying objects. If all those objects are the same, or the
original PHI, we determine that there is a new underlying object. This
is similar to getUnderlyingObjects, but provides a more efficient way to
find a single underlying object.

This is an attempt at solving huge compile time regressions in
https://reviews.llvm.org/D152082. First, we only look through a single
PHI, not nested PHIs. Second, we only use one callsite. There are likely
other callsites that could take advantage of this over the vanilla
getUnderlyingObjects. We need to be careful about compile times. Adding
this to BasicAA::aliasCheck increases compile times by 3% on local
builds.

This can hopefully lead to improved rustc generated code in
https://github.com/rust-lang/rust/issues/111603. rustc generates
pointers comparisons that this patch can identify as non capturing.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D152241

Files:
  llvm/include/llvm/Analysis/ValueTracking.h
  llvm/lib/Analysis/CaptureTracking.cpp
  llvm/lib/Analysis/ValueTracking.cpp
  llvm/test/Transforms/FunctionAttrs/nocapture.ll
  llvm/unittests/Analysis/CaptureTrackingTest.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D152241.528736.patch
Type: text/x-patch
Size: 5421 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230606/a4953aff/attachment.bin>


More information about the llvm-commits mailing list