[Attributor] Track a GEP Instruction in align deduction
authorHideto Ueno <uenoku.tokotoko@gmail.com>
Tue, 26 Nov 2019 07:51:59 +0000 (07:51 +0000)
committerHideto Ueno <uenoku.tokotoko@gmail.com>
Tue, 26 Nov 2019 07:55:28 +0000 (07:55 +0000)
commit78a750276f442726193b007a0010432765abe9d4
tree860342977c1ae9747ee0ace3fcb3a509b2c79200
parent1b20908334847f4dc7b283f0493f4c59f1c62858
[Attributor] Track a GEP Instruction in align deduction

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.

Reviewers: jdoerfert, sstefan1

Reviewed By: jdoerfert

Subscribers: lebedev.ri, hiraditya, llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D70392
llvm/lib/Transforms/IPO/Attributor.cpp
llvm/test/Transforms/FunctionAttrs/align.ll
llvm/test/Transforms/FunctionAttrs/arg_nocapture.ll
llvm/test/Transforms/FunctionAttrs/nocapture.ll
llvm/test/Transforms/InferFunctionAttrs/dereferenceable.ll