diff options
author | Duncan Sands <baldrick@free.fr> | 2012-10-23 08:28:26 +0000 |
---|---|---|
committer | Duncan Sands <baldrick@free.fr> | 2012-10-23 08:28:26 +0000 |
commit | 533c8ae79f2974b4321110ace493ff41517ef420 (patch) | |
tree | 20b7abfd41ff52c141c9a4bb52fcb683f50cddfd /lldb/scripts/Python/python-wrapper.swig | |
parent | 500d87159bd2c1fc16c25a53530fcf8b82d97c78 (diff) | |
download | llvm-533c8ae79f2974b4321110ace493ff41517ef420.zip llvm-533c8ae79f2974b4321110ace493ff41517ef420.tar.gz llvm-533c8ae79f2974b4321110ace493ff41517ef420.tar.bz2 |
Transform code like this
%V = mul i64 %N, 4
%t = getelementptr i8* bitcast (i32* %arr to i8*), i32 %V
into
%t1 = getelementptr i32* %arr, i32 %N
%t = bitcast i32* %t1 to i8*
incorporating the multiplication into the getelementptr.
This happens all the time in dragonegg, for example for
int foo(int *A, int N) {
return A[N];
}
because gcc turns this into byte pointer arithmetic before it hits the plugin:
D.1590_2 = (long unsigned int) N_1(D);
D.1591_3 = D.1590_2 * 4;
D.1592_5 = A_4(D) + D.1591_3;
D.1589_6 = *D.1592_5;
return D.1589_6;
The D.1592_5 line is a POINTER_PLUS_EXPR, which is turned into a getelementptr
on a bitcast of A_4 to i8*, so this becomes exactly the kind of IR that the
transform fires on.
An analogous transform (with no testcases!) already existed for bitcasts of
arrays, so I rewrote it to share code with this one.
llvm-svn: 166474
Diffstat (limited to 'lldb/scripts/Python/python-wrapper.swig')
0 files changed, 0 insertions, 0 deletions