This is an archive of the discontinued LLVM Phabricator instance.

[OpaquePtr] add Type parameter to Loads.h analysis API.
ClosedPublic

Authored by t.p.northover on Jul 4 2019, 4:37 AM.

Details

Reviewers
dblaikie
Summary

As part of getting the rest of LLVM ready for opaque pointers, this adds a mandatory type/size argument to the analysis APIs in Loads.h (to avoid relying on V->getPointerElementType()).

Most callers already had a memory instruction locally they could use to provide this parameter, but two (SROA and ArgumentPromotion) were doing a more complicated analysis. I updated them to track the combined properties of the loads they are tracking.

Some of the logic is currently trivial (if one load has type T then all loads of that value will) but this implementation should be robust even when that's false and saves updating them twice.

Diff Detail

Event Timeline

t.p.northover created this revision.Jul 4 2019, 4:37 AM
Herald added a project: Restricted Project. · View Herald TranscriptJul 4 2019, 4:37 AM
dblaikie accepted this revision.Jul 8 2019, 4:09 PM

Looks good :)

llvm/lib/Transforms/IPO/ArgumentPromotion.cpp
599–603

I'd probably simplify this, eg:

Type *BaseTy = ByValTy;
if (BaseTy)
  SafeToUnconditionallyLoad.insert(...);

Or:

if (ByValTy)
  SafeToUnconditionallyLoad...

Type *BaseTy = ByValTy;

(I'd potentially declare BaseTy right before UpdateBaseTy - after the comment, since it's so closely connected to that lambda)

611–612

Drop the 'else' after return?

(& potentially invert the second condition to use an early return & reduce indentation:

if (BaseTy)
  return true;

BaseTy = NewBaseTy;
if (allCallers(...)) {
  ...
}

return true;
This revision is now accepted and ready to land.Jul 8 2019, 4:09 PM
t.p.northover marked an inline comment as done.Jul 9 2019, 4:35 AM

Thanks David. Committed with your suggestions as r365468.

llvm/lib/Transforms/IPO/ArgumentPromotion.cpp
611–612

I decided

if (BaseTy)
  return BaseTy == NewBaseTy;

was even better.

t.p.northover closed this revision.Jul 9 2019, 4:35 AM