2016-03-03 03:20:00 +08:00
|
|
|
; RUN: llc < %s -mtriple=thumbv7-apple-ios -mcpu=cortex-a8 -regalloc=fast -optimize-regalloc=0 -verify-machineinstrs | FileCheck %s -check-prefix=A8 -check-prefix=CHECK -check-prefix=NORMAL
|
|
|
|
; RUN: llc < %s -mtriple=thumbv7-apple-ios -mcpu=cortex-m3 -regalloc=fast -optimize-regalloc=0 | FileCheck %s -check-prefix=M3 -check-prefix=CHECK -check-prefix=NORMAL
|
2011-11-09 05:21:09 +08:00
|
|
|
; rdar://6949835
|
2016-03-03 03:20:00 +08:00
|
|
|
; RUN: llc < %s -mtriple=thumbv7-apple-ios -mcpu=cortex-a8 -regalloc=basic | FileCheck %s -check-prefix=BASIC -check-prefix=CHECK -check-prefix=NORMAL
|
|
|
|
; RUN: llc < %s -mtriple=thumbv7-apple-ios -mcpu=cortex-a8 -regalloc=greedy | FileCheck %s -check-prefix=GREEDY -check-prefix=CHECK -check-prefix=NORMAL
|
|
|
|
; RUN: llc < %s -mtriple=thumbv7-apple-ios -mcpu=swift | FileCheck %s -check-prefix=SWIFT -check-prefix=CHECK -check-prefix=NORMAL
|
|
|
|
|
|
|
|
; RUN: llc < %s -mtriple=thumbv7-apple-ios -arm-assume-misaligned-load-store | FileCheck %s -check-prefix=CHECK -check-prefix=CONSERVATIVE
|
2009-06-15 16:28:29 +08:00
|
|
|
|
2011-11-09 05:21:09 +08:00
|
|
|
; Magic ARM pair hints works best with linearscan / fast.
|
|
|
|
|
2009-06-15 16:28:29 +08:00
|
|
|
@b = external global i64*
|
|
|
|
|
2015-06-25 04:03:27 +08:00
|
|
|
; We use the following two to force values into specific registers.
|
|
|
|
declare i64* @get_ptr()
|
|
|
|
declare void @use_i64(i64 %v)
|
2009-09-26 10:41:17 +08:00
|
|
|
|
[ARM] Generate consistent frame records for Thumb2
There is not an official documented ABI for frame pointers in Thumb2,
but we should try to emit something which is useful.
We use r7 as the frame pointer for Thumb code, which currently means
that if a function needs to save a high register (r8-r11), it will get
pushed to the stack between the frame pointer (r7) and link register
(r14). This means that while a stack unwinder can follow the chain of
frame pointers up the stack, it cannot know the offset to lr, so does
not know which functions correspond to the stack frames.
To fix this, we need to push the callee-saved registers in two batches,
with the first push saving the low registers, fp and lr, and the second
push saving the high registers. This is already implemented, but
previously only used for iOS. This patch turns it on for all Thumb2
targets when frame pointers are required by the ABI, and the frame
pointer is r7 (Windows uses r11, so this isn't a problem there). If
frame pointer elimination is enabled we still emit a single push/pop
even if we need a frame pointer for other reasons, to avoid increasing
code size.
We must also ensure that lr is pushed to the stack when using a frame
pointer, so that we end up with a complete frame record. Situations that
could cause this were rare, because we already push lr in most
situations so that we can return using the pop instruction.
Differential Revision: https://reviews.llvm.org/D23516
llvm-svn: 279506
2016-08-23 17:19:22 +08:00
|
|
|
define void @test_ldrd(i64 %a) nounwind readonly "no-frame-pointer-elim"="true" {
|
2015-06-25 04:03:27 +08:00
|
|
|
; CHECK-LABEL: test_ldrd:
|
2016-03-03 03:20:00 +08:00
|
|
|
; NORMAL: bl{{x?}} _get_ptr
|
2015-06-25 04:03:27 +08:00
|
|
|
; A8: ldrd r0, r1, [r0]
|
|
|
|
; Cortex-M3 errata 602117: LDRD with base in list may result in incorrect base
|
|
|
|
; register when interrupted or faulted.
|
|
|
|
; M3-NOT: ldrd r[[REGNUM:[0-9]+]], {{r[0-9]+}}, [r[[REGNUM]]]
|
2016-03-03 03:20:00 +08:00
|
|
|
; CONSERVATIVE-NOT: ldrd
|
|
|
|
; NORMAL: bl{{x?}} _use_i64
|
2015-06-25 04:03:27 +08:00
|
|
|
%ptr = call i64* @get_ptr()
|
|
|
|
%v = load i64, i64* %ptr, align 8
|
|
|
|
call void @use_i64(i64 %v)
|
|
|
|
ret void
|
2009-06-15 16:28:29 +08:00
|
|
|
}
|
2012-01-11 11:56:08 +08:00
|
|
|
|
|
|
|
; rdar://10435045 mixed LDRi8/LDRi12
|
|
|
|
;
|
|
|
|
; In this case, LSR generate a sequence of LDRi8/LDRi12. We should be
|
|
|
|
; able to generate an LDRD pair here, but this is highly sensitive to
|
|
|
|
; regalloc hinting. So, this doubles as a register allocation
|
|
|
|
; test. RABasic currently does a better job within the inner loop
|
|
|
|
; because of its *lack* of hinting ability. Whereas RAGreedy keeps
|
|
|
|
; R0/R1/R2 live as the three arguments, forcing the LDRD's odd
|
|
|
|
; destination into R3. We then sensibly split LDRD again rather then
|
|
|
|
; evict another live range or use callee saved regs. Sorry if the test
|
|
|
|
; is sensitive to Regalloc changes, but it is an interesting case.
|
|
|
|
;
|
2016-03-03 03:20:00 +08:00
|
|
|
; CHECK-LABEL: f:
|
2012-01-11 11:56:08 +08:00
|
|
|
; BASIC: %bb
|
|
|
|
; BASIC: ldrd
|
|
|
|
; BASIC: str
|
|
|
|
; GREEDY: %bb
|
2012-04-03 06:30:39 +08:00
|
|
|
; GREEDY: ldrd
|
2012-01-11 11:56:08 +08:00
|
|
|
; GREEDY: str
|
[ARM] Generate consistent frame records for Thumb2
There is not an official documented ABI for frame pointers in Thumb2,
but we should try to emit something which is useful.
We use r7 as the frame pointer for Thumb code, which currently means
that if a function needs to save a high register (r8-r11), it will get
pushed to the stack between the frame pointer (r7) and link register
(r14). This means that while a stack unwinder can follow the chain of
frame pointers up the stack, it cannot know the offset to lr, so does
not know which functions correspond to the stack frames.
To fix this, we need to push the callee-saved registers in two batches,
with the first push saving the low registers, fp and lr, and the second
push saving the high registers. This is already implemented, but
previously only used for iOS. This patch turns it on for all Thumb2
targets when frame pointers are required by the ABI, and the frame
pointer is r7 (Windows uses r11, so this isn't a problem there). If
frame pointer elimination is enabled we still emit a single push/pop
even if we need a frame pointer for other reasons, to avoid increasing
code size.
We must also ensure that lr is pushed to the stack when using a frame
pointer, so that we end up with a complete frame record. Situations that
could cause this were rare, because we already push lr in most
situations so that we can return using the pop instruction.
Differential Revision: https://reviews.llvm.org/D23516
llvm-svn: 279506
2016-08-23 17:19:22 +08:00
|
|
|
define void @f(i32* nocapture %a, i32* nocapture %b, i32 %n) nounwind "no-frame-pointer-elim"="true" {
|
2012-01-11 11:56:08 +08:00
|
|
|
entry:
|
|
|
|
%0 = add nsw i32 %n, -1 ; <i32> [#uses=2]
|
|
|
|
%1 = icmp sgt i32 %0, 0 ; <i1> [#uses=1]
|
|
|
|
br i1 %1, label %bb, label %return
|
|
|
|
|
|
|
|
bb: ; preds = %bb, %entry
|
|
|
|
%i.03 = phi i32 [ %tmp, %bb ], [ 0, %entry ] ; <i32> [#uses=3]
|
[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
|
|
|
%scevgep = getelementptr i32, i32* %a, i32 %i.03 ; <i32*> [#uses=1]
|
|
|
|
%scevgep4 = getelementptr i32, i32* %b, i32 %i.03 ; <i32*> [#uses=1]
|
2012-01-11 11:56:08 +08:00
|
|
|
%tmp = add i32 %i.03, 1 ; <i32> [#uses=3]
|
[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
|
|
|
%scevgep5 = getelementptr i32, i32* %a, i32 %tmp ; <i32*> [#uses=1]
|
2015-02-28 05:17:42 +08:00
|
|
|
%2 = load i32, i32* %scevgep, align 4 ; <i32> [#uses=1]
|
|
|
|
%3 = load i32, i32* %scevgep5, align 4 ; <i32> [#uses=1]
|
2012-01-11 11:56:08 +08:00
|
|
|
%4 = add nsw i32 %3, %2 ; <i32> [#uses=1]
|
|
|
|
store i32 %4, i32* %scevgep4, align 4
|
|
|
|
%exitcond = icmp eq i32 %tmp, %0 ; <i1> [#uses=1]
|
|
|
|
br i1 %exitcond, label %return, label %bb
|
|
|
|
|
|
|
|
return: ; preds = %bb, %entry
|
|
|
|
ret void
|
|
|
|
}
|
2013-06-21 06:51:44 +08:00
|
|
|
|
|
|
|
; rdar://13978317
|
|
|
|
; Pair of loads not formed when lifetime markers are set.
|
|
|
|
%struct.Test = type { i32, i32, i32 }
|
|
|
|
|
|
|
|
@TestVar = external global %struct.Test
|
|
|
|
|
2016-03-03 03:20:00 +08:00
|
|
|
; CHECK-LABEL: Func1:
|
[ARM] Generate consistent frame records for Thumb2
There is not an official documented ABI for frame pointers in Thumb2,
but we should try to emit something which is useful.
We use r7 as the frame pointer for Thumb code, which currently means
that if a function needs to save a high register (r8-r11), it will get
pushed to the stack between the frame pointer (r7) and link register
(r14). This means that while a stack unwinder can follow the chain of
frame pointers up the stack, it cannot know the offset to lr, so does
not know which functions correspond to the stack frames.
To fix this, we need to push the callee-saved registers in two batches,
with the first push saving the low registers, fp and lr, and the second
push saving the high registers. This is already implemented, but
previously only used for iOS. This patch turns it on for all Thumb2
targets when frame pointers are required by the ABI, and the frame
pointer is r7 (Windows uses r11, so this isn't a problem there). If
frame pointer elimination is enabled we still emit a single push/pop
even if we need a frame pointer for other reasons, to avoid increasing
code size.
We must also ensure that lr is pushed to the stack when using a frame
pointer, so that we end up with a complete frame record. Situations that
could cause this were rare, because we already push lr in most
situations so that we can return using the pop instruction.
Differential Revision: https://reviews.llvm.org/D23516
llvm-svn: 279506
2016-08-23 17:19:22 +08:00
|
|
|
define void @Func1() nounwind ssp "no-frame-pointer-elim"="true" {
|
2013-06-21 06:51:44 +08:00
|
|
|
entry:
|
|
|
|
; A8: movw [[BASE:r[0-9]+]], :lower16:{{.*}}TestVar{{.*}}
|
|
|
|
; A8: movt [[BASE]], :upper16:{{.*}}TestVar{{.*}}
|
|
|
|
; A8: ldrd [[FIELD1:r[0-9]+]], [[FIELD2:r[0-9]+]], {{\[}}[[BASE]], #4]
|
|
|
|
; A8-NEXT: add [[FIELD1]], [[FIELD2]]
|
|
|
|
; A8-NEXT: str [[FIELD1]], {{\[}}[[BASE]]{{\]}}
|
2016-03-03 03:20:00 +08:00
|
|
|
; CONSERVATIVE-NOT: ldrd
|
2013-06-21 06:51:44 +08:00
|
|
|
%orig_blocks = alloca [256 x i16], align 2
|
|
|
|
%0 = bitcast [256 x i16]* %orig_blocks to i8*call void @llvm.lifetime.start(i64 512, i8* %0) nounwind
|
2015-03-14 02:20:45 +08:00
|
|
|
%tmp1 = load i32, i32* getelementptr inbounds (%struct.Test, %struct.Test* @TestVar, i32 0, i32 1), align 4
|
|
|
|
%tmp2 = load i32, i32* getelementptr inbounds (%struct.Test, %struct.Test* @TestVar, i32 0, i32 2), align 4
|
2013-06-21 06:51:44 +08:00
|
|
|
%add = add nsw i32 %tmp2, %tmp1
|
2015-03-14 02:20:45 +08:00
|
|
|
store i32 %add, i32* getelementptr inbounds (%struct.Test, %struct.Test* @TestVar, i32 0, i32 0), align 4
|
2013-06-21 06:51:44 +08:00
|
|
|
call void @llvm.lifetime.end(i64 512, i8* %0) nounwind
|
|
|
|
ret void
|
|
|
|
}
|
|
|
|
|
2015-06-04 00:30:24 +08:00
|
|
|
declare void @extfunc(i32, i32, i32, i32)
|
|
|
|
|
|
|
|
; CHECK-LABEL: Func2:
|
2016-03-03 03:20:00 +08:00
|
|
|
; CONSERVATIVE-NOT: ldrd
|
2015-06-04 00:30:24 +08:00
|
|
|
; A8: ldrd
|
2016-03-03 03:20:00 +08:00
|
|
|
; CHECK: bl{{x?}} _extfunc
|
2015-06-04 00:30:24 +08:00
|
|
|
; A8: pop
|
[ARM] Generate consistent frame records for Thumb2
There is not an official documented ABI for frame pointers in Thumb2,
but we should try to emit something which is useful.
We use r7 as the frame pointer for Thumb code, which currently means
that if a function needs to save a high register (r8-r11), it will get
pushed to the stack between the frame pointer (r7) and link register
(r14). This means that while a stack unwinder can follow the chain of
frame pointers up the stack, it cannot know the offset to lr, so does
not know which functions correspond to the stack frames.
To fix this, we need to push the callee-saved registers in two batches,
with the first push saving the low registers, fp and lr, and the second
push saving the high registers. This is already implemented, but
previously only used for iOS. This patch turns it on for all Thumb2
targets when frame pointers are required by the ABI, and the frame
pointer is r7 (Windows uses r11, so this isn't a problem there). If
frame pointer elimination is enabled we still emit a single push/pop
even if we need a frame pointer for other reasons, to avoid increasing
code size.
We must also ensure that lr is pushed to the stack when using a frame
pointer, so that we end up with a complete frame record. Situations that
could cause this were rare, because we already push lr in most
situations so that we can return using the pop instruction.
Differential Revision: https://reviews.llvm.org/D23516
llvm-svn: 279506
2016-08-23 17:19:22 +08:00
|
|
|
define void @Func2(i32* %p) "no-frame-pointer-elim"="true" {
|
2015-06-04 00:30:24 +08:00
|
|
|
entry:
|
|
|
|
%addr0 = getelementptr i32, i32* %p, i32 0
|
|
|
|
%addr1 = getelementptr i32, i32* %p, i32 1
|
|
|
|
%v0 = load i32, i32* %addr0
|
|
|
|
%v1 = load i32, i32* %addr1
|
|
|
|
; try to force %v0/%v1 into non-adjacent registers
|
|
|
|
call void @extfunc(i32 %v0, i32 0, i32 0, i32 %v1)
|
|
|
|
ret void
|
|
|
|
}
|
2013-06-21 06:51:44 +08:00
|
|
|
|
2015-07-21 08:18:59 +08:00
|
|
|
; CHECK-LABEL: strd_spill_ldrd_reload:
|
2015-07-21 08:19:01 +08:00
|
|
|
; A8: strd r1, r0, [sp, #-8]!
|
|
|
|
; M3: strd r1, r0, [sp, #-8]!
|
|
|
|
; BASIC: strd r1, r0, [sp, #-8]!
|
|
|
|
; GREEDY: strd r0, r1, [sp, #-8]!
|
2016-03-03 03:20:00 +08:00
|
|
|
; CONSERVATIVE: strd r0, r1, [sp, #-8]!
|
|
|
|
; NORMAL: @ InlineAsm Start
|
|
|
|
; NORMAL: @ InlineAsm End
|
2015-07-21 08:18:59 +08:00
|
|
|
; A8: ldrd r2, r1, [sp]
|
|
|
|
; M3: ldrd r2, r1, [sp]
|
|
|
|
; BASIC: ldrd r2, r1, [sp]
|
|
|
|
; GREEDY: ldrd r1, r2, [sp]
|
2016-03-03 03:20:00 +08:00
|
|
|
; CONSERVATIVE: ldrd r1, r2, [sp]
|
2015-07-21 08:18:59 +08:00
|
|
|
; CHECK: bl{{x?}} _extfunc
|
[ARM] Generate consistent frame records for Thumb2
There is not an official documented ABI for frame pointers in Thumb2,
but we should try to emit something which is useful.
We use r7 as the frame pointer for Thumb code, which currently means
that if a function needs to save a high register (r8-r11), it will get
pushed to the stack between the frame pointer (r7) and link register
(r14). This means that while a stack unwinder can follow the chain of
frame pointers up the stack, it cannot know the offset to lr, so does
not know which functions correspond to the stack frames.
To fix this, we need to push the callee-saved registers in two batches,
with the first push saving the low registers, fp and lr, and the second
push saving the high registers. This is already implemented, but
previously only used for iOS. This patch turns it on for all Thumb2
targets when frame pointers are required by the ABI, and the frame
pointer is r7 (Windows uses r11, so this isn't a problem there). If
frame pointer elimination is enabled we still emit a single push/pop
even if we need a frame pointer for other reasons, to avoid increasing
code size.
We must also ensure that lr is pushed to the stack when using a frame
pointer, so that we end up with a complete frame record. Situations that
could cause this were rare, because we already push lr in most
situations so that we can return using the pop instruction.
Differential Revision: https://reviews.llvm.org/D23516
llvm-svn: 279506
2016-08-23 17:19:22 +08:00
|
|
|
define void @strd_spill_ldrd_reload(i32 %v0, i32 %v1) "no-frame-pointer-elim"="true" {
|
2015-07-21 08:18:59 +08:00
|
|
|
; force %v0 and %v1 to be spilled
|
|
|
|
call void asm sideeffect "", "~{r0},~{r1},~{r2},~{r3},~{r4},~{r5},~{r6},~{r7},~{r8},~{r9},~{r10},~{r11},~{r12},~{lr}"()
|
|
|
|
; force the reloaded %v0, %v1 into different registers
|
|
|
|
call void @extfunc(i32 0, i32 %v0, i32 %v1, i32 7)
|
|
|
|
ret void
|
|
|
|
}
|
|
|
|
|
2015-07-21 08:19:01 +08:00
|
|
|
declare void @extfunc2(i32*, i32, i32)
|
|
|
|
|
|
|
|
; CHECK-LABEL: ldrd_postupdate_dec:
|
2016-03-03 03:20:00 +08:00
|
|
|
; NORMAL: ldrd r1, r2, [r0], #-8
|
|
|
|
; CONSERVATIVE-NOT: ldrd
|
|
|
|
; CHECK: bl{{x?}} _extfunc
|
[ARM] Generate consistent frame records for Thumb2
There is not an official documented ABI for frame pointers in Thumb2,
but we should try to emit something which is useful.
We use r7 as the frame pointer for Thumb code, which currently means
that if a function needs to save a high register (r8-r11), it will get
pushed to the stack between the frame pointer (r7) and link register
(r14). This means that while a stack unwinder can follow the chain of
frame pointers up the stack, it cannot know the offset to lr, so does
not know which functions correspond to the stack frames.
To fix this, we need to push the callee-saved registers in two batches,
with the first push saving the low registers, fp and lr, and the second
push saving the high registers. This is already implemented, but
previously only used for iOS. This patch turns it on for all Thumb2
targets when frame pointers are required by the ABI, and the frame
pointer is r7 (Windows uses r11, so this isn't a problem there). If
frame pointer elimination is enabled we still emit a single push/pop
even if we need a frame pointer for other reasons, to avoid increasing
code size.
We must also ensure that lr is pushed to the stack when using a frame
pointer, so that we end up with a complete frame record. Situations that
could cause this were rare, because we already push lr in most
situations so that we can return using the pop instruction.
Differential Revision: https://reviews.llvm.org/D23516
llvm-svn: 279506
2016-08-23 17:19:22 +08:00
|
|
|
define void @ldrd_postupdate_dec(i32* %p0) "no-frame-pointer-elim"="true" {
|
2015-07-21 08:19:01 +08:00
|
|
|
%p0.1 = getelementptr i32, i32* %p0, i32 1
|
|
|
|
%v0 = load i32, i32* %p0
|
|
|
|
%v1 = load i32, i32* %p0.1
|
|
|
|
%p1 = getelementptr i32, i32* %p0, i32 -2
|
|
|
|
call void @extfunc2(i32* %p1, i32 %v0, i32 %v1)
|
|
|
|
ret void
|
|
|
|
}
|
|
|
|
|
|
|
|
; CHECK-LABEL: ldrd_postupdate_inc:
|
2016-03-03 03:20:00 +08:00
|
|
|
; NORMAL: ldrd r1, r2, [r0], #8
|
|
|
|
; CONSERVATIVE-NOT: ldrd
|
|
|
|
; CHECK: bl{{x?}} _extfunc
|
[ARM] Generate consistent frame records for Thumb2
There is not an official documented ABI for frame pointers in Thumb2,
but we should try to emit something which is useful.
We use r7 as the frame pointer for Thumb code, which currently means
that if a function needs to save a high register (r8-r11), it will get
pushed to the stack between the frame pointer (r7) and link register
(r14). This means that while a stack unwinder can follow the chain of
frame pointers up the stack, it cannot know the offset to lr, so does
not know which functions correspond to the stack frames.
To fix this, we need to push the callee-saved registers in two batches,
with the first push saving the low registers, fp and lr, and the second
push saving the high registers. This is already implemented, but
previously only used for iOS. This patch turns it on for all Thumb2
targets when frame pointers are required by the ABI, and the frame
pointer is r7 (Windows uses r11, so this isn't a problem there). If
frame pointer elimination is enabled we still emit a single push/pop
even if we need a frame pointer for other reasons, to avoid increasing
code size.
We must also ensure that lr is pushed to the stack when using a frame
pointer, so that we end up with a complete frame record. Situations that
could cause this were rare, because we already push lr in most
situations so that we can return using the pop instruction.
Differential Revision: https://reviews.llvm.org/D23516
llvm-svn: 279506
2016-08-23 17:19:22 +08:00
|
|
|
define void @ldrd_postupdate_inc(i32* %p0) "no-frame-pointer-elim"="true" {
|
2015-07-21 08:19:01 +08:00
|
|
|
%p0.1 = getelementptr i32, i32* %p0, i32 1
|
|
|
|
%v0 = load i32, i32* %p0
|
|
|
|
%v1 = load i32, i32* %p0.1
|
|
|
|
%p1 = getelementptr i32, i32* %p0, i32 2
|
|
|
|
call void @extfunc2(i32* %p1, i32 %v0, i32 %v1)
|
|
|
|
ret void
|
|
|
|
}
|
|
|
|
|
|
|
|
; CHECK-LABEL: strd_postupdate_dec:
|
2016-03-03 03:20:00 +08:00
|
|
|
; NORMAL: strd r1, r2, [r0], #-8
|
|
|
|
; CONSERVATIVE-NOT: strd
|
|
|
|
; CHECK: bx lr
|
[ARM] Generate consistent frame records for Thumb2
There is not an official documented ABI for frame pointers in Thumb2,
but we should try to emit something which is useful.
We use r7 as the frame pointer for Thumb code, which currently means
that if a function needs to save a high register (r8-r11), it will get
pushed to the stack between the frame pointer (r7) and link register
(r14). This means that while a stack unwinder can follow the chain of
frame pointers up the stack, it cannot know the offset to lr, so does
not know which functions correspond to the stack frames.
To fix this, we need to push the callee-saved registers in two batches,
with the first push saving the low registers, fp and lr, and the second
push saving the high registers. This is already implemented, but
previously only used for iOS. This patch turns it on for all Thumb2
targets when frame pointers are required by the ABI, and the frame
pointer is r7 (Windows uses r11, so this isn't a problem there). If
frame pointer elimination is enabled we still emit a single push/pop
even if we need a frame pointer for other reasons, to avoid increasing
code size.
We must also ensure that lr is pushed to the stack when using a frame
pointer, so that we end up with a complete frame record. Situations that
could cause this were rare, because we already push lr in most
situations so that we can return using the pop instruction.
Differential Revision: https://reviews.llvm.org/D23516
llvm-svn: 279506
2016-08-23 17:19:22 +08:00
|
|
|
define i32* @strd_postupdate_dec(i32* %p0, i32 %v0, i32 %v1) "no-frame-pointer-elim"="true" {
|
2015-07-21 08:19:01 +08:00
|
|
|
%p0.1 = getelementptr i32, i32* %p0, i32 1
|
|
|
|
store i32 %v0, i32* %p0
|
|
|
|
store i32 %v1, i32* %p0.1
|
|
|
|
%p1 = getelementptr i32, i32* %p0, i32 -2
|
|
|
|
ret i32* %p1
|
|
|
|
}
|
|
|
|
|
|
|
|
; CHECK-LABEL: strd_postupdate_inc:
|
2016-03-03 03:20:00 +08:00
|
|
|
; NORMAL: strd r1, r2, [r0], #8
|
|
|
|
; CONSERVATIVE-NOT: strd
|
|
|
|
; CHECK: bx lr
|
[ARM] Generate consistent frame records for Thumb2
There is not an official documented ABI for frame pointers in Thumb2,
but we should try to emit something which is useful.
We use r7 as the frame pointer for Thumb code, which currently means
that if a function needs to save a high register (r8-r11), it will get
pushed to the stack between the frame pointer (r7) and link register
(r14). This means that while a stack unwinder can follow the chain of
frame pointers up the stack, it cannot know the offset to lr, so does
not know which functions correspond to the stack frames.
To fix this, we need to push the callee-saved registers in two batches,
with the first push saving the low registers, fp and lr, and the second
push saving the high registers. This is already implemented, but
previously only used for iOS. This patch turns it on for all Thumb2
targets when frame pointers are required by the ABI, and the frame
pointer is r7 (Windows uses r11, so this isn't a problem there). If
frame pointer elimination is enabled we still emit a single push/pop
even if we need a frame pointer for other reasons, to avoid increasing
code size.
We must also ensure that lr is pushed to the stack when using a frame
pointer, so that we end up with a complete frame record. Situations that
could cause this were rare, because we already push lr in most
situations so that we can return using the pop instruction.
Differential Revision: https://reviews.llvm.org/D23516
llvm-svn: 279506
2016-08-23 17:19:22 +08:00
|
|
|
define i32* @strd_postupdate_inc(i32* %p0, i32 %v0, i32 %v1) "no-frame-pointer-elim"="true" {
|
2015-07-21 08:19:01 +08:00
|
|
|
%p0.1 = getelementptr i32, i32* %p0, i32 1
|
|
|
|
store i32 %v0, i32* %p0
|
|
|
|
store i32 %v1, i32* %p0.1
|
|
|
|
%p1 = getelementptr i32, i32* %p0, i32 2
|
|
|
|
ret i32* %p1
|
|
|
|
}
|
|
|
|
|
2013-06-21 06:51:44 +08:00
|
|
|
declare void @llvm.lifetime.start(i64, i8* nocapture) nounwind
|
|
|
|
declare void @llvm.lifetime.end(i64, i8* nocapture) nounwind
|