2009-09-12 02:01:28 +08:00
|
|
|
; RUN: opt < %s -adce -disable-output
|
2016-12-14 00:42:18 +08:00
|
|
|
; RUN: opt < %s -adce -adce-remove-loops=true -disable-output
|
|
|
|
|
2008-03-01 17:15:35 +08:00
|
|
|
target datalayout = "e-p:32:32"
|
|
|
|
%struct..CppObjTypeDesc = type { i32, i16, i16 }
|
|
|
|
%struct..TypeToken = type { i32, i16, i16 }
|
2003-06-25 06:58:05 +08:00
|
|
|
|
2008-03-01 17:15:35 +08:00
|
|
|
define i32 @C_ReFaxToDb() {
|
|
|
|
entry:
|
|
|
|
br i1 false, label %endif.0, label %then.0
|
2003-06-25 06:58:05 +08:00
|
|
|
|
|
|
|
then.0: ; preds = %entry
|
2008-03-01 17:15:35 +08:00
|
|
|
ret i32 0
|
2003-06-25 06:58:05 +08:00
|
|
|
|
|
|
|
endif.0: ; preds = %entry
|
2008-03-01 17:15:35 +08:00
|
|
|
br i1 false, label %then.11, label %then.4
|
2003-06-25 06:58:05 +08:00
|
|
|
|
|
|
|
then.4: ; preds = %endif.0
|
2008-03-01 17:15:35 +08:00
|
|
|
ret i32 0
|
2003-06-25 06:58:05 +08:00
|
|
|
|
|
|
|
then.11: ; preds = %endif.0
|
2008-03-01 17:15:35 +08:00
|
|
|
br i1 false, label %loopentry.0, label %else.2
|
2003-06-25 06:58:05 +08:00
|
|
|
|
2008-03-01 17:15:35 +08:00
|
|
|
loopentry.0: ; preds = %loopentry.1, %endif.14, %then.11
|
|
|
|
br i1 false, label %endif.14, label %loopexit.0
|
2003-06-25 06:58:05 +08:00
|
|
|
|
|
|
|
endif.14: ; preds = %loopentry.0
|
2008-03-01 17:15:35 +08:00
|
|
|
br i1 false, label %loopentry.1, label %loopentry.0
|
2003-06-25 06:58:05 +08:00
|
|
|
|
2008-03-01 17:15:35 +08:00
|
|
|
loopentry.1: ; preds = %then.53, %endif.14
|
|
|
|
%SubArrays.10 = phi i32* [ %SubArrays.8, %then.53 ], [ null, %endif.14 ] ; <i32*> [#uses=3]
|
|
|
|
br i1 false, label %no_exit.1, label %loopentry.0
|
2003-06-25 06:58:05 +08:00
|
|
|
|
|
|
|
no_exit.1: ; preds = %loopentry.1
|
2016-12-14 00:42:18 +08:00
|
|
|
; CHECK: switch
|
2008-03-01 17:15:35 +08:00
|
|
|
switch i32 0, label %label.17 [
|
|
|
|
i32 2, label %label.11
|
|
|
|
i32 19, label %label.10
|
2003-06-25 06:58:05 +08:00
|
|
|
]
|
|
|
|
|
|
|
|
label.10: ; preds = %no_exit.1
|
2008-03-01 17:15:35 +08:00
|
|
|
br i1 false, label %then.43, label %endif.43
|
2003-06-25 06:58:05 +08:00
|
|
|
|
|
|
|
then.43: ; preds = %label.10
|
2008-03-01 17:15:35 +08:00
|
|
|
br i1 false, label %then.44, label %endif.44
|
2003-06-25 06:58:05 +08:00
|
|
|
|
|
|
|
then.44: ; preds = %then.43
|
2008-03-01 17:15:35 +08:00
|
|
|
br i1 false, label %shortcirc_next.4, label %endif.45
|
2003-06-25 06:58:05 +08:00
|
|
|
|
|
|
|
shortcirc_next.4: ; preds = %then.44
|
2008-03-01 17:15:35 +08:00
|
|
|
br i1 false, label %no_exit.2, label %loopexit.2
|
2003-06-25 06:58:05 +08:00
|
|
|
|
|
|
|
no_exit.2: ; preds = %shortcirc_next.4
|
[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
2015-02-28 03:29:02 +08:00
|
|
|
%tmp.897 = getelementptr i32, i32* %SubArrays.10, i64 0 ; <i32*> [#uses=1]
|
2015-02-28 05:17:42 +08:00
|
|
|
%tmp.899 = load i32, i32* %tmp.897 ; <i32> [#uses=1]
|
2008-03-01 17:15:35 +08:00
|
|
|
store i32 %tmp.899, i32* null
|
|
|
|
ret i32 0
|
2003-06-25 06:58:05 +08:00
|
|
|
|
|
|
|
loopexit.2: ; preds = %shortcirc_next.4
|
2008-03-01 17:15:35 +08:00
|
|
|
ret i32 0
|
2003-06-25 06:58:05 +08:00
|
|
|
|
|
|
|
endif.45: ; preds = %then.44
|
2008-03-01 17:15:35 +08:00
|
|
|
ret i32 0
|
2003-06-25 06:58:05 +08:00
|
|
|
|
|
|
|
endif.44: ; preds = %then.43
|
2008-03-01 17:15:35 +08:00
|
|
|
ret i32 0
|
2003-06-25 06:58:05 +08:00
|
|
|
|
|
|
|
endif.43: ; preds = %label.10
|
2008-03-01 17:15:35 +08:00
|
|
|
ret i32 0
|
2003-06-25 06:58:05 +08:00
|
|
|
|
|
|
|
label.11: ; preds = %no_exit.1
|
2008-03-01 17:15:35 +08:00
|
|
|
ret i32 0
|
2003-06-25 06:58:05 +08:00
|
|
|
|
2008-03-01 17:15:35 +08:00
|
|
|
label.17: ; preds = %no_exit.1
|
|
|
|
br i1 false, label %then.53, label %shortcirc_next.7
|
2003-06-25 06:58:05 +08:00
|
|
|
|
|
|
|
shortcirc_next.7: ; preds = %label.17
|
2008-03-01 17:15:35 +08:00
|
|
|
br i1 false, label %then.53, label %shortcirc_next.8
|
2003-06-25 06:58:05 +08:00
|
|
|
|
|
|
|
shortcirc_next.8: ; preds = %shortcirc_next.7
|
2008-03-01 17:15:35 +08:00
|
|
|
ret i32 0
|
2003-06-25 06:58:05 +08:00
|
|
|
|
|
|
|
then.53: ; preds = %shortcirc_next.7, %label.17
|
2008-03-01 17:15:35 +08:00
|
|
|
%SubArrays.8 = phi i32* [ %SubArrays.10, %shortcirc_next.7 ], [ %SubArrays.10, %label.17 ] ; <i32*> [#uses=1]
|
2015-02-28 05:17:42 +08:00
|
|
|
%tmp.1023 = load i32, i32* null ; <i32> [#uses=1]
|
2008-03-01 17:15:35 +08:00
|
|
|
switch i32 %tmp.1023, label %loopentry.1 [
|
|
|
|
]
|
2003-06-25 06:58:05 +08:00
|
|
|
|
|
|
|
loopexit.0: ; preds = %loopentry.0
|
2008-03-01 17:15:35 +08:00
|
|
|
ret i32 0
|
2003-06-25 06:58:05 +08:00
|
|
|
|
|
|
|
else.2: ; preds = %then.11
|
2008-03-01 17:15:35 +08:00
|
|
|
ret i32 0
|
2003-06-25 06:58:05 +08:00
|
|
|
}
|