diff options
author | Michael Kuperstein <mkuper@google.com> | 2016-05-25 22:23:08 +0000 |
---|---|---|
committer | Michael Kuperstein <mkuper@google.com> | 2016-05-25 22:23:08 +0000 |
commit | 82069c44ca39df9d506e16bfb0ca2481866dd0bb (patch) | |
tree | b7ce872b3abcd46e142898aab2e79dbe2dea031b /lldb/packages/Python/lldbsuite/test/functionalities/non-overlapping-index-variable-i/main.cpp | |
parent | 6ee02c7fce57b98dc4e0959e3b1c944d70f1ae49 (diff) | |
download | bcm5719-llvm-82069c44ca39df9d506e16bfb0ca2481866dd0bb.tar.gz bcm5719-llvm-82069c44ca39df9d506e16bfb0ca2481866dd0bb.zip |
[BasicAA] Improve precision of alloca vs. inbounds GEP alias queries
If a we have (a) a GEP and (b) a pointer based on an alloca, and the
beginning of the object the GEP points would have a negative offset with
repsect to the alloca, then the GEP can not alias pointer (b).
For example, consider code like:
struct { int f0, int f1, ...} foo;
...
foo alloca;
foo *random = bar(alloca);
int *f0 = &alloca.f0
int *f1 = &random->f1;
Which is lowered, approximately, to:
%alloca = alloca %struct.foo
%random = call %struct.foo* @random(%struct.foo* %alloca)
%f0 = getelementptr inbounds %struct, %struct.foo* %alloca, i32 0, i32 0
%f1 = getelementptr inbounds %struct, %struct.foo* %random, i32 0, i32 1
Assume %f1 and %f0 alias. Then %f1 would point into the object allocated
by %alloca. Since the %f1 GEP is inbounds, that means %random must also
point into the same object. But since %f0 points to the beginning of %alloca,
the highest %f1 can be is (%alloca + 3). This means %random can not be higher
than (%alloca - 1), and so is not inbounds, a contradiction.
Differential Revision: http://reviews.llvm.org/D20495
llvm-svn: 270777
Diffstat (limited to 'lldb/packages/Python/lldbsuite/test/functionalities/non-overlapping-index-variable-i/main.cpp')
0 files changed, 0 insertions, 0 deletions