• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Test cases where we spill from one frame index to another, both of which
2# are out of range of MVC, and both of which need emergency spill slots.
3# RUN: python %s | llc -mtriple=s390x-linux-gnu | FileCheck %s
4
5# CHECK: f1:
6# CHECK: %fallthru
7# CHECK-DAG: stg [[REG1:%r[0-9]+]], 8168(%r15)
8# CHECK-DAG: stg [[REG2:%r[0-9]+]], 8176(%r15)
9# CHECK-DAG: lay [[REG3:%r[0-9]+]], 8192(%r15)
10# CHECK-DAG: lay [[REG4:%r[0-9]+]], 4096(%r15)
11# CHECK: mvc 0(8,[[REG3]]), 4088([[REG4]])
12# CHECK-DAG: lg [[REG1]], 8168(%r15)
13# CHECK-DAG: lg [[REG2]], 8176(%r15)
14# CHECK: %skip
15# CHECK: br %r14
16
17# Arrange for %foo's spill slot to be at 8184(%r15) and the alloca area to be at
18# 8192(%r15).  The two emergency spill slots live below that, so this requires
19# the first 8168 bytes to be used for the call.  160 of these bytes are
20# allocated for the ABI frame.  There are also 5 argument registers, one of
21# which is used as a base pointer.
22args = (8168 - 160) / 8 + (5 - 1)
23
24print 'declare i64 *@foo(i64 *%s)' % (', i64' * args)
25print 'declare void @bar(i64 *)'
26print ''
27print 'define i64 @f1(i64 %foo) {'
28print 'entry:'
29
30# Make the allocation big, so that it goes at the top of the frame.
31print '  %array = alloca [1000 x i64]'
32print '  %area = getelementptr [1000 x i64], [1000 x i64] *%array, i64 0, i64 0'
33print '  %%base = call i64 *@foo(i64 *%%area%s)' % (', i64 0' * args)
34print ''
35
36# Make sure all GPRs are used.  One is needed for the stack pointer and
37# another for %base, so we need 14 live values.
38count = 14
39for i in range(count):
40    print '  %%ptr%d = getelementptr i64, i64 *%%base, i64 %d' % (i, i / 2)
41    print '  %%val%d = load volatile i64 , i64 *%%ptr%d' % (i, i)
42    print ''
43
44# Encourage the register allocator to give preference to these %vals
45# by using them several times.
46for j in range(4):
47    for i in range(count):
48        print '  store volatile i64 %%val%d, i64 *%%ptr%d' % (i, i)
49    print ''
50
51# Copy the incoming argument, which we expect to be spilled, to the frame
52# index for the alloca area.  Also throw in a volatile store, so that this
53# block cannot be reordered with the surrounding code.
54print '  %cond = icmp eq i64 %val0, %val1'
55print '  br i1 %cond, label %skip, label %fallthru'
56print ''
57print 'fallthru:'
58print '  store i64 %foo, i64 *%area'
59print '  store volatile i64 %val0, i64 *%ptr0'
60print '  br label %skip'
61print ''
62print 'skip:'
63
64# Use each %val a few more times to emphasise the point, and to make sure
65# that they are live across the store of %foo.
66for j in range(4):
67    for i in range(count):
68        print '  store volatile i64 %%val%d, i64 *%%ptr%d' % (i, i)
69    print ''
70
71print '  call void @bar(i64 *%area)'
72print '  ret i64 0'
73print '}'
74