diff options
| author | David Blaikie <dblaikie@gmail.com> | 2015-02-27 19:29:02 +0000 |
|---|---|---|
| committer | David Blaikie <dblaikie@gmail.com> | 2015-02-27 19:29:02 +0000 |
| commit | 79e6c74981f4755ed55b38175d8cd34ec91395b1 (patch) | |
| tree | 3e3d41d853795c46029a07c3fb78b1e2f7668185 /llvm/test/Analysis/CFLAliasAnalysis | |
| parent | bad3ff207f68e69f36b9a1f90a29f22341e505bb (diff) | |
| download | bcm5719-llvm-79e6c74981f4755ed55b38175d8cd34ec91395b1.tar.gz bcm5719-llvm-79e6c74981f4755ed55b38175d8cd34ec91395b1.zip | |
[opaque pointer type] Add textual IR support for explicit type parameter to getelementptr instruction
One of several parallel first steps to remove the target type of pointers,
replacing them with a single opaque pointer type.
This adds an explicit type parameter to the gep instruction so that when the
first parameter becomes an opaque pointer type, the type to gep through is
still available to the instructions.
* This doesn't modify gep operators, only instructions (operators will be
handled separately)
* Textual IR changes only. Bitcode (including upgrade) and changing the
in-memory representation will be in separate changes.
* geps of vectors are transformed as:
getelementptr <4 x float*> %x, ...
->getelementptr float, <4 x float*> %x, ...
Then, once the opaque pointer type is introduced, this will ultimately look
like:
getelementptr float, <4 x ptr> %x
with the unambiguous interpretation that it is a vector of pointers to float.
* address spaces remain on the pointer, not the type:
getelementptr float addrspace(1)* %x
->getelementptr float, float addrspace(1)* %x
Then, eventually:
getelementptr float, ptr addrspace(1) %x
Importantly, the massive amount of test case churn has been automated by
same crappy python code. I had to manually update a few test cases that
wouldn't fit the script's model (r228970,r229196,r229197,r229198). The
python script just massages stdin and writes the result to stdout, I
then wrapped that in a shell script to handle replacing files, then
using the usual find+xargs to migrate all the files.
update.py:
import fileinput
import sys
import re
ibrep = re.compile(r"(^.*?[^%\w]getelementptr inbounds )(((?:<\d* x )?)(.*?)(| addrspace\(\d\)) *\*(|>)(?:$| *(?:%|@|null|undef|blockaddress|getelementptr|addrspacecast|bitcast|inttoptr|\[\[[a-zA-Z]|\{\{).*$))")
normrep = re.compile( r"(^.*?[^%\w]getelementptr )(((?:<\d* x )?)(.*?)(| addrspace\(\d\)) *\*(|>)(?:$| *(?:%|@|null|undef|blockaddress|getelementptr|addrspacecast|bitcast|inttoptr|\[\[[a-zA-Z]|\{\{).*$))")
def conv(match, line):
if not match:
return line
line = match.groups()[0]
if len(match.groups()[5]) == 0:
line += match.groups()[2]
line += match.groups()[3]
line += ", "
line += match.groups()[1]
line += "\n"
return line
for line in sys.stdin:
if line.find("getelementptr ") == line.find("getelementptr inbounds"):
if line.find("getelementptr inbounds") != line.find("getelementptr inbounds ("):
line = conv(re.match(ibrep, line), line)
elif line.find("getelementptr ") != line.find("getelementptr ("):
line = conv(re.match(normrep, line), line)
sys.stdout.write(line)
apply.sh:
for name in "$@"
do
python3 `dirname "$0"`/update.py < "$name" > "$name.tmp" && mv "$name.tmp" "$name"
rm -f "$name.tmp"
done
The actual commands:
From llvm/src:
find test/ -name *.ll | xargs ./apply.sh
From llvm/src/tools/clang:
find test/ -name *.mm -o -name *.m -o -name *.cpp -o -name *.c | xargs -I '{}' ../../apply.sh "{}"
From llvm/src/tools/polly:
find test/ -name *.ll | xargs ./apply.sh
After that, check-all (with llvm, clang, clang-tools-extra, lld,
compiler-rt, and polly all checked out).
The extra 'rm' in the apply.sh script is due to a few files in clang's test
suite using interesting unicode stuff that my python script was throwing
exceptions on. None of those files needed to be migrated, so it seemed
sufficient to ignore those cases.
Reviewers: rafael, dexonsmith, grosser
Differential Revision: http://reviews.llvm.org/D7636
llvm-svn: 230786
Diffstat (limited to 'llvm/test/Analysis/CFLAliasAnalysis')
6 files changed, 18 insertions, 18 deletions
diff --git a/llvm/test/Analysis/CFLAliasAnalysis/const-expr-gep.ll b/llvm/test/Analysis/CFLAliasAnalysis/const-expr-gep.ll index 9ae200bc570..65d723e0f92 100644 --- a/llvm/test/Analysis/CFLAliasAnalysis/const-expr-gep.ll +++ b/llvm/test/Analysis/CFLAliasAnalysis/const-expr-gep.ll @@ -12,10 +12,10 @@ ; CHECK-NOT: May: define void @test() { - %D = getelementptr %T* @G, i64 0, i32 0 - %E = getelementptr %T* @G, i64 0, i32 1, i64 5 - %F = getelementptr i32* getelementptr (%T* @G, i64 0, i32 0), i64 0 - %X = getelementptr [10 x i8]* getelementptr (%T* @G, i64 0, i32 1), i64 0, i64 5 + %D = getelementptr %T, %T* @G, i64 0, i32 0 + %E = getelementptr %T, %T* @G, i64 0, i32 1, i64 5 + %F = getelementptr i32, i32* getelementptr (%T* @G, i64 0, i32 0), i64 0 + %X = getelementptr [10 x i8], [10 x i8]* getelementptr (%T* @G, i64 0, i32 1), i64 0, i64 5 ret void } diff --git a/llvm/test/Analysis/CFLAliasAnalysis/constant-over-index.ll b/llvm/test/Analysis/CFLAliasAnalysis/constant-over-index.ll index fb44b95d134..a8e00aaed37 100644 --- a/llvm/test/Analysis/CFLAliasAnalysis/constant-over-index.ll +++ b/llvm/test/Analysis/CFLAliasAnalysis/constant-over-index.ll @@ -10,13 +10,13 @@ define void @foo([3 x [3 x double]]* noalias %p) { entry: - %p3 = getelementptr [3 x [3 x double]]* %p, i64 0, i64 0, i64 3 + %p3 = getelementptr [3 x [3 x double]], [3 x [3 x double]]* %p, i64 0, i64 0, i64 3 br label %loop loop: %i = phi i64 [ 0, %entry ], [ %i.next, %loop ] - %p.0.i.0 = getelementptr [3 x [3 x double]]* %p, i64 0, i64 %i, i64 0 + %p.0.i.0 = getelementptr [3 x [3 x double]], [3 x [3 x double]]* %p, i64 0, i64 %i, i64 0 store volatile double 0.0, double* %p3 store volatile double 0.1, double* %p.0.i.0 diff --git a/llvm/test/Analysis/CFLAliasAnalysis/full-store-partial-alias.ll b/llvm/test/Analysis/CFLAliasAnalysis/full-store-partial-alias.ll index 21edfc276e6..245a0607be6 100644 --- a/llvm/test/Analysis/CFLAliasAnalysis/full-store-partial-alias.ll +++ b/llvm/test/Analysis/CFLAliasAnalysis/full-store-partial-alias.ll @@ -20,12 +20,12 @@ define i32 @signbit(double %x) nounwind { ; CHECK: ret i32 0 entry: %u = alloca %union.anon, align 8 - %tmp9 = getelementptr inbounds %union.anon* %u, i64 0, i32 0 + %tmp9 = getelementptr inbounds %union.anon, %union.anon* %u, i64 0, i32 0 store double %x, double* %tmp9, align 8, !tbaa !0 %tmp2 = load i32* bitcast (i64* @endianness_test to i32*), align 8, !tbaa !3 %idxprom = sext i32 %tmp2 to i64 %tmp4 = bitcast %union.anon* %u to [2 x i32]* - %arrayidx = getelementptr inbounds [2 x i32]* %tmp4, i64 0, i64 %idxprom + %arrayidx = getelementptr inbounds [2 x i32], [2 x i32]* %tmp4, i64 0, i64 %idxprom %tmp5 = load i32* %arrayidx, align 4, !tbaa !3 %tmp5.lobit = lshr i32 %tmp5, 31 ret i32 %tmp5.lobit diff --git a/llvm/test/Analysis/CFLAliasAnalysis/gep-signed-arithmetic.ll b/llvm/test/Analysis/CFLAliasAnalysis/gep-signed-arithmetic.ll index 19d251cbb53..eeb423740e6 100644 --- a/llvm/test/Analysis/CFLAliasAnalysis/gep-signed-arithmetic.ll +++ b/llvm/test/Analysis/CFLAliasAnalysis/gep-signed-arithmetic.ll @@ -10,7 +10,7 @@ define i32 @test(i32 %indvar) nounwind { %tab = alloca i32, align 4 %tmp31 = mul i32 %indvar, -2 %tmp32 = add i32 %tmp31, 30 - %t.5 = getelementptr i32* %tab, i32 %tmp32 + %t.5 = getelementptr i32, i32* %tab, i32 %tmp32 %loada = load i32* %tab store i32 0, i32* %t.5 %loadb = load i32* %tab diff --git a/llvm/test/Analysis/CFLAliasAnalysis/must-and-partial.ll b/llvm/test/Analysis/CFLAliasAnalysis/must-and-partial.ll index 163a6c348a1..bf1e66c9199 100644 --- a/llvm/test/Analysis/CFLAliasAnalysis/must-and-partial.ll +++ b/llvm/test/Analysis/CFLAliasAnalysis/must-and-partial.ll @@ -10,7 +10,7 @@ target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f3 define i8 @test0(i1 %x) { entry: %base = alloca i8, align 4 - %baseplusone = getelementptr i8* %base, i64 1 + %baseplusone = getelementptr i8, i8* %base, i64 1 br i1 %x, label %red, label %green red: br label %green @@ -30,7 +30,7 @@ green: define i8 @test1(i1 %x) { entry: %base = alloca i8, align 4 - %baseplusone = getelementptr i8* %base, i64 1 + %baseplusone = getelementptr i8, i8* %base, i64 1 %sel = select i1 %x, i8* %baseplusone, i8* %base store i8 0, i8* %sel @@ -45,9 +45,9 @@ entry: ; even if they are nocapture ; CHECK: MayAlias: double* %A, double* %Index define void @testr2(double* nocapture readonly %A, double* nocapture readonly %Index) { - %arrayidx22 = getelementptr inbounds double* %Index, i64 2 + %arrayidx22 = getelementptr inbounds double, double* %Index, i64 2 %1 = load double* %arrayidx22 - %arrayidx25 = getelementptr inbounds double* %A, i64 2 + %arrayidx25 = getelementptr inbounds double, double* %A, i64 2 %2 = load double* %arrayidx25 %mul26 = fmul double %1, %2 ret void diff --git a/llvm/test/Analysis/CFLAliasAnalysis/simple.ll b/llvm/test/Analysis/CFLAliasAnalysis/simple.ll index 7bc455ae7a2..adc71867bfc 100644 --- a/llvm/test/Analysis/CFLAliasAnalysis/simple.ll +++ b/llvm/test/Analysis/CFLAliasAnalysis/simple.ll @@ -9,10 +9,10 @@ ; CHECK-NOT: May: define void @test(%T* %P) { - %A = getelementptr %T* %P, i64 0 - %B = getelementptr %T* %P, i64 0, i32 0 - %C = getelementptr %T* %P, i64 0, i32 1 - %D = getelementptr %T* %P, i64 0, i32 1, i64 0 - %E = getelementptr %T* %P, i64 0, i32 1, i64 5 + %A = getelementptr %T, %T* %P, i64 0 + %B = getelementptr %T, %T* %P, i64 0, i32 0 + %C = getelementptr %T, %T* %P, i64 0, i32 1 + %D = getelementptr %T, %T* %P, i64 0, i32 1, i64 0 + %E = getelementptr %T, %T* %P, i64 0, i32 1, i64 5 ret void } |

