2012-12-31 16:37:17 +08:00
|
|
|
; RUN: opt < %s -basicaa -tbaa -licm -S | FileCheck %s
|
2016-07-13 06:37:48 +08:00
|
|
|
; RUN: opt -aa-pipeline=type-based-aa,basic-aa -passes='require<aa>,require<targetir>,require<scalar-evolution>,loop(licm)' -S %s | FileCheck %s
|
2010-09-01 07:00:16 +08:00
|
|
|
target datalayout = "E-p:64:64:64-a0:0:8-f32:32:32-f64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-v64:64:64-v128:128:128"
|
|
|
|
|
2013-01-05 07:11:35 +08:00
|
|
|
@X = global i32 7 ; <i32*> [#uses=4]
|
2003-02-23 06:20:19 +08:00
|
|
|
|
2009-08-31 06:08:19 +08:00
|
|
|
define void @test1(i32 %i) {
|
|
|
|
Entry:
|
2013-01-05 07:11:35 +08:00
|
|
|
br label %Loop
|
2013-07-14 09:42:54 +08:00
|
|
|
; CHECK-LABEL: @test1(
|
2009-08-31 06:08:19 +08:00
|
|
|
; CHECK: Entry:
|
2015-02-28 05:17:42 +08:00
|
|
|
; CHECK-NEXT: load i32, i32* @X
|
2009-08-31 06:08:19 +08:00
|
|
|
; CHECK-NEXT: br label %Loop
|
|
|
|
|
2003-02-23 06:20:19 +08:00
|
|
|
|
2013-01-05 07:11:35 +08:00
|
|
|
Loop: ; preds = %Loop, %0
|
|
|
|
%j = phi i32 [ 0, %Entry ], [ %Next, %Loop ] ; <i32> [#uses=1]
|
2015-02-28 05:17:42 +08:00
|
|
|
%x = load i32, i32* @X ; <i32> [#uses=1]
|
2013-01-05 07:11:35 +08:00
|
|
|
%x2 = add i32 %x, 1 ; <i32> [#uses=1]
|
|
|
|
store i32 %x2, i32* @X
|
|
|
|
%Next = add i32 %j, 1 ; <i32> [#uses=2]
|
|
|
|
%cond = icmp eq i32 %Next, 0 ; <i1> [#uses=1]
|
|
|
|
br i1 %cond, label %Out, label %Loop
|
2003-02-23 06:20:19 +08:00
|
|
|
|
2013-01-05 07:11:35 +08:00
|
|
|
Out:
|
|
|
|
ret void
|
2009-08-31 06:08:19 +08:00
|
|
|
; CHECK: Out:
|
2014-01-25 12:07:24 +08:00
|
|
|
; CHECK-NEXT: %[[LCSSAPHI:.*]] = phi i32 [ %x2
|
|
|
|
; CHECK-NEXT: store i32 %[[LCSSAPHI]], i32* @X
|
2009-08-31 06:08:19 +08:00
|
|
|
; CHECK-NEXT: ret void
|
|
|
|
|
2003-02-23 06:20:19 +08:00
|
|
|
}
|
2003-02-24 11:52:04 +08:00
|
|
|
|
2009-08-31 06:08:19 +08:00
|
|
|
define void @test2(i32 %i) {
|
|
|
|
Entry:
|
2013-01-05 07:11:35 +08:00
|
|
|
br label %Loop
|
2013-07-14 09:42:54 +08:00
|
|
|
; CHECK-LABEL: @test2(
|
2009-08-31 06:08:19 +08:00
|
|
|
; CHECK: Entry:
|
2015-03-14 02:20:45 +08:00
|
|
|
; CHECK-NEXT: %.promoted = load i32, i32* getelementptr inbounds (i32, i32* @X, i64 1)
|
2009-08-31 06:08:19 +08:00
|
|
|
; CHECK-NEXT: br label %Loop
|
2003-02-24 11:52:04 +08:00
|
|
|
|
2013-01-05 07:11:35 +08:00
|
|
|
Loop: ; preds = %Loop, %0
|
[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
|
|
|
%X1 = getelementptr i32, i32* @X, i64 1 ; <i32*> [#uses=1]
|
2015-02-28 05:17:42 +08:00
|
|
|
%A = load i32, i32* %X1 ; <i32> [#uses=1]
|
2013-01-05 07:11:35 +08:00
|
|
|
%V = add i32 %A, 1 ; <i32> [#uses=1]
|
[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
|
|
|
%X2 = getelementptr i32, i32* @X, i64 1 ; <i32*> [#uses=1]
|
2013-01-05 07:11:35 +08:00
|
|
|
store i32 %V, i32* %X2
|
|
|
|
br i1 false, label %Loop, label %Exit
|
2003-02-24 11:52:04 +08:00
|
|
|
|
2013-01-05 07:11:35 +08:00
|
|
|
Exit: ; preds = %Loop
|
|
|
|
ret void
|
2009-08-31 06:08:19 +08:00
|
|
|
; CHECK: Exit:
|
2014-01-25 12:07:24 +08:00
|
|
|
; CHECK-NEXT: %[[LCSSAPHI:.*]] = phi i32 [ %V
|
2015-03-14 02:20:45 +08:00
|
|
|
; CHECK-NEXT: store i32 %[[LCSSAPHI]], i32* getelementptr inbounds (i32, i32* @X, i64 1)
|
2009-08-31 06:08:19 +08:00
|
|
|
; CHECK-NEXT: ret void
|
2003-02-24 11:52:04 +08:00
|
|
|
}
|
2009-08-31 06:08:19 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
define void @test3(i32 %i) {
|
2013-07-14 09:42:54 +08:00
|
|
|
; CHECK-LABEL: @test3(
|
2013-01-05 07:11:35 +08:00
|
|
|
br label %Loop
|
2009-08-31 06:08:19 +08:00
|
|
|
Loop:
|
|
|
|
; Should not promote this to a register
|
2015-02-28 05:17:42 +08:00
|
|
|
%x = load volatile i32, i32* @X
|
2013-01-05 07:11:35 +08:00
|
|
|
%x2 = add i32 %x, 1
|
|
|
|
store i32 %x2, i32* @X
|
|
|
|
br i1 true, label %Out, label %Loop
|
|
|
|
|
2009-08-31 06:08:19 +08:00
|
|
|
; CHECK: Loop:
|
2011-08-13 06:50:01 +08:00
|
|
|
; CHECK-NEXT: load volatile
|
2009-08-31 06:08:19 +08:00
|
|
|
|
2013-01-05 07:11:35 +08:00
|
|
|
Out: ; preds = %Loop
|
|
|
|
ret void
|
2009-08-31 06:08:19 +08:00
|
|
|
}
|
|
|
|
|
2010-09-03 06:19:10 +08:00
|
|
|
; PR8041
|
|
|
|
define void @test4(i8* %x, i8 %n) {
|
2013-07-14 09:42:54 +08:00
|
|
|
; CHECK-LABEL: @test4(
|
2010-09-03 06:19:10 +08:00
|
|
|
%handle1 = alloca i8*
|
|
|
|
%handle2 = alloca i8*
|
|
|
|
store i8* %x, i8** %handle1
|
|
|
|
br label %loop
|
|
|
|
|
|
|
|
loop:
|
[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 = getelementptr i8, i8* %x, i64 8
|
2010-09-03 06:19:10 +08:00
|
|
|
store i8* %tmp, i8** %handle2
|
|
|
|
br label %subloop
|
|
|
|
|
|
|
|
subloop:
|
|
|
|
%count = phi i8 [ 0, %loop ], [ %nextcount, %subloop ]
|
2015-02-28 05:17:42 +08:00
|
|
|
%offsetx2 = load i8*, i8** %handle2
|
2010-09-03 06:19:10 +08:00
|
|
|
store i8 %n, i8* %offsetx2
|
[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
|
|
|
%newoffsetx2 = getelementptr i8, i8* %offsetx2, i64 -1
|
2010-09-03 06:19:10 +08:00
|
|
|
store i8* %newoffsetx2, i8** %handle2
|
|
|
|
%nextcount = add i8 %count, 1
|
|
|
|
%innerexitcond = icmp sge i8 %nextcount, 8
|
|
|
|
br i1 %innerexitcond, label %innerexit, label %subloop
|
|
|
|
|
|
|
|
; Should have promoted 'handle2' accesses.
|
|
|
|
; CHECK: subloop:
|
|
|
|
; CHECK-NEXT: phi i8* [
|
|
|
|
; CHECK-NEXT: %count = phi i8 [
|
|
|
|
; CHECK-NEXT: store i8 %n
|
|
|
|
; CHECK-NOT: store
|
|
|
|
; CHECK: br i1
|
|
|
|
|
|
|
|
innerexit:
|
2015-02-28 05:17:42 +08:00
|
|
|
%offsetx1 = load i8*, i8** %handle1
|
|
|
|
%val = load i8, i8* %offsetx1
|
2010-09-03 06:19:10 +08:00
|
|
|
%cond = icmp eq i8 %val, %n
|
|
|
|
br i1 %cond, label %exit, label %loop
|
|
|
|
|
|
|
|
; Should not have promoted offsetx1 loads.
|
|
|
|
; CHECK: innerexit:
|
2015-02-28 05:17:42 +08:00
|
|
|
; CHECK: %val = load i8, i8* %offsetx1
|
2010-09-03 06:19:10 +08:00
|
|
|
; CHECK: %cond = icmp eq i8 %val, %n
|
|
|
|
; CHECK: br i1 %cond, label %exit, label %loop
|
|
|
|
|
|
|
|
exit:
|
|
|
|
ret void
|
|
|
|
}
|
|
|
|
|
2010-12-19 13:57:25 +08:00
|
|
|
define void @test5(i32 %i, i32** noalias %P2) {
|
|
|
|
Entry:
|
2013-01-05 07:11:35 +08:00
|
|
|
br label %Loop
|
2013-07-14 09:42:54 +08:00
|
|
|
; CHECK-LABEL: @test5(
|
2010-12-19 13:57:25 +08:00
|
|
|
; CHECK: Entry:
|
2015-02-28 05:17:42 +08:00
|
|
|
; CHECK-NEXT: load i32, i32* @X
|
2010-12-19 13:57:25 +08:00
|
|
|
; CHECK-NEXT: br label %Loop
|
|
|
|
|
|
|
|
|
2013-01-05 07:11:35 +08:00
|
|
|
Loop: ; preds = %Loop, %0
|
|
|
|
%j = phi i32 [ 0, %Entry ], [ %Next, %Loop ] ; <i32> [#uses=1]
|
2015-02-28 05:17:42 +08:00
|
|
|
%x = load i32, i32* @X ; <i32> [#uses=1]
|
2013-01-05 07:11:35 +08:00
|
|
|
%x2 = add i32 %x, 1 ; <i32> [#uses=1]
|
|
|
|
store i32 %x2, i32* @X
|
|
|
|
|
[LICM] Make isGuaranteedToExecute more accurate.
Summary:
Make isGuaranteedToExecute use the
isGuaranteedToTransferExecutionToSuccessor helper, and make that helper
a bit more accurate.
There's a potential performance impact here from assuming that arbitrary
calls might not return. This probably has little impact on loads and
stores to a pointer because most things alias analysis can reason about
are dereferenceable anyway. The other impacts, like less aggressive
hoisting of sdiv by a variable and less aggressive hoisting around
volatile memory operations, are unlikely to matter for real code.
This also impacts SCEV, which uses the same helper. It's a minor
improvement there because we can tell that, for example, memcpy always
returns normally. Strictly speaking, it's also introducing
a bug, but it's not any worse than everywhere else we assume readonly
functions terminate.
Fixes http://llvm.org/PR27857.
Reviewers: hfinkel, reames, chandlerc, sanjoy
Subscribers: broune, llvm-commits
Differential Revision: http://reviews.llvm.org/D21167
llvm-svn: 272489
2016-06-12 05:48:25 +08:00
|
|
|
store atomic i32* @X, i32** %P2 monotonic, align 8
|
2012-12-31 16:37:17 +08:00
|
|
|
|
2013-01-05 07:11:35 +08:00
|
|
|
%Next = add i32 %j, 1 ; <i32> [#uses=2]
|
|
|
|
%cond = icmp eq i32 %Next, 0 ; <i1> [#uses=1]
|
|
|
|
br i1 %cond, label %Out, label %Loop
|
2010-12-19 13:57:25 +08:00
|
|
|
|
2013-01-05 07:11:35 +08:00
|
|
|
Out:
|
|
|
|
ret void
|
2010-12-19 13:57:25 +08:00
|
|
|
; CHECK: Out:
|
2014-01-25 12:07:24 +08:00
|
|
|
; CHECK-NEXT: %[[LCSSAPHI:.*]] = phi i32 [ %x2
|
|
|
|
; CHECK-NEXT: store i32 %[[LCSSAPHI]], i32* @X
|
2010-12-19 13:57:25 +08:00
|
|
|
; CHECK-NEXT: ret void
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-12-31 16:37:17 +08:00
|
|
|
; PR14753 - Preserve TBAA tags when promoting values in a loop.
|
|
|
|
define void @test6(i32 %n, float* nocapture %a, i32* %gi) {
|
|
|
|
entry:
|
|
|
|
store i32 0, i32* %gi, align 4, !tbaa !0
|
|
|
|
%cmp1 = icmp slt i32 0, %n
|
|
|
|
br i1 %cmp1, label %for.body.lr.ph, label %for.end
|
|
|
|
|
|
|
|
for.body.lr.ph: ; preds = %entry
|
|
|
|
br label %for.body
|
|
|
|
|
|
|
|
for.body: ; preds = %for.body.lr.ph, %for.body
|
|
|
|
%storemerge2 = phi i32 [ 0, %for.body.lr.ph ], [ %inc, %for.body ]
|
|
|
|
%idxprom = sext i32 %storemerge2 to i64
|
[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
|
|
|
%arrayidx = getelementptr inbounds float, float* %a, i64 %idxprom
|
2012-12-31 16:37:17 +08:00
|
|
|
store float 0.000000e+00, float* %arrayidx, align 4, !tbaa !3
|
2015-02-28 05:17:42 +08:00
|
|
|
%0 = load i32, i32* %gi, align 4, !tbaa !0
|
2012-12-31 16:37:17 +08:00
|
|
|
%inc = add nsw i32 %0, 1
|
|
|
|
store i32 %inc, i32* %gi, align 4, !tbaa !0
|
|
|
|
%cmp = icmp slt i32 %inc, %n
|
|
|
|
br i1 %cmp, label %for.body, label %for.cond.for.end_crit_edge
|
|
|
|
|
|
|
|
for.cond.for.end_crit_edge: ; preds = %for.body
|
|
|
|
br label %for.end
|
|
|
|
|
|
|
|
for.end: ; preds = %for.cond.for.end_crit_edge, %entry
|
|
|
|
ret void
|
2013-01-05 07:11:35 +08:00
|
|
|
|
2012-12-31 16:37:17 +08:00
|
|
|
; CHECK: for.body.lr.ph:
|
2015-02-28 05:17:42 +08:00
|
|
|
; CHECK-NEXT: %gi.promoted = load i32, i32* %gi, align 4, !tbaa !0
|
2012-12-31 16:37:17 +08:00
|
|
|
; CHECK: for.cond.for.end_crit_edge:
|
2014-01-25 12:07:24 +08:00
|
|
|
; CHECK-NEXT: %[[LCSSAPHI:.*]] = phi i32 [ %inc
|
|
|
|
; CHECK-NEXT: store i32 %[[LCSSAPHI]], i32* %gi, align 4, !tbaa !0
|
2012-12-31 16:37:17 +08:00
|
|
|
}
|
|
|
|
|
IR: Make metadata typeless in assembly
Now that `Metadata` is typeless, reflect that in the assembly. These
are the matching assembly changes for the metadata/value split in
r223802.
- Only use the `metadata` type when referencing metadata from a call
intrinsic -- i.e., only when it's used as a `Value`.
- Stop pretending that `ValueAsMetadata` is wrapped in an `MDNode`
when referencing it from call intrinsics.
So, assembly like this:
define @foo(i32 %v) {
call void @llvm.foo(metadata !{i32 %v}, metadata !0)
call void @llvm.foo(metadata !{i32 7}, metadata !0)
call void @llvm.foo(metadata !1, metadata !0)
call void @llvm.foo(metadata !3, metadata !0)
call void @llvm.foo(metadata !{metadata !3}, metadata !0)
ret void, !bar !2
}
!0 = metadata !{metadata !2}
!1 = metadata !{i32* @global}
!2 = metadata !{metadata !3}
!3 = metadata !{}
turns into this:
define @foo(i32 %v) {
call void @llvm.foo(metadata i32 %v, metadata !0)
call void @llvm.foo(metadata i32 7, metadata !0)
call void @llvm.foo(metadata i32* @global, metadata !0)
call void @llvm.foo(metadata !3, metadata !0)
call void @llvm.foo(metadata !{!3}, metadata !0)
ret void, !bar !2
}
!0 = !{!2}
!1 = !{i32* @global}
!2 = !{!3}
!3 = !{}
I wrote an upgrade script that handled almost all of the tests in llvm
and many of the tests in cfe (even handling many `CHECK` lines). I've
attached it (or will attach it in a moment if you're speedy) to PR21532
to help everyone update their out-of-tree testcases.
This is part of PR21532.
llvm-svn: 224257
2014-12-16 03:07:53 +08:00
|
|
|
!0 = !{!4, !4, i64 0}
|
|
|
|
!1 = !{!"omnipotent char", !2}
|
|
|
|
!2 = !{!"Simple C/C++ TBAA"}
|
|
|
|
!3 = !{!5, !5, i64 0}
|
|
|
|
!4 = !{!"int", !1}
|
|
|
|
!5 = !{!"float", !1}
|