2012-06-18 11:15:04 +02:00
|
|
|
; This test is attempting to detect when we request forced re-alignment of the
|
|
|
|
; stack to an alignment greater than would be available due to the ABI. We
|
|
|
|
; arbitrarily force alignment up to 32-bytes for i386 hoping that this will
|
|
|
|
; exceed any ABI provisions.
|
|
|
|
;
|
2015-09-11 20:54:38 +02:00
|
|
|
; RUN: llc < %s -mcpu=generic -stackrealign -stack-alignment=32 | FileCheck %s
|
2012-06-18 11:15:04 +02:00
|
|
|
|
|
|
|
target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:32:32-n8:16:32-S128"
|
|
|
|
target triple = "i386-unknown-linux-gnu"
|
|
|
|
|
|
|
|
define i32 @f(i8* %p) nounwind {
|
|
|
|
entry:
|
2015-02-27 22:17:42 +01:00
|
|
|
%0 = load i8, i8* %p
|
2012-06-18 11:15:04 +02:00
|
|
|
%conv = sext i8 %0 to i32
|
|
|
|
ret i32 %conv
|
|
|
|
}
|
|
|
|
|
|
|
|
define i64 @g(i32 %i) nounwind {
|
2013-07-14 08:24:09 +02:00
|
|
|
; CHECK-LABEL: g:
|
2012-07-10 19:45:53 +02:00
|
|
|
; CHECK: pushl %ebp
|
2012-06-18 11:15:04 +02:00
|
|
|
; CHECK-NEXT: movl %esp, %ebp
|
|
|
|
; CHECK-NEXT: pushl
|
2012-07-10 19:45:53 +02:00
|
|
|
; CHECK-NEXT: pushl
|
2012-07-16 08:54:09 +02:00
|
|
|
; CHECK-NEXT: andl $-32, %esp
|
|
|
|
; CHECK-NEXT: subl $32, %esp
|
2012-07-10 19:45:53 +02:00
|
|
|
;
|
2012-07-31 20:29:21 +02:00
|
|
|
; Now setup the base pointer (%esi).
|
|
|
|
; CHECK-NEXT: movl %esp, %esi
|
2012-06-18 11:15:04 +02:00
|
|
|
; CHECK-NOT: {{[^ ,]*}}, %esp
|
|
|
|
;
|
|
|
|
; The next adjustment of the stack is due to the alloca.
|
|
|
|
; CHECK: movl %{{...}}, %esp
|
|
|
|
; CHECK-NOT: {{[^ ,]*}}, %esp
|
|
|
|
;
|
|
|
|
; Next we set up the memset call, and then undo it.
|
2014-12-09 07:10:44 +01:00
|
|
|
; CHECK: subl $20, %esp
|
2012-06-18 11:15:04 +02:00
|
|
|
; CHECK-NOT: {{[^ ,]*}}, %esp
|
|
|
|
; CHECK: calll memset
|
|
|
|
; CHECK-NEXT: addl $32, %esp
|
|
|
|
; CHECK-NOT: {{[^ ,]*}}, %esp
|
|
|
|
;
|
|
|
|
; Next we set up the call to 'f'.
|
2014-12-09 07:10:44 +01:00
|
|
|
; CHECK: subl $28, %esp
|
2012-06-18 11:15:04 +02:00
|
|
|
; CHECK-NOT: {{[^ ,]*}}, %esp
|
|
|
|
; CHECK: calll f
|
|
|
|
; CHECK-NEXT: addl $32, %esp
|
|
|
|
; CHECK-NOT: {{[^ ,]*}}, %esp
|
|
|
|
;
|
2012-07-16 08:54:09 +02:00
|
|
|
; Restore %esp from %ebp (frame pointer) and subtract the size of
|
|
|
|
; zone with callee-saved registers to pop them.
|
|
|
|
; This is the state prior to stack realignment and the allocation of VLAs.
|
2012-06-18 11:15:04 +02:00
|
|
|
; CHECK-NOT: popl
|
2012-07-16 08:54:09 +02:00
|
|
|
; CHECK: leal -8(%ebp), %esp
|
2012-06-18 11:15:04 +02:00
|
|
|
; CHECK-NEXT: popl
|
|
|
|
; CHECK-NEXT: popl
|
2012-07-10 19:45:53 +02:00
|
|
|
; CHECK-NEXT: popl %ebp
|
2012-06-18 11:15:04 +02:00
|
|
|
; CHECK-NEXT: ret
|
|
|
|
|
|
|
|
entry:
|
|
|
|
br label %if.then
|
|
|
|
|
|
|
|
if.then:
|
|
|
|
%0 = alloca i8, i32 %i
|
Change memcpy/memset/memmove to have dest and source alignments.
Note, this was reviewed (and more details are in) http://lists.llvm.org/pipermail/llvm-commits/Week-of-Mon-20151109/312083.html
These intrinsics currently have an explicit alignment argument which is
required to be a constant integer. It represents the alignment of the
source and dest, and so must be the minimum of those.
This change allows source and dest to each have their own alignments
by using the alignment attribute on their arguments. The alignment
argument itself is removed.
There are a few places in the code for which the code needs to be
checked by an expert as to whether using only src/dest alignment is
safe. For those places, they currently take the minimum of src/dest
alignments which matches the current behaviour.
For example, code which used to read:
call void @llvm.memcpy.p0i8.p0i8.i32(i8* %dest, i8* %src, i32 500, i32 8, i1 false)
will now read:
call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 8 %dest, i8* align 8 %src, i32 500, i1 false)
For out of tree owners, I was able to strip alignment from calls using sed by replacing:
(call.*llvm\.memset.*)i32\ [0-9]*\,\ i1 false\)
with:
$1i1 false)
and similarly for memmove and memcpy.
I then added back in alignment to test cases which needed it.
A similar commit will be made to clang which actually has many differences in alignment as now
IRBuilder can generate different source/dest alignments on calls.
In IRBuilder itself, a new argument was added. Instead of calling:
CreateMemCpy(Dst, Src, getInt64(Size), DstAlign, /* isVolatile */ false)
you now call
CreateMemCpy(Dst, Src, getInt64(Size), DstAlign, SrcAlign, /* isVolatile */ false)
There is a temporary class (IntegerAlignment) which takes the source alignment and rejects
implicit conversion from bool. This is to prevent isVolatile here from passing its default
parameter to the source alignment.
Note, changes in future can now be made to codegen. I didn't change anything here, but this
change should enable better memcpy code sequences.
Reviewed by Hal Finkel.
llvm-svn: 253511
2015-11-18 23:17:24 +01:00
|
|
|
call void @llvm.memset.p0i8.i32(i8* %0, i8 0, i32 %i, i1 false)
|
2012-06-18 11:15:04 +02:00
|
|
|
%call = call i32 @f(i8* %0)
|
|
|
|
%conv = sext i32 %call to i64
|
|
|
|
ret i64 %conv
|
|
|
|
}
|
|
|
|
|
Change memcpy/memset/memmove to have dest and source alignments.
Note, this was reviewed (and more details are in) http://lists.llvm.org/pipermail/llvm-commits/Week-of-Mon-20151109/312083.html
These intrinsics currently have an explicit alignment argument which is
required to be a constant integer. It represents the alignment of the
source and dest, and so must be the minimum of those.
This change allows source and dest to each have their own alignments
by using the alignment attribute on their arguments. The alignment
argument itself is removed.
There are a few places in the code for which the code needs to be
checked by an expert as to whether using only src/dest alignment is
safe. For those places, they currently take the minimum of src/dest
alignments which matches the current behaviour.
For example, code which used to read:
call void @llvm.memcpy.p0i8.p0i8.i32(i8* %dest, i8* %src, i32 500, i32 8, i1 false)
will now read:
call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 8 %dest, i8* align 8 %src, i32 500, i1 false)
For out of tree owners, I was able to strip alignment from calls using sed by replacing:
(call.*llvm\.memset.*)i32\ [0-9]*\,\ i1 false\)
with:
$1i1 false)
and similarly for memmove and memcpy.
I then added back in alignment to test cases which needed it.
A similar commit will be made to clang which actually has many differences in alignment as now
IRBuilder can generate different source/dest alignments on calls.
In IRBuilder itself, a new argument was added. Instead of calling:
CreateMemCpy(Dst, Src, getInt64(Size), DstAlign, /* isVolatile */ false)
you now call
CreateMemCpy(Dst, Src, getInt64(Size), DstAlign, SrcAlign, /* isVolatile */ false)
There is a temporary class (IntegerAlignment) which takes the source alignment and rejects
implicit conversion from bool. This is to prevent isVolatile here from passing its default
parameter to the source alignment.
Note, changes in future can now be made to codegen. I didn't change anything here, but this
change should enable better memcpy code sequences.
Reviewed by Hal Finkel.
llvm-svn: 253511
2015-11-18 23:17:24 +01:00
|
|
|
declare void @llvm.memset.p0i8.i32(i8*, i8, i32, i1) nounwind
|