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/Transforms/LoopUnswitch | |
| 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/Transforms/LoopUnswitch')
5 files changed, 6 insertions, 6 deletions
diff --git a/llvm/test/Transforms/LoopUnswitch/2007-07-18-DomInfo.ll b/llvm/test/Transforms/LoopUnswitch/2007-07-18-DomInfo.ll index dfca15403bf..c01bed142fc 100644 --- a/llvm/test/Transforms/LoopUnswitch/2007-07-18-DomInfo.ll +++ b/llvm/test/Transforms/LoopUnswitch/2007-07-18-DomInfo.ll @@ -52,7 +52,7 @@ cond_next1929: ; preds = %cond_next1915 br i1 false, label %cond_next1961, label %cond_next2009 cond_next1961: ; preds = %cond_next1929 - %tmp1992 = getelementptr i8* %b.10.ph, i32 0 ; <i8*> [#uses=0] + %tmp1992 = getelementptr i8, i8* %b.10.ph, i32 0 ; <i8*> [#uses=0] br label %cond_next1915 cond_next2009: ; preds = %cond_next1929 diff --git a/llvm/test/Transforms/LoopUnswitch/2011-09-26-EHCrash.ll b/llvm/test/Transforms/LoopUnswitch/2011-09-26-EHCrash.ll index e8feef383b0..5717dd89e2f 100644 --- a/llvm/test/Transforms/LoopUnswitch/2011-09-26-EHCrash.ll +++ b/llvm/test/Transforms/LoopUnswitch/2011-09-26-EHCrash.ll @@ -22,8 +22,8 @@ for.body: ; preds = %for.cond if.then: ; preds = %for.body %idxprom = sext i32 %inc1 to i64 - %array_ = getelementptr inbounds %class.MyContainer.1.3.19.29* %this, i32 0, i32 0 - %arrayidx = getelementptr inbounds [6 x %class.MyMemVarClass.0.2.18.28*]* %array_, i32 0, i64 %idxprom + %array_ = getelementptr inbounds %class.MyContainer.1.3.19.29, %class.MyContainer.1.3.19.29* %this, i32 0, i32 0 + %arrayidx = getelementptr inbounds [6 x %class.MyMemVarClass.0.2.18.28*], [6 x %class.MyMemVarClass.0.2.18.28*]* %array_, i32 0, i64 %idxprom %tmp4 = load %class.MyMemVarClass.0.2.18.28** %arrayidx, align 8 %isnull = icmp eq %class.MyMemVarClass.0.2.18.28* %tmp4, null br i1 %isnull, label %for.inc, label %delete.notnull diff --git a/llvm/test/Transforms/LoopUnswitch/2012-04-30-LoopUnswitch-LPad-Crash.ll b/llvm/test/Transforms/LoopUnswitch/2012-04-30-LoopUnswitch-LPad-Crash.ll index a6c0d83484b..80e4d782731 100644 --- a/llvm/test/Transforms/LoopUnswitch/2012-04-30-LoopUnswitch-LPad-Crash.ll +++ b/llvm/test/Transforms/LoopUnswitch/2012-04-30-LoopUnswitch-LPad-Crash.ll @@ -47,7 +47,7 @@ entry: %this.addr = alloca %class.D.22.42.66.102.138.158.178.198.238.242.246.250.262.294.302.338.346.379*, align 8 store %class.D.22.42.66.102.138.158.178.198.238.242.246.250.262.294.302.338.346.379* %this, %class.D.22.42.66.102.138.158.178.198.238.242.246.250.262.294.302.338.346.379** %this.addr, align 8 %this1 = load %class.D.22.42.66.102.138.158.178.198.238.242.246.250.262.294.302.338.346.379** %this.addr - %px = getelementptr inbounds %class.D.22.42.66.102.138.158.178.198.238.242.246.250.262.294.302.338.346.379* %this1, i32 0, i32 0 + %px = getelementptr inbounds %class.D.22.42.66.102.138.158.178.198.238.242.246.250.262.294.302.338.346.379, %class.D.22.42.66.102.138.158.178.198.238.242.246.250.262.294.302.338.346.379* %this1, i32 0, i32 0 %0 = load %class.C.23.43.67.103.139.159.179.199.239.243.247.251.263.295.303.339.347.376** %px, align 8 %tobool = icmp ne %class.C.23.43.67.103.139.159.179.199.239.243.247.251.263.295.303.339.347.376* %0, null br i1 %tobool, label %cond.end, label %cond.false diff --git a/llvm/test/Transforms/LoopUnswitch/basictest.ll b/llvm/test/Transforms/LoopUnswitch/basictest.ll index 85e44eca9b6..2a0f5a5abb1 100644 --- a/llvm/test/Transforms/LoopUnswitch/basictest.ll +++ b/llvm/test/Transforms/LoopUnswitch/basictest.ll @@ -6,7 +6,7 @@ entry: no_exit: ; preds = %no_exit.backedge, %entry %i.0.0 = phi i32 [ 0, %entry ], [ %i.0.0.be, %no_exit.backedge ] ; <i32> [#uses=3] %gep.upgrd.1 = zext i32 %i.0.0 to i64 ; <i64> [#uses=1] - %tmp.7 = getelementptr i32* %A, i64 %gep.upgrd.1 ; <i32*> [#uses=4] + %tmp.7 = getelementptr i32, i32* %A, i64 %gep.upgrd.1 ; <i32*> [#uses=4] %tmp.13 = load i32* %tmp.7 ; <i32> [#uses=2] %tmp.14 = add i32 %tmp.13, 1 ; <i32> [#uses=1] store i32 %tmp.14, i32* %tmp.7 diff --git a/llvm/test/Transforms/LoopUnswitch/preserve-analyses.ll b/llvm/test/Transforms/LoopUnswitch/preserve-analyses.ll index f79612bef51..2725745ea60 100644 --- a/llvm/test/Transforms/LoopUnswitch/preserve-analyses.ll +++ b/llvm/test/Transforms/LoopUnswitch/preserve-analyses.ll @@ -20,7 +20,7 @@ bb: ; preds = %bb8 br i1 %2, label %bb10, label %bb2 bb2: ; preds = %bb - %3 = getelementptr inbounds i8* %p_addr.0, i32 1 ; <i8*> [#uses=3] + %3 = getelementptr inbounds i8, i8* %p_addr.0, i32 1 ; <i8*> [#uses=3] switch i32 %ineq.0.ph, label %bb8.backedge [ i32 0, label %bb3 i32 1, label %bb6 |

