This is an archive of the discontinued LLVM Phabricator instance.

[Attributor] Simplify loads
ClosedPublic

Authored by jdoerfert on Jun 7 2021, 5:00 PM.

Details

Summary

As a first step to simplify loads we only handle null and undef
underlying objects, as well as alloca instructions that have the load
as a single user. Loads of those values can be replaced by undef.
Proper reasoning is introduced in a follow up patch

Diff Detail

Event Timeline

jdoerfert created this revision.Jun 7 2021, 5:00 PM
jdoerfert requested review of this revision.Jun 7 2021, 5:00 PM
Herald added a project: Restricted Project. · View Herald TranscriptJun 7 2021, 5:00 PM
Herald added a subscriber: bbn. · View Herald Transcript
jdoerfert updated this revision to Diff 350458.Jun 7 2021, 5:19 PM

Put in a little more to reduce the follow up size

kuter added a comment.Jun 10 2021, 5:24 PM

The code for the AAPotentialValues and AAValueSimplify is the same. Maybe we could move this to a separate function with a callback for doing the unions ?

The code for the AAPotentialValues and AAValueSimplify is the same. Maybe we could move this to a separate function with a callback for doing the unions ?

There are more such opportunities. Will modify this code first though.

ormris removed a subscriber: ormris.Jun 11 2021, 2:50 PM
jdoerfert updated this revision to Diff 352614.Jun 16 2021, 8:20 PM

Introduc a helper

kuter added inline comments.Jun 27 2021, 10:33 AM
llvm/lib/Transforms/IPO/AttributorAttributes.cpp
4507

I don't understand why this case needs to be handled. I don't see how we would get something different from the getAssumedSimplified. getAssumedUnderlyingObjects just does genericValueTraversal and strips away casts.

jdoerfert added inline comments.Jun 27 2021, 12:17 PM
llvm/lib/Transforms/IPO/AttributorAttributes.cpp
4507

The problem is that the object might be null but the pointer is not.

p = nullptr; p[(intptr_t)q] = 1;
Uses a nullptr object and q as offset. The simplified pointer is not null but a gep (or q).
In this case we cannot ignore the object. We can only ignore p = nullptr; q = p[10]; q[-10] = 1; because the object and the simplified pointer (which is where the access happens) are both null.

kuter added a comment.Jul 4 2021, 5:43 PM

I think there was a mistake during rebase or we should abandon https://reviews.llvm.org/D104432

llvm/include/llvm/Transforms/IPO/Attributor.h
3888

Is AAPointerInfo supposed to be here ?

I think there was a mistake during rebase or we should abandon https://reviews.llvm.org/D104432

I smashed the two :(

I guess I have to untangle them again...

kuter added a comment.EditedJul 5 2021, 11:53 AM

Only this patch looks broken.
I think applying the D104432 in reverse should work.

jdoerfert updated this revision to Diff 357825.Jul 11 2021, 7:09 PM

Rebase without AAPointerInfo

kuter accepted this revision.Jul 12 2021, 4:30 PM

LGTM

This revision is now accepted and ready to land.Jul 12 2021, 4:30 PM
This revision was landed with ongoing or failed builds.Jul 19 2021, 8:50 PM
This revision was automatically updated to reflect the committed changes.