2009-10-18 12:41:36 +08:00
|
|
|
; RUN: opt < %s -basicaa -gvn -dse -S | FileCheck %s
|
2009-11-03 23:29:06 +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"
|
2009-10-18 07:59:51 +08:00
|
|
|
|
2017-04-11 04:18:21 +08:00
|
|
|
declare void @llvm.lifetime.end.p0i8(i64, i8* nocapture)
|
2006-11-18 13:52:18 +08:00
|
|
|
|
2009-10-18 07:59:51 +08:00
|
|
|
declare void @external(i32*)
|
|
|
|
|
|
|
|
define i32 @test0(i8* %P) {
|
|
|
|
%A = alloca i32
|
|
|
|
call void @external(i32* %A)
|
2014-09-16 01:56:56 +08:00
|
|
|
|
2009-10-18 07:59:51 +08:00
|
|
|
store i32 0, i32* %A
|
2014-09-16 01:56:56 +08:00
|
|
|
|
2015-11-19 13:56:52 +08:00
|
|
|
call void @llvm.memset.p0i8.i32(i8* %P, i8 0, i32 42, i32 1, i1 false)
|
2014-09-16 01:56:56 +08:00
|
|
|
|
2015-02-28 05:17:42 +08:00
|
|
|
%B = load i32, i32* %A
|
2009-10-18 07:59:51 +08:00
|
|
|
ret i32 %B
|
2014-09-16 01:56:56 +08:00
|
|
|
|
|
|
|
; CHECK-LABEL: @test0
|
2009-10-18 07:59:51 +08:00
|
|
|
; CHECK: ret i32 0
|
2006-11-18 13:52:18 +08:00
|
|
|
}
|
2009-10-18 07:59:51 +08:00
|
|
|
|
2009-10-18 12:41:36 +08:00
|
|
|
define i8 @test1() {
|
2014-09-16 01:56:56 +08:00
|
|
|
; CHECK-LABEL: @test1
|
2009-10-18 12:41:36 +08:00
|
|
|
%A = alloca i8
|
|
|
|
%B = alloca i8
|
|
|
|
|
|
|
|
store i8 2, i8* %B ;; Not written to by memcpy
|
|
|
|
|
2015-11-19 13:56:52 +08:00
|
|
|
call void @llvm.memcpy.p0i8.p0i8.i8(i8* %A, i8* %B, i8 -1, i32 0, i1 false)
|
2009-10-18 12:41:36 +08:00
|
|
|
|
2015-02-28 05:17:42 +08:00
|
|
|
%C = load i8, i8* %B
|
2009-10-18 12:41:36 +08:00
|
|
|
ret i8 %C
|
|
|
|
; CHECK: ret i8 2
|
|
|
|
}
|
|
|
|
|
|
|
|
define i8 @test2(i8* %P) {
|
2014-09-16 01:56:56 +08:00
|
|
|
; CHECK-LABEL: @test2
|
[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
|
|
|
%P2 = getelementptr i8, i8* %P, i32 127
|
2009-10-18 12:41:36 +08:00
|
|
|
store i8 1, i8* %P2 ;; Not dead across memset
|
2015-11-19 13:56:52 +08:00
|
|
|
call void @llvm.memset.p0i8.i8(i8* %P, i8 2, i8 127, i32 0, i1 false)
|
2015-02-28 05:17:42 +08:00
|
|
|
%A = load i8, i8* %P2
|
2009-10-18 12:41:36 +08:00
|
|
|
ret i8 %A
|
|
|
|
; CHECK: ret i8 1
|
|
|
|
}
|
|
|
|
|
2009-10-18 12:50:18 +08:00
|
|
|
define i8 @test2a(i8* %P) {
|
2014-09-16 01:56:56 +08:00
|
|
|
; CHECK-LABEL: @test2
|
[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
|
|
|
%P2 = getelementptr i8, i8* %P, i32 126
|
2014-09-16 01:56:56 +08:00
|
|
|
|
2009-10-18 12:55:26 +08:00
|
|
|
;; FIXME: DSE isn't zapping this dead store.
|
2009-10-18 12:50:18 +08:00
|
|
|
store i8 1, i8* %P2 ;; Dead, clobbered by memset.
|
2014-09-16 01:56:56 +08:00
|
|
|
|
2015-11-19 13:56:52 +08:00
|
|
|
call void @llvm.memset.p0i8.i8(i8* %P, i8 2, i8 127, i32 0, i1 false)
|
2015-02-28 05:17:42 +08:00
|
|
|
%A = load i8, i8* %P2
|
2009-10-18 12:50:18 +08:00
|
|
|
ret i8 %A
|
2009-12-06 12:16:05 +08:00
|
|
|
; CHECK-NOT: load
|
|
|
|
; CHECK: ret i8 2
|
2009-10-18 12:50:18 +08:00
|
|
|
}
|
|
|
|
|
2009-10-18 12:55:26 +08:00
|
|
|
define void @test3(i8* %P, i8 %X) {
|
2014-09-16 01:56:56 +08:00
|
|
|
; CHECK-LABEL: @test3
|
2009-10-18 12:55:26 +08:00
|
|
|
; CHECK-NOT: store
|
|
|
|
; CHECK-NOT: %Y
|
|
|
|
%Y = add i8 %X, 1 ;; Dead, because the only use (the store) is dead.
|
2014-09-16 01:56:56 +08:00
|
|
|
|
[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
|
|
|
%P2 = getelementptr i8, i8* %P, i32 2
|
2009-10-18 12:55:26 +08:00
|
|
|
store i8 %Y, i8* %P2 ;; Not read by lifetime.end, should be removed.
|
|
|
|
; CHECK: store i8 2, i8* %P2
|
2017-04-11 04:18:21 +08:00
|
|
|
call void @llvm.lifetime.end.p0i8(i64 1, i8* %P)
|
2009-10-18 12:41:36 +08:00
|
|
|
store i8 2, i8* %P2
|
|
|
|
; CHECK-NOT: store
|
|
|
|
ret void
|
|
|
|
; CHECK: ret void
|
2009-10-18 12:55:26 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
define void @test3a(i8* %P, i8 %X) {
|
2014-09-16 01:56:56 +08:00
|
|
|
; CHECK-LABEL: @test3a
|
2009-10-18 12:55:26 +08:00
|
|
|
%Y = add i8 %X, 1 ;; Dead, because the only use (the store) is dead.
|
2014-09-16 01:56:56 +08:00
|
|
|
|
[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
|
|
|
%P2 = getelementptr i8, i8* %P, i32 2
|
2010-12-01 07:25:01 +08:00
|
|
|
store i8 %Y, i8* %P2
|
|
|
|
; CHECK-NEXT: call void @llvm.lifetime.end
|
2017-04-11 04:18:21 +08:00
|
|
|
call void @llvm.lifetime.end.p0i8(i64 10, i8* %P)
|
2009-10-18 12:55:26 +08:00
|
|
|
ret void
|
2010-12-01 07:25:01 +08:00
|
|
|
; CHECK-NEXT: ret void
|
2009-11-03 23:29:06 +08:00
|
|
|
}
|
2009-11-23 00:15:59 +08:00
|
|
|
|
|
|
|
@G1 = external global i32
|
|
|
|
@G2 = external global [4000 x i32]
|
|
|
|
|
2009-11-26 10:16:28 +08:00
|
|
|
define i32 @test4(i8* %P) {
|
2015-02-28 05:17:42 +08:00
|
|
|
%tmp = load i32, i32* @G1
|
2015-11-19 13:56:52 +08:00
|
|
|
call void @llvm.memset.p0i8.i32(i8* bitcast ([4000 x i32]* @G2 to i8*), i8 0, i32 4000, i32 1, i1 false)
|
2015-02-28 05:17:42 +08:00
|
|
|
%tmp2 = load i32, i32* @G1
|
2009-11-23 00:15:59 +08:00
|
|
|
%sub = sub i32 %tmp2, %tmp
|
|
|
|
ret i32 %sub
|
2014-09-16 01:56:56 +08:00
|
|
|
; CHECK-LABEL: @test4
|
2011-05-22 15:20:02 +08:00
|
|
|
; CHECK-NOT: load
|
Reapply address space patch after fixing an issue in MemCopyOptimizer.
Added support for address spaces and added a isVolatile field to memcpy, memmove, and memset,
e.g., llvm.memcpy.i32(i8*, i8*, i32, i32) -> llvm.memcpy.p0i8.p0i8.i32(i8*, i8*, i32, i32, i1)
llvm-svn: 100304
2010-04-04 11:10:48 +08:00
|
|
|
; CHECK: memset.p0i8.i32
|
2009-11-23 00:15:59 +08:00
|
|
|
; CHECK-NOT: load
|
2010-12-15 22:07:39 +08:00
|
|
|
; CHECK: ret i32 0
|
2009-11-23 00:15:59 +08:00
|
|
|
}
|
|
|
|
|
2009-11-26 10:16:28 +08:00
|
|
|
; Verify that basicaa is handling variable length memcpy, knowing it doesn't
|
|
|
|
; write to G1.
|
|
|
|
define i32 @test5(i8* %P, i32 %Len) {
|
2015-02-28 05:17:42 +08:00
|
|
|
%tmp = load i32, i32* @G1
|
2015-11-19 13:56:52 +08:00
|
|
|
call void @llvm.memcpy.p0i8.p0i8.i32(i8* bitcast ([4000 x i32]* @G2 to i8*), i8* bitcast (i32* @G1 to i8*), i32 %Len, i32 1, i1 false)
|
2015-02-28 05:17:42 +08:00
|
|
|
%tmp2 = load i32, i32* @G1
|
2009-11-26 10:16:28 +08:00
|
|
|
%sub = sub i32 %tmp2, %tmp
|
|
|
|
ret i32 %sub
|
|
|
|
; CHECK: @test5
|
2011-05-22 15:20:02 +08:00
|
|
|
; CHECK-NOT: load
|
Reapply address space patch after fixing an issue in MemCopyOptimizer.
Added support for address spaces and added a isVolatile field to memcpy, memmove, and memset,
e.g., llvm.memcpy.i32(i8*, i8*, i32, i32) -> llvm.memcpy.p0i8.p0i8.i32(i8*, i8*, i32, i32, i1)
llvm-svn: 100304
2010-04-04 11:10:48 +08:00
|
|
|
; CHECK: memcpy.p0i8.p0i8.i32
|
2009-11-26 10:16:28 +08:00
|
|
|
; CHECK-NOT: load
|
2010-12-15 22:07:39 +08:00
|
|
|
; CHECK: ret i32 0
|
2009-11-26 10:16:28 +08:00
|
|
|
}
|
|
|
|
|
2010-08-07 02:24:38 +08:00
|
|
|
define i8 @test6(i8* %p, i8* noalias %a) {
|
2015-02-28 05:17:42 +08:00
|
|
|
%x = load i8, i8* %a
|
2010-08-07 02:24:38 +08:00
|
|
|
%t = va_arg i8* %p, float
|
2015-02-28 05:17:42 +08:00
|
|
|
%y = load i8, i8* %a
|
2010-08-07 02:24:38 +08:00
|
|
|
%z = add i8 %x, %y
|
|
|
|
ret i8 %z
|
2014-09-16 01:56:56 +08:00
|
|
|
; CHECK-LABEL: @test6
|
2015-02-28 05:17:42 +08:00
|
|
|
; CHECK: load i8, i8* %a
|
2010-08-07 02:24:38 +08:00
|
|
|
; CHECK-NOT: load
|
|
|
|
; CHECK: ret
|
|
|
|
}
|
2011-06-18 14:05:24 +08:00
|
|
|
|
2011-09-28 08:34:27 +08:00
|
|
|
; PR10628
|
|
|
|
declare void @test7decl(i32* nocapture %x)
|
|
|
|
define i32 @test7() nounwind uwtable ssp {
|
|
|
|
entry:
|
|
|
|
%x = alloca i32, align 4
|
|
|
|
store i32 0, i32* %x, align 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
|
|
|
%add.ptr = getelementptr inbounds i32, i32* %x, i64 1
|
2011-09-28 08:34:27 +08:00
|
|
|
call void @test7decl(i32* %add.ptr)
|
2015-02-28 05:17:42 +08:00
|
|
|
%tmp = load i32, i32* %x, align 4
|
2011-09-28 08:34:27 +08:00
|
|
|
ret i32 %tmp
|
2014-09-16 01:56:56 +08:00
|
|
|
; CHECK-LABEL: @test7(
|
2011-09-28 08:34:27 +08:00
|
|
|
; CHECK: store i32 0
|
|
|
|
; CHECK: call void @test7decl
|
2015-02-28 05:17:42 +08:00
|
|
|
; CHECK: load i32, i32*
|
2011-09-28 08:34:27 +08:00
|
|
|
}
|
|
|
|
|
2015-07-11 18:30:36 +08:00
|
|
|
;; Check that aa correctly handles functions marked with argmemonly
|
|
|
|
;; attribute.
|
|
|
|
declare i32 @func_argmemonly(i32 * %P) argmemonly
|
|
|
|
|
|
|
|
;; Can not remove redundant load, function may write to it.
|
|
|
|
; CHECK-LABEL: @test8(
|
|
|
|
define i32 @test8(i32 *%P) {
|
|
|
|
%V1 = load i32, i32* %P
|
|
|
|
call i32 @func_argmemonly(i32* %P)
|
|
|
|
%V2 = load i32, i32* %P
|
|
|
|
%Diff = sub i32 %V1, %V2
|
|
|
|
ret i32 %Diff
|
|
|
|
; CHECK: load
|
|
|
|
; CHECK: load
|
|
|
|
; CHECK: sub
|
|
|
|
; CHECK: ret i32 %Diff
|
|
|
|
}
|
|
|
|
|
|
|
|
;; In this case load can be removed, function clobbers only %P2.
|
|
|
|
; CHECK-LABEL: @test9(
|
|
|
|
define i32 @test9(i32* %P, i32* noalias %P2) {
|
|
|
|
%V1 = load i32, i32* %P
|
|
|
|
call i32 @func_argmemonly(i32* %P2)
|
|
|
|
%V2 = load i32, i32* %P
|
|
|
|
%Diff = sub i32 %V1, %V2
|
|
|
|
ret i32 %Diff
|
|
|
|
; CHECK-NOT: load
|
|
|
|
; CHECK: ret i32 0
|
|
|
|
}
|
|
|
|
|
|
|
|
;; In this case load can *not* be removed. Function clobers only %P2 but it may
|
|
|
|
;; alias with %P.
|
|
|
|
; CHECK-LABEL: @test10(
|
|
|
|
define i32 @test10(i32* %P, i32* %P2) {
|
|
|
|
%V1 = load i32, i32* %P
|
|
|
|
call i32 @func_argmemonly(i32* %P2)
|
|
|
|
%V2 = load i32, i32* %P
|
|
|
|
%Diff = sub i32 %V1, %V2
|
|
|
|
ret i32 %Diff
|
|
|
|
; CHECK: load
|
|
|
|
; CHECK: load
|
|
|
|
; CHECK: sub
|
|
|
|
; CHECK: ret i32 %Diff
|
|
|
|
}
|
|
|
|
|
2015-10-29 00:42:00 +08:00
|
|
|
; CHECK-LABEL: @test11(
|
|
|
|
define i32 @test11(i32* %P, i32* %P2) {
|
|
|
|
%V1 = load i32, i32* %P
|
|
|
|
call i32 @func_argmemonly(i32* readonly %P2)
|
|
|
|
%V2 = load i32, i32* %P
|
|
|
|
%Diff = sub i32 %V1, %V2
|
|
|
|
ret i32 %Diff
|
|
|
|
; CHECK-NOT: load
|
|
|
|
; CHECK: ret i32 0
|
|
|
|
}
|
|
|
|
|
|
|
|
declare i32 @func_argmemonly_two_args(i32* %P, i32* %P2) argmemonly
|
|
|
|
|
|
|
|
; CHECK-LABEL: @test12(
|
|
|
|
define i32 @test12(i32* %P, i32* %P2, i32* %P3) {
|
|
|
|
%V1 = load i32, i32* %P
|
|
|
|
call i32 @func_argmemonly_two_args(i32* readonly %P2, i32* %P3)
|
|
|
|
%V2 = load i32, i32* %P
|
|
|
|
%Diff = sub i32 %V1, %V2
|
|
|
|
ret i32 %Diff
|
|
|
|
; CHECK: load
|
|
|
|
; CHECK: load
|
|
|
|
; CHECK: sub
|
|
|
|
; CHECK: ret i32 %Diff
|
|
|
|
}
|
|
|
|
|
2015-10-29 01:54:48 +08:00
|
|
|
; CHECK-LABEL: @test13(
|
|
|
|
define i32 @test13(i32* %P, i32* %P2) {
|
|
|
|
%V1 = load i32, i32* %P
|
|
|
|
call i32 @func_argmemonly(i32* readnone %P2)
|
|
|
|
%V2 = load i32, i32* %P
|
|
|
|
%Diff = sub i32 %V1, %V2
|
|
|
|
ret i32 %Diff
|
|
|
|
; CHECK-NOT: load
|
|
|
|
; CHECK: ret i32 0
|
|
|
|
}
|
|
|
|
|
2015-11-19 13:56:52 +08:00
|
|
|
declare void @llvm.memset.p0i8.i32(i8* nocapture, i8, i32, i32, i1) nounwind
|
|
|
|
declare void @llvm.memset.p0i8.i8(i8* nocapture, i8, i8, i32, i1) nounwind
|
|
|
|
declare void @llvm.memcpy.p0i8.p0i8.i8(i8* nocapture, i8* nocapture, i8, i32, i1) nounwind
|
|
|
|
declare void @llvm.memcpy.p0i8.p0i8.i32(i8* nocapture, i8* nocapture, i32, i32, i1) nounwind
|