Home | History | Annotate | Download | only in Large
      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.
     22 args = (8168 - 160) / 8 + (5 - 1)
     23 
     24 print 'declare i64 *@foo(i64 *%s)' % (', i64' * args)
     25 print 'declare void @bar(i64 *)'
     26 print ''
     27 print 'define i64 @f1(i64 %foo) {'
     28 print 'entry:'
     29 
     30 # Make the allocation big, so that it goes at the top of the frame.
     31 print '  %array = alloca [1000 x i64]'
     32 print '  %area = getelementptr [1000 x i64], [1000 x i64] *%array, i64 0, i64 0'
     33 print '  %%base = call i64 *@foo(i64 *%%area%s)' % (', i64 0' * args)
     34 print ''
     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.
     38 count = 14
     39 for 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.
     46 for 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.
     54 print '  %cond = icmp eq i64 %val0, %val1'
     55 print '  br i1 %cond, label %skip, label %fallthru'
     56 print ''
     57 print 'fallthru:'
     58 print '  store i64 %foo, i64 *%area'
     59 print '  store volatile i64 %val0, i64 *%ptr0'
     60 print '  br label %skip'
     61 print ''
     62 print '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.
     66 for 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 
     71 print '  call void @bar(i64 *%area)'
     72 print '  ret i64 0'
     73 print '}'
     74