2013-08-02 05:42:05 +08:00
|
|
|
; RUN: llc < %s -relocation-model=static -mcpu=yonah | FileCheck %s
|
Infer alignment of loads and increase their alignment when we can tell they are
from the stack. This allows us to compile stack-align.ll to:
_test:
movsd LCPI1_0, %xmm0
movapd %xmm0, %xmm1
*** andpd 4(%esp), %xmm1
andpd _G, %xmm0
addsd %xmm1, %xmm0
movl 20(%esp), %eax
movsd %xmm0, (%eax)
ret
instead of:
_test:
movsd LCPI1_0, %xmm0
** movsd 4(%esp), %xmm1
** andpd %xmm0, %xmm1
andpd _G, %xmm0
addsd %xmm1, %xmm0
movl 20(%esp), %eax
movsd %xmm0, (%eax)
ret
llvm-svn: 46401
2008-01-27 03:45:50 +08:00
|
|
|
|
2015-02-18 04:08:21 +08:00
|
|
|
; The double argument is at 4(esp) which is 16-byte aligned, but we
|
|
|
|
; are required to read in extra bytes of memory in order to fold the
|
|
|
|
; load. Bad Things may happen when reading/processing undefined bytes,
|
|
|
|
; so don't fold the load.
|
|
|
|
; PR22371 / http://reviews.llvm.org/D7474
|
Infer alignment of loads and increase their alignment when we can tell they are
from the stack. This allows us to compile stack-align.ll to:
_test:
movsd LCPI1_0, %xmm0
movapd %xmm0, %xmm1
*** andpd 4(%esp), %xmm1
andpd _G, %xmm0
addsd %xmm1, %xmm0
movl 20(%esp), %eax
movsd %xmm0, (%eax)
ret
instead of:
_test:
movsd LCPI1_0, %xmm0
** movsd 4(%esp), %xmm1
** andpd %xmm0, %xmm1
andpd _G, %xmm0
addsd %xmm1, %xmm0
movl 20(%esp), %eax
movsd %xmm0, (%eax)
ret
llvm-svn: 46401
2008-01-27 03:45:50 +08: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:128:128"
|
|
|
|
target triple = "i686-apple-darwin8"
|
|
|
|
@G = external global double
|
|
|
|
|
2011-02-14 06:25:43 +08:00
|
|
|
define void @test({ double, double }* byval %z, double* %P) nounwind {
|
Infer alignment of loads and increase their alignment when we can tell they are
from the stack. This allows us to compile stack-align.ll to:
_test:
movsd LCPI1_0, %xmm0
movapd %xmm0, %xmm1
*** andpd 4(%esp), %xmm1
andpd _G, %xmm0
addsd %xmm1, %xmm0
movl 20(%esp), %eax
movsd %xmm0, (%eax)
ret
instead of:
_test:
movsd LCPI1_0, %xmm0
** movsd 4(%esp), %xmm1
** andpd %xmm0, %xmm1
andpd _G, %xmm0
addsd %xmm1, %xmm0
movl 20(%esp), %eax
movsd %xmm0, (%eax)
ret
llvm-svn: 46401
2008-01-27 03:45:50 +08:00
|
|
|
entry:
|
2015-02-28 05:17:42 +08:00
|
|
|
%tmp3 = load double, double* @G, align 16 ; <double> [#uses=1]
|
2012-08-04 07:29:17 +08:00
|
|
|
%tmp4 = tail call double @fabs( double %tmp3 ) readnone ; <double> [#uses=1]
|
2011-11-27 14:54:59 +08:00
|
|
|
store volatile double %tmp4, double* %P
|
[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
|
|
|
%tmp = getelementptr { double, double }, { double, double }* %z, i32 0, i32 0 ; <double*> [#uses=1]
|
2015-02-28 05:17:42 +08:00
|
|
|
%tmp1 = load volatile double, double* %tmp, align 8 ; <double> [#uses=1]
|
2012-08-04 07:29:17 +08:00
|
|
|
%tmp2 = tail call double @fabs( double %tmp1 ) readnone ; <double> [#uses=1]
|
2009-06-05 06:49:04 +08:00
|
|
|
%tmp6 = fadd double %tmp4, %tmp2 ; <double> [#uses=1]
|
2011-11-27 14:54:59 +08:00
|
|
|
store volatile double %tmp6, double* %P, align 8
|
Infer alignment of loads and increase their alignment when we can tell they are
from the stack. This allows us to compile stack-align.ll to:
_test:
movsd LCPI1_0, %xmm0
movapd %xmm0, %xmm1
*** andpd 4(%esp), %xmm1
andpd _G, %xmm0
addsd %xmm1, %xmm0
movl 20(%esp), %eax
movsd %xmm0, (%eax)
ret
instead of:
_test:
movsd LCPI1_0, %xmm0
** movsd 4(%esp), %xmm1
** andpd %xmm0, %xmm1
andpd _G, %xmm0
addsd %xmm1, %xmm0
movl 20(%esp), %eax
movsd %xmm0, (%eax)
ret
llvm-svn: 46401
2008-01-27 03:45:50 +08:00
|
|
|
ret void
|
2015-02-18 04:08:21 +08:00
|
|
|
|
|
|
|
; CHECK-LABEL: test:
|
|
|
|
; CHECK: movsd {{.*}}G, %xmm{{.*}}
|
|
|
|
; CHECK: andpd %xmm{{.*}}, %xmm{{.*}}
|
|
|
|
; CHECK: movsd 4(%esp), %xmm{{.*}}
|
|
|
|
; CHECK: andpd %xmm{{.*}}, %xmm{{.*}}
|
|
|
|
|
|
|
|
|
Infer alignment of loads and increase their alignment when we can tell they are
from the stack. This allows us to compile stack-align.ll to:
_test:
movsd LCPI1_0, %xmm0
movapd %xmm0, %xmm1
*** andpd 4(%esp), %xmm1
andpd _G, %xmm0
addsd %xmm1, %xmm0
movl 20(%esp), %eax
movsd %xmm0, (%eax)
ret
instead of:
_test:
movsd LCPI1_0, %xmm0
** movsd 4(%esp), %xmm1
** andpd %xmm0, %xmm1
andpd _G, %xmm0
addsd %xmm1, %xmm0
movl 20(%esp), %eax
movsd %xmm0, (%eax)
ret
llvm-svn: 46401
2008-01-27 03:45:50 +08:00
|
|
|
}
|
|
|
|
|
2011-02-14 06:25:43 +08:00
|
|
|
define void @test2() alignstack(16) nounwind {
|
2010-02-20 02:17:13 +08:00
|
|
|
entry:
|
2015-02-18 04:08:21 +08:00
|
|
|
; CHECK-LABEL: test2:
|
|
|
|
; CHECK: andl{{.*}}$-16, %esp
|
2010-02-20 02:17:13 +08:00
|
|
|
ret void
|
|
|
|
}
|
|
|
|
|
|
|
|
; Use a call to force a spill.
|
2011-02-14 06:25:43 +08:00
|
|
|
define <2 x double> @test3(<2 x double> %x, <2 x double> %y) alignstack(32) nounwind {
|
2010-02-20 02:17:13 +08:00
|
|
|
entry:
|
2015-02-18 04:08:21 +08:00
|
|
|
; CHECK-LABEL: test3:
|
|
|
|
; CHECK: andl{{.*}}$-32, %esp
|
2010-02-20 02:17:13 +08:00
|
|
|
call void @test2()
|
2010-05-04 06:36:46 +08:00
|
|
|
%A = fmul <2 x double> %x, %y
|
2010-02-20 02:17:13 +08:00
|
|
|
ret <2 x double> %A
|
|
|
|
}
|
|
|
|
|
Infer alignment of loads and increase their alignment when we can tell they are
from the stack. This allows us to compile stack-align.ll to:
_test:
movsd LCPI1_0, %xmm0
movapd %xmm0, %xmm1
*** andpd 4(%esp), %xmm1
andpd _G, %xmm0
addsd %xmm1, %xmm0
movl 20(%esp), %eax
movsd %xmm0, (%eax)
ret
instead of:
_test:
movsd LCPI1_0, %xmm0
** movsd 4(%esp), %xmm1
** andpd %xmm0, %xmm1
andpd _G, %xmm0
addsd %xmm1, %xmm0
movl 20(%esp), %eax
movsd %xmm0, (%eax)
ret
llvm-svn: 46401
2008-01-27 03:45:50 +08:00
|
|
|
declare double @fabs(double)
|
2010-02-20 02:17:13 +08:00
|
|
|
|
2011-02-14 06:25:43 +08:00
|
|
|
; The pointer is already known aligned, so and x,-16 is eliminable.
|
|
|
|
define i32 @test4() nounwind {
|
|
|
|
entry:
|
|
|
|
%buffer = alloca [2048 x i8], align 16
|
|
|
|
%0 = ptrtoint [2048 x i8]* %buffer to i32
|
|
|
|
%and = and i32 %0, -16
|
|
|
|
ret i32 %and
|
2013-07-14 04:38:47 +08:00
|
|
|
; CHECK-LABEL: test4:
|
2011-02-14 06:25:43 +08:00
|
|
|
; CHECK-NOT: and
|
|
|
|
; CHECK: ret
|
|
|
|
}
|
2016-04-10 07:34:42 +08:00
|
|
|
|
|
|
|
%struct.sixteen = type { [16 x i8] }
|
|
|
|
|
|
|
|
; Accessing stack parameters shouldn't assume stack alignment. Here we should
|
|
|
|
; emit two 8-byte loads, followed by two 8-byte stores.
|
|
|
|
define x86_stdcallcc void @test5(%struct.sixteen* byval nocapture readonly align 4 %s) #0 {
|
|
|
|
%d.sroa.0 = alloca [16 x i8], align 1
|
|
|
|
%1 = getelementptr inbounds [16 x i8], [16 x i8]* %d.sroa.0, i32 0, i32 0
|
|
|
|
call void @llvm.lifetime.start(i64 16, i8* %1)
|
|
|
|
%2 = getelementptr inbounds %struct.sixteen, %struct.sixteen* %s, i32 0, i32 0, i32 0
|
|
|
|
call void @llvm.memcpy.p0i8.p0i8.i32(i8* %1, i8* %2, i32 16, i32 1, i1 true)
|
|
|
|
call void @llvm.lifetime.end(i64 16, i8* %1)
|
|
|
|
ret void
|
|
|
|
; CHECK-LABEL: test5:
|
|
|
|
; CHECK: and
|
|
|
|
; CHECK: movsd
|
|
|
|
; CHECK-NEXT: movsd
|
|
|
|
; CHECK-NEXT: movsd
|
|
|
|
; CHECK-NEXT: movsd
|
|
|
|
}
|
|
|
|
|
|
|
|
declare void @llvm.lifetime.start(i64, i8* nocapture) argmemonly nounwind
|
|
|
|
|
|
|
|
declare void @llvm.memcpy.p0i8.p0i8.i32(i8* nocapture, i8* nocapture readonly, i32, i32, i1) argmemonly nounwind
|
|
|
|
|
|
|
|
declare void @llvm.lifetime.end(i64, i8* nocapture) argmemonly nounwind
|
|
|
|
|
|
|
|
attributes #0 = { nounwind alignstack=16 "no-frame-pointer-elim"="true" "no-frame-pointer-elim-non-leaf" }
|