2015-03-24 23:46:01 +00:00
|
|
|
; RUN: llc -mtriple=x86_64-windows-msvc < %s | FileCheck %s --check-prefix=X64
|
2015-10-12 19:43:34 +00:00
|
|
|
; RUN: llc -mtriple=i686-windows-msvc < %s | FileCheck %s --check-prefix=X86
|
2015-03-05 18:26:34 +00:00
|
|
|
|
|
|
|
declare i8* @llvm.frameaddress(i32)
|
2015-10-12 19:43:34 +00:00
|
|
|
declare void @llvm.localescape(...)
|
|
|
|
declare i8* @llvm.localaddress()
|
Rename llvm.frameescape and llvm.framerecover to localescape and localrecover
Summary:
Initially, these intrinsics seemed like part of a family of "frame"
related intrinsics, but now I think that's more confusing than helpful.
Initially, the LangRef specified that this would create a new kind of
allocation that would be allocated at a fixed offset from the frame
pointer (EBP/RBP). We ended up dropping that design, and leaving the
stack frame layout alone.
These intrinsics are really about sharing local stack allocations, not
frame pointers. I intend to go further and add an `llvm.localaddress()`
intrinsic that returns whatever register (EBP, ESI, ESP, RBX) is being
used to address locals, which should not be confused with the frame
pointer.
Naming suggestions at this point are welcome, I'm happy to re-run sed.
Reviewers: majnemer, nicholas
Subscribers: llvm-commits
Differential Revision: http://reviews.llvm.org/D11011
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@241633 91177308-0d34-0410-b5e6-96231b3b80d8
2015-07-07 22:25:32 +00:00
|
|
|
declare i8* @llvm.localrecover(i8*, i8*, i32)
|
2015-03-05 18:26:34 +00:00
|
|
|
declare i32 @printf(i8*, ...)
|
|
|
|
|
|
|
|
@str = internal constant [10 x i8] c"asdf: %d\0A\00"
|
|
|
|
|
|
|
|
define void @print_framealloc_from_fp(i8* %fp) {
|
2015-10-12 19:43:34 +00:00
|
|
|
%a.i8 = call i8* @llvm.localrecover(i8* bitcast (void(i32)* @alloc_func to i8*), i8* %fp, i32 0)
|
2015-03-05 18:26:34 +00:00
|
|
|
%a = bitcast i8* %a.i8 to i32*
|
|
|
|
%a.val = load i32, i32* %a
|
[opaque pointer type] Add textual IR support for explicit type parameter to the call instruction
See r230786 and r230794 for similar changes to gep and load
respectively.
Call is a bit different because it often doesn't have a single explicit
type - usually the type is deduced from the arguments, and just the
return type is explicit. In those cases there's no need to change the
IR.
When that's not the case, the IR usually contains the pointer type of
the first operand - but since typed pointers are going away, that
representation is insufficient so I'm just stripping the "pointerness"
of the explicit type away.
This does make the IR a bit weird - it /sort of/ reads like the type of
the first operand: "call void () %x(" but %x is actually of type "void
()*" and will eventually be just of type "ptr". But this seems not too
bad and I don't think it would benefit from repeating the type
("void (), void () * %x(" and then eventually "void (), ptr %x(") as has
been done with gep and load.
This also has a side benefit: since the explicit type is no longer a
pointer, there's no ambiguity between an explicit type and a function
that returns a function pointer. Previously this case needed an explicit
type (eg: a function returning a void() function was written as
"call void () () * @x(" rather than "call void () * @x(" because of the
ambiguity between a function returning a pointer to a void() function
and a function returning void).
No ambiguity means even function pointer return types can just be
written alone, without writing the whole function's type.
This leaves /only/ the varargs case where the explicit type is required.
Given the special type syntax in call instructions, the regex-fu used
for migration was a bit more involved in its own unique way (as every
one of these is) so here it is. Use it in conjunction with the apply.sh
script and associated find/xargs commands I've provided in rr230786 to
migrate your out of tree tests. Do let me know if any of this doesn't
cover your cases & we can iterate on a more general script/regexes to
help others with out of tree tests.
About 9 test cases couldn't be automatically migrated - half of those
were functions returning function pointers, where I just had to manually
delete the function argument types now that we didn't need an explicit
function type there. The other half were typedefs of function types used
in calls - just had to manually drop the * from those.
import fileinput
import sys
import re
pat = re.compile(r'((?:=|:|^|\s)call\s(?:[^@]*?))(\s*$|\s*(?:(?:\[\[[a-zA-Z0-9_]+\]\]|[@%](?:(")?[\\\?@a-zA-Z0-9_.]*?(?(3)"|)|{{.*}}))(?:\(|$)|undef|inttoptr|bitcast|null|asm).*$)')
addrspace_end = re.compile(r"addrspace\(\d+\)\s*\*$")
func_end = re.compile("(?:void.*|\)\s*)\*$")
def conv(match, line):
if not match or re.search(addrspace_end, match.group(1)) or not re.search(func_end, match.group(1)):
return line
return line[:match.start()] + match.group(1)[:match.group(1).rfind('*')].rstrip() + match.group(2) + line[match.end():]
for line in sys.stdin:
sys.stdout.write(conv(re.search(pat, line), line))
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@235145 91177308-0d34-0410-b5e6-96231b3b80d8
2015-04-16 23:24:18 +00:00
|
|
|
call i32 (i8*, ...) @printf(i8* getelementptr ([10 x i8], [10 x i8]* @str, i32 0, i32 0), i32 %a.val)
|
2015-10-12 19:43:34 +00:00
|
|
|
%b.i8 = call i8* @llvm.localrecover(i8* bitcast (void(i32)* @alloc_func to i8*), i8* %fp, i32 1)
|
2015-03-05 18:26:34 +00:00
|
|
|
%b = bitcast i8* %b.i8 to i32*
|
|
|
|
%b.val = load i32, i32* %b
|
[opaque pointer type] Add textual IR support for explicit type parameter to the call instruction
See r230786 and r230794 for similar changes to gep and load
respectively.
Call is a bit different because it often doesn't have a single explicit
type - usually the type is deduced from the arguments, and just the
return type is explicit. In those cases there's no need to change the
IR.
When that's not the case, the IR usually contains the pointer type of
the first operand - but since typed pointers are going away, that
representation is insufficient so I'm just stripping the "pointerness"
of the explicit type away.
This does make the IR a bit weird - it /sort of/ reads like the type of
the first operand: "call void () %x(" but %x is actually of type "void
()*" and will eventually be just of type "ptr". But this seems not too
bad and I don't think it would benefit from repeating the type
("void (), void () * %x(" and then eventually "void (), ptr %x(") as has
been done with gep and load.
This also has a side benefit: since the explicit type is no longer a
pointer, there's no ambiguity between an explicit type and a function
that returns a function pointer. Previously this case needed an explicit
type (eg: a function returning a void() function was written as
"call void () () * @x(" rather than "call void () * @x(" because of the
ambiguity between a function returning a pointer to a void() function
and a function returning void).
No ambiguity means even function pointer return types can just be
written alone, without writing the whole function's type.
This leaves /only/ the varargs case where the explicit type is required.
Given the special type syntax in call instructions, the regex-fu used
for migration was a bit more involved in its own unique way (as every
one of these is) so here it is. Use it in conjunction with the apply.sh
script and associated find/xargs commands I've provided in rr230786 to
migrate your out of tree tests. Do let me know if any of this doesn't
cover your cases & we can iterate on a more general script/regexes to
help others with out of tree tests.
About 9 test cases couldn't be automatically migrated - half of those
were functions returning function pointers, where I just had to manually
delete the function argument types now that we didn't need an explicit
function type there. The other half were typedefs of function types used
in calls - just had to manually drop the * from those.
import fileinput
import sys
import re
pat = re.compile(r'((?:=|:|^|\s)call\s(?:[^@]*?))(\s*$|\s*(?:(?:\[\[[a-zA-Z0-9_]+\]\]|[@%](?:(")?[\\\?@a-zA-Z0-9_.]*?(?(3)"|)|{{.*}}))(?:\(|$)|undef|inttoptr|bitcast|null|asm).*$)')
addrspace_end = re.compile(r"addrspace\(\d+\)\s*\*$")
func_end = re.compile("(?:void.*|\)\s*)\*$")
def conv(match, line):
if not match or re.search(addrspace_end, match.group(1)) or not re.search(func_end, match.group(1)):
return line
return line[:match.start()] + match.group(1)[:match.group(1).rfind('*')].rstrip() + match.group(2) + line[match.end():]
for line in sys.stdin:
sys.stdout.write(conv(re.search(pat, line), line))
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@235145 91177308-0d34-0410-b5e6-96231b3b80d8
2015-04-16 23:24:18 +00:00
|
|
|
call i32 (i8*, ...) @printf(i8* getelementptr ([10 x i8], [10 x i8]* @str, i32 0, i32 0), i32 %b.val)
|
2015-03-05 18:50:12 +00:00
|
|
|
store i32 42, i32* %b
|
2015-05-04 23:22:36 +00:00
|
|
|
%b2 = getelementptr i32, i32* %b, i32 1
|
|
|
|
%b2.val = load i32, i32* %b2
|
|
|
|
call i32 (i8*, ...) @printf(i8* getelementptr ([10 x i8], [10 x i8]* @str, i32 0, i32 0), i32 %b2.val)
|
2015-03-05 18:26:34 +00:00
|
|
|
ret void
|
|
|
|
}
|
|
|
|
|
2015-03-24 23:46:01 +00:00
|
|
|
; X64-LABEL: print_framealloc_from_fp:
|
|
|
|
; X64: movq %rcx, %[[parent_fp:[a-z]+]]
|
|
|
|
; X64: movl .Lalloc_func$frame_escape_0(%[[parent_fp]]), %edx
|
|
|
|
; X64: leaq {{.*}}(%rip), %[[str:[a-z]+]]
|
|
|
|
; X64: movq %[[str]], %rcx
|
|
|
|
; X64: callq printf
|
|
|
|
; X64: movl .Lalloc_func$frame_escape_1(%[[parent_fp]]), %edx
|
|
|
|
; X64: movq %[[str]], %rcx
|
|
|
|
; X64: callq printf
|
|
|
|
; X64: movl $42, .Lalloc_func$frame_escape_1(%[[parent_fp]])
|
|
|
|
; X64: retq
|
|
|
|
|
|
|
|
; X86-LABEL: print_framealloc_from_fp:
|
|
|
|
; X86: pushl %esi
|
2016-03-30 23:38:01 +00:00
|
|
|
; X86: movl 8(%esp), %esi
|
|
|
|
; X86: pushl Lalloc_func$frame_escape_0(%esi)
|
|
|
|
; X86: pushl $_str
|
2015-03-24 23:46:01 +00:00
|
|
|
; X86: calll _printf
|
2016-03-30 23:38:01 +00:00
|
|
|
; X86: addl $8, %esp
|
|
|
|
; X86: pushl Lalloc_func$frame_escape_1(%esi)
|
|
|
|
; X86: pushl $_str
|
2015-03-24 23:46:01 +00:00
|
|
|
; X86: calll _printf
|
2016-03-30 23:38:01 +00:00
|
|
|
; X86: addl $8, %esp
|
2015-04-29 16:46:01 +00:00
|
|
|
; X86: movl $42, Lalloc_func$frame_escape_1(%esi)
|
2015-05-04 23:22:36 +00:00
|
|
|
; X86: movl $4, %eax
|
2016-03-30 23:38:01 +00:00
|
|
|
; X86: pushl Lalloc_func$frame_escape_1(%esi,%eax)
|
|
|
|
; X86: pushl $_str
|
2015-05-04 23:22:36 +00:00
|
|
|
; X86: calll _printf
|
2015-03-24 23:46:01 +00:00
|
|
|
; X86: addl $8, %esp
|
|
|
|
; X86: popl %esi
|
|
|
|
; X86: retl
|
2015-03-05 18:26:34 +00:00
|
|
|
|
2015-10-12 19:43:34 +00:00
|
|
|
define void @alloc_func(i32 %n) {
|
2015-03-05 18:26:34 +00:00
|
|
|
%a = alloca i32
|
2015-05-04 23:22:36 +00:00
|
|
|
%b = alloca i32, i32 2
|
Rename llvm.frameescape and llvm.framerecover to localescape and localrecover
Summary:
Initially, these intrinsics seemed like part of a family of "frame"
related intrinsics, but now I think that's more confusing than helpful.
Initially, the LangRef specified that this would create a new kind of
allocation that would be allocated at a fixed offset from the frame
pointer (EBP/RBP). We ended up dropping that design, and leaving the
stack frame layout alone.
These intrinsics are really about sharing local stack allocations, not
frame pointers. I intend to go further and add an `llvm.localaddress()`
intrinsic that returns whatever register (EBP, ESI, ESP, RBX) is being
used to address locals, which should not be confused with the frame
pointer.
Naming suggestions at this point are welcome, I'm happy to re-run sed.
Reviewers: majnemer, nicholas
Subscribers: llvm-commits
Differential Revision: http://reviews.llvm.org/D11011
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@241633 91177308-0d34-0410-b5e6-96231b3b80d8
2015-07-07 22:25:32 +00:00
|
|
|
call void (...) @llvm.localescape(i32* %a, i32* %b)
|
2015-03-05 18:26:34 +00:00
|
|
|
store i32 42, i32* %a
|
|
|
|
store i32 13, i32* %b
|
2015-10-12 19:43:34 +00:00
|
|
|
|
|
|
|
; Force usage of EBP with a dynamic alloca.
|
|
|
|
alloca i8, i32 %n
|
|
|
|
|
|
|
|
%lp = call i8* @llvm.localaddress()
|
|
|
|
call void @print_framealloc_from_fp(i8* %lp)
|
2015-03-05 18:26:34 +00:00
|
|
|
ret void
|
|
|
|
}
|
|
|
|
|
2015-03-24 23:46:01 +00:00
|
|
|
; X64-LABEL: alloc_func:
|
2015-10-12 19:43:34 +00:00
|
|
|
; X64: pushq %rbp
|
|
|
|
; X64: subq $16, %rsp
|
|
|
|
; X64: .seh_stackalloc 16
|
|
|
|
; X64: leaq 16(%rsp), %rbp
|
|
|
|
; X64: .seh_setframe 5, 16
|
|
|
|
; X64: .Lalloc_func$frame_escape_0 = -4
|
|
|
|
; X64: .Lalloc_func$frame_escape_1 = -12
|
2015-03-24 23:46:01 +00:00
|
|
|
; X64: movl $42, -4(%rbp)
|
2015-05-04 23:22:36 +00:00
|
|
|
; X64: movl $13, -12(%rbp)
|
2015-10-12 19:43:34 +00:00
|
|
|
; X64: movq %rbp, %rcx
|
2015-03-24 23:46:01 +00:00
|
|
|
; X64: callq print_framealloc_from_fp
|
|
|
|
; X64: retq
|
|
|
|
|
|
|
|
; X86-LABEL: alloc_func:
|
|
|
|
; X86: pushl %ebp
|
|
|
|
; X86: movl %esp, %ebp
|
2015-10-12 19:43:34 +00:00
|
|
|
; X86: subl $12, %esp
|
2015-03-24 23:46:01 +00:00
|
|
|
; X86: Lalloc_func$frame_escape_0 = -4
|
2015-05-04 23:22:36 +00:00
|
|
|
; X86: Lalloc_func$frame_escape_1 = -12
|
2015-03-24 23:46:01 +00:00
|
|
|
; X86: movl $42, -4(%ebp)
|
2015-05-04 23:22:36 +00:00
|
|
|
; X86: movl $13, -12(%ebp)
|
2015-10-12 19:43:34 +00:00
|
|
|
; X86: pushl %ebp
|
2015-03-24 23:46:01 +00:00
|
|
|
; X86: calll _print_framealloc_from_fp
|
2015-10-12 19:43:34 +00:00
|
|
|
; X86: movl %ebp, %esp
|
2015-03-24 23:46:01 +00:00
|
|
|
; X86: popl %ebp
|
|
|
|
; X86: retl
|
2015-03-05 18:26:34 +00:00
|
|
|
|
|
|
|
; Helper to make this a complete program so it can be compiled and tested.
|
|
|
|
define i32 @main() {
|
2015-10-12 19:43:34 +00:00
|
|
|
call void @alloc_func(i32 3)
|
2015-03-05 18:26:34 +00:00
|
|
|
ret i32 0
|
|
|
|
}
|
2015-03-24 23:46:01 +00:00
|
|
|
|
|
|
|
define void @alloc_func_no_frameaddr() {
|
|
|
|
%a = alloca i32
|
|
|
|
%b = alloca i32
|
Rename llvm.frameescape and llvm.framerecover to localescape and localrecover
Summary:
Initially, these intrinsics seemed like part of a family of "frame"
related intrinsics, but now I think that's more confusing than helpful.
Initially, the LangRef specified that this would create a new kind of
allocation that would be allocated at a fixed offset from the frame
pointer (EBP/RBP). We ended up dropping that design, and leaving the
stack frame layout alone.
These intrinsics are really about sharing local stack allocations, not
frame pointers. I intend to go further and add an `llvm.localaddress()`
intrinsic that returns whatever register (EBP, ESI, ESP, RBX) is being
used to address locals, which should not be confused with the frame
pointer.
Naming suggestions at this point are welcome, I'm happy to re-run sed.
Reviewers: majnemer, nicholas
Subscribers: llvm-commits
Differential Revision: http://reviews.llvm.org/D11011
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@241633 91177308-0d34-0410-b5e6-96231b3b80d8
2015-07-07 22:25:32 +00:00
|
|
|
call void (...) @llvm.localescape(i32* %a, i32* %b)
|
2015-03-24 23:46:01 +00:00
|
|
|
store i32 42, i32* %a
|
|
|
|
store i32 13, i32* %b
|
|
|
|
call void @print_framealloc_from_fp(i8* null)
|
|
|
|
ret void
|
|
|
|
}
|
|
|
|
|
|
|
|
; X64-LABEL: alloc_func_no_frameaddr:
|
|
|
|
; X64: subq $40, %rsp
|
|
|
|
; X64: .seh_stackalloc 40
|
|
|
|
; X64: .seh_endprologue
|
|
|
|
; X64: .Lalloc_func_no_frameaddr$frame_escape_0 = 36
|
|
|
|
; X64: .Lalloc_func_no_frameaddr$frame_escape_1 = 32
|
|
|
|
; X64: movl $42, 36(%rsp)
|
|
|
|
; X64: movl $13, 32(%rsp)
|
|
|
|
; X64: xorl %ecx, %ecx
|
|
|
|
; X64: callq print_framealloc_from_fp
|
|
|
|
; X64: addq $40, %rsp
|
|
|
|
; X64: retq
|
2015-05-04 23:22:36 +00:00
|
|
|
|
|
|
|
; X86-LABEL: alloc_func_no_frameaddr:
|
2016-03-30 23:38:01 +00:00
|
|
|
; X86: subl $8, %esp
|
|
|
|
; X86: Lalloc_func_no_frameaddr$frame_escape_0 = 4
|
|
|
|
; X86: Lalloc_func_no_frameaddr$frame_escape_1 = 0
|
|
|
|
; X86: movl $42, 4(%esp)
|
|
|
|
; X86: movl $13, (%esp)
|
|
|
|
; X86: pushl $0
|
2015-10-12 19:43:34 +00:00
|
|
|
; X86: calll _print_framealloc_from_fp
|
2016-04-07 00:05:49 +00:00
|
|
|
; X86: addl $12, %esp
|
2015-10-12 19:43:34 +00:00
|
|
|
; X86: retl
|