This is an archive of the discontinued LLVM Phabricator instance.

[Attributor] Track a GEP Instruction in align deduction
ClosedPublic

Authored by uenoku on Nov 18 2019, 5:49 AM.

Details

Summary

This patch enables us to track GEP instruction in align deduction.
If a pointer B is defined as A+Offset and known to have alignment C, there exists some integer Q such that

A + Offset = C * Q = B

So we can say that the maximum power of two which is a divisor of gcd(Offset, C) is an alignment.

Diff Detail

Event Timeline

uenoku created this revision.Nov 18 2019, 5:49 AM
Herald added a project: Restricted Project. · View Herald TranscriptNov 18 2019, 5:49 AM
lebedev.ri added inline comments.
llvm/test/Transforms/FunctionAttrs/align.ll
352–359

Is there test coverage where this is a store instead of load,
and maybe there is a call to a function that expects certain aliment of it's pointer argument?

uenoku updated this revision to Diff 229839.Nov 18 2019, 7:08 AM

Fix a call handling and add tests for store and calls.

uenoku marked an inline comment as done.Nov 18 2019, 7:10 AM
uenoku added inline comments.
llvm/test/Transforms/FunctionAttrs/align.ll
352–359

Thank you for the comment. I added tests for store(12-3, 12-4) and call(12-5, 12-6).

Looks fine from my side. @lebedev.ri please feel free to comment and please accept once satisfied.

Looks fine from my side. @lebedev.ri please feel free to comment and please accept once satisfied.

No further comments from me; i'm not really familiar with the code in question to review.

jdoerfert accepted this revision.Nov 25 2019, 10:10 AM
This revision is now accepted and ready to land.Nov 25 2019, 10:10 AM
This revision was automatically updated to reflect the committed changes.