2014-08-29 21:42:08 +00:00
|
|
|
; RUN: llc < %s -enable-tail-merge=0 -mtriple=x86_64-linux | FileCheck %s --check-prefix=LINUX
|
|
|
|
; RUN: llc < %s -enable-tail-merge=0 -mtriple=x86_64-windows | FileCheck %s --check-prefix=WINDOWS
|
2015-01-12 23:28:23 +00:00
|
|
|
; RUN: llc < %s -enable-tail-merge=0 -mtriple=i686-windows | FileCheck %s --check-prefix=X86
|
2014-08-29 21:42:08 +00:00
|
|
|
|
|
|
|
; Test that we actually spill and reload all arguments in the variadic argument
|
|
|
|
; pack. Doing a normal call will clobber all argument registers, and we will
|
|
|
|
; spill around it. A simple adjustment should not require any XMM spills.
|
|
|
|
|
2014-12-22 23:58:37 +00:00
|
|
|
declare void @llvm.va_start(i8*) nounwind
|
|
|
|
|
2014-08-29 21:42:08 +00:00
|
|
|
declare void(i8*, ...)* @get_f(i8* %this)
|
|
|
|
|
|
|
|
define void @f_thunk(i8* %this, ...) {
|
2014-12-22 23:58:37 +00:00
|
|
|
; Use va_start so that we exercise the combination.
|
|
|
|
%ap = alloca [4 x i8*], align 16
|
|
|
|
%ap_i8 = bitcast [4 x i8*]* %ap to i8*
|
|
|
|
call void @llvm.va_start(i8* %ap_i8)
|
|
|
|
|
2014-08-29 21:42:08 +00:00
|
|
|
%fptr = call void(i8*, ...)*(i8*)* @get_f(i8* %this)
|
|
|
|
musttail call void (i8*, ...)* %fptr(i8* %this, ...)
|
|
|
|
ret void
|
|
|
|
}
|
|
|
|
|
|
|
|
; Save and restore 6 GPRs, 8 XMMs, and AL around the call.
|
|
|
|
|
|
|
|
; LINUX-LABEL: f_thunk:
|
|
|
|
; LINUX-DAG: movq %rdi, {{.*}}
|
|
|
|
; LINUX-DAG: movq %rsi, {{.*}}
|
|
|
|
; LINUX-DAG: movq %rdx, {{.*}}
|
|
|
|
; LINUX-DAG: movq %rcx, {{.*}}
|
|
|
|
; LINUX-DAG: movq %r8, {{.*}}
|
|
|
|
; LINUX-DAG: movq %r9, {{.*}}
|
|
|
|
; LINUX-DAG: movb %al, {{.*}}
|
|
|
|
; LINUX-DAG: movaps %xmm0, {{[0-9]*}}(%rsp)
|
|
|
|
; LINUX-DAG: movaps %xmm1, {{[0-9]*}}(%rsp)
|
|
|
|
; LINUX-DAG: movaps %xmm2, {{[0-9]*}}(%rsp)
|
|
|
|
; LINUX-DAG: movaps %xmm3, {{[0-9]*}}(%rsp)
|
|
|
|
; LINUX-DAG: movaps %xmm4, {{[0-9]*}}(%rsp)
|
|
|
|
; LINUX-DAG: movaps %xmm5, {{[0-9]*}}(%rsp)
|
|
|
|
; LINUX-DAG: movaps %xmm6, {{[0-9]*}}(%rsp)
|
|
|
|
; LINUX-DAG: movaps %xmm7, {{[0-9]*}}(%rsp)
|
|
|
|
; LINUX: callq get_f
|
|
|
|
; LINUX-DAG: movaps {{[0-9]*}}(%rsp), %xmm0
|
|
|
|
; LINUX-DAG: movaps {{[0-9]*}}(%rsp), %xmm1
|
|
|
|
; LINUX-DAG: movaps {{[0-9]*}}(%rsp), %xmm2
|
|
|
|
; LINUX-DAG: movaps {{[0-9]*}}(%rsp), %xmm3
|
|
|
|
; LINUX-DAG: movaps {{[0-9]*}}(%rsp), %xmm4
|
|
|
|
; LINUX-DAG: movaps {{[0-9]*}}(%rsp), %xmm5
|
|
|
|
; LINUX-DAG: movaps {{[0-9]*}}(%rsp), %xmm6
|
|
|
|
; LINUX-DAG: movaps {{[0-9]*}}(%rsp), %xmm7
|
|
|
|
; LINUX-DAG: movq {{.*}}, %rdi
|
|
|
|
; LINUX-DAG: movq {{.*}}, %rsi
|
|
|
|
; LINUX-DAG: movq {{.*}}, %rdx
|
|
|
|
; LINUX-DAG: movq {{.*}}, %rcx
|
|
|
|
; LINUX-DAG: movq {{.*}}, %r8
|
|
|
|
; LINUX-DAG: movq {{.*}}, %r9
|
|
|
|
; LINUX-DAG: movb {{.*}}, %al
|
|
|
|
; LINUX: jmpq *{{.*}} # TAILCALL
|
|
|
|
|
|
|
|
; WINDOWS-LABEL: f_thunk:
|
|
|
|
; WINDOWS-NOT: mov{{.}}ps
|
|
|
|
; WINDOWS-DAG: movq %rdx, {{.*}}
|
|
|
|
; WINDOWS-DAG: movq %rcx, {{.*}}
|
|
|
|
; WINDOWS-DAG: movq %r8, {{.*}}
|
|
|
|
; WINDOWS-DAG: movq %r9, {{.*}}
|
|
|
|
; WINDOWS-NOT: mov{{.}}ps
|
|
|
|
; WINDOWS: callq get_f
|
|
|
|
; WINDOWS-NOT: mov{{.}}ps
|
|
|
|
; WINDOWS-DAG: movq {{.*}}, %rdx
|
|
|
|
; WINDOWS-DAG: movq {{.*}}, %rcx
|
|
|
|
; WINDOWS-DAG: movq {{.*}}, %r8
|
|
|
|
; WINDOWS-DAG: movq {{.*}}, %r9
|
|
|
|
; WINDOWS-NOT: mov{{.}}ps
|
|
|
|
; WINDOWS: jmpq *{{.*}} # TAILCALL
|
|
|
|
|
2015-01-12 23:28:23 +00:00
|
|
|
; No regparms on normal x86 conventions.
|
|
|
|
|
|
|
|
; X86-LABEL: _f_thunk:
|
|
|
|
; X86: calll _get_f
|
|
|
|
; X86: jmpl *{{.*}} # TAILCALL
|
|
|
|
|
2014-08-29 21:42:08 +00:00
|
|
|
; This thunk shouldn't require any spills and reloads, assuming the register
|
|
|
|
; allocator knows what it's doing.
|
|
|
|
|
|
|
|
define void @g_thunk(i8* %fptr_i8, ...) {
|
|
|
|
%fptr = bitcast i8* %fptr_i8 to void (i8*, ...)*
|
|
|
|
musttail call void (i8*, ...)* %fptr(i8* %fptr_i8, ...)
|
|
|
|
ret void
|
|
|
|
}
|
|
|
|
|
|
|
|
; LINUX-LABEL: g_thunk:
|
|
|
|
; LINUX-NOT: movq
|
|
|
|
; LINUX: jmpq *%rdi # TAILCALL
|
|
|
|
|
|
|
|
; WINDOWS-LABEL: g_thunk:
|
|
|
|
; WINDOWS-NOT: movq
|
|
|
|
; WINDOWS: jmpq *%rcx # TAILCALL
|
|
|
|
|
2015-01-12 23:28:23 +00:00
|
|
|
; X86-LABEL: _g_thunk:
|
|
|
|
; X86: jmpl *%eax # TAILCALL
|
|
|
|
|
2014-08-29 21:42:08 +00:00
|
|
|
; Do a simple multi-exit multi-bb test.
|
|
|
|
|
|
|
|
%struct.Foo = type { i1, i8*, i8* }
|
|
|
|
|
|
|
|
@g = external global i32
|
|
|
|
|
|
|
|
define void @h_thunk(%struct.Foo* %this, ...) {
|
[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
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@230786 91177308-0d34-0410-b5e6-96231b3b80d8
2015-02-27 19:29:02 +00:00
|
|
|
%cond_p = getelementptr %struct.Foo, %struct.Foo* %this, i32 0, i32 0
|
2014-08-29 21:42:08 +00:00
|
|
|
%cond = load i1* %cond_p
|
|
|
|
br i1 %cond, label %then, label %else
|
|
|
|
|
|
|
|
then:
|
[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
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@230786 91177308-0d34-0410-b5e6-96231b3b80d8
2015-02-27 19:29:02 +00:00
|
|
|
%a_p = getelementptr %struct.Foo, %struct.Foo* %this, i32 0, i32 1
|
2014-08-29 21:42:08 +00:00
|
|
|
%a_i8 = load i8** %a_p
|
|
|
|
%a = bitcast i8* %a_i8 to void (%struct.Foo*, ...)*
|
|
|
|
musttail call void (%struct.Foo*, ...)* %a(%struct.Foo* %this, ...)
|
|
|
|
ret void
|
|
|
|
|
|
|
|
else:
|
[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
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@230786 91177308-0d34-0410-b5e6-96231b3b80d8
2015-02-27 19:29:02 +00:00
|
|
|
%b_p = getelementptr %struct.Foo, %struct.Foo* %this, i32 0, i32 2
|
2014-08-29 21:42:08 +00:00
|
|
|
%b_i8 = load i8** %b_p
|
|
|
|
%b = bitcast i8* %b_i8 to void (%struct.Foo*, ...)*
|
|
|
|
store i32 42, i32* @g
|
|
|
|
musttail call void (%struct.Foo*, ...)* %b(%struct.Foo* %this, ...)
|
|
|
|
ret void
|
|
|
|
}
|
|
|
|
|
|
|
|
; LINUX-LABEL: h_thunk:
|
|
|
|
; LINUX: jne
|
|
|
|
; LINUX: jmpq *{{.*}} # TAILCALL
|
|
|
|
; LINUX: jmpq *{{.*}} # TAILCALL
|
|
|
|
; WINDOWS-LABEL: h_thunk:
|
|
|
|
; WINDOWS: jne
|
|
|
|
; WINDOWS: jmpq *{{.*}} # TAILCALL
|
|
|
|
; WINDOWS: jmpq *{{.*}} # TAILCALL
|
2015-01-12 23:28:23 +00:00
|
|
|
; X86-LABEL: _h_thunk:
|
|
|
|
; X86: jne
|
|
|
|
; X86: jmpl *{{.*}} # TAILCALL
|
|
|
|
; X86: jmpl *{{.*}} # TAILCALL
|