xref: /llvm-project/llvm/test/CodeGen/SystemZ/stackmap-shadow-optimization.ll (revision 5eb64110d241cf2506f54ade3c2693beed42dd8f)
1*5eb64110SUlrich Weigand; RUN: llc < %s -mtriple=s390x-linux-gnu | FileCheck %s
2*5eb64110SUlrich Weigand
3*5eb64110SUlrich Weigand; Check that the stackmap shadow optimization is only outputting a 2-byte
4*5eb64110SUlrich Weigand; nop here. 8-bytes are requested, but 6 are covered by the code for the call to
5*5eb64110SUlrich Weigand; bar.  However, the frame teardown and the return do not count towards the
6*5eb64110SUlrich Weigand; stackmap shadow as the call return counts as a branch target so must flush
7*5eb64110SUlrich Weigand; the shadow.
8*5eb64110SUlrich Weigand; Note that in order for a thread to not return in to the patched space
9*5eb64110SUlrich Weigand; the call must be at the end of the shadow, so the required nop must be
10*5eb64110SUlrich Weigand; before the call, not after.
11*5eb64110SUlrich Weiganddefine void @shadow_optimization_test() {
12*5eb64110SUlrich Weigandentry:
13*5eb64110SUlrich Weigand; CHECK-LABEL:  shadow_optimization_test:
14*5eb64110SUlrich Weigand; CHECK:        brasl %r14, bar@PLT
15*5eb64110SUlrich Weigand; CHECK-NEXT:   .Ltmp
16*5eb64110SUlrich Weigand; CHECK-NEXT:   bcr 0, %r0
17*5eb64110SUlrich Weigand; CHECK-NEXT:   brasl %r14, bar@PLT
18*5eb64110SUlrich Weigand; CHECK-NEXT:   brasl %r14, bar@PLT
19*5eb64110SUlrich Weigand  call void @bar()
20*5eb64110SUlrich Weigand  tail call void (i64, i32, ...) @llvm.experimental.stackmap(i64 0, i32 8)
21*5eb64110SUlrich Weigand  call void @bar()
22*5eb64110SUlrich Weigand  call void @bar()
23*5eb64110SUlrich Weigand  ret void
24*5eb64110SUlrich Weigand}
25*5eb64110SUlrich Weiganddeclare void @bar()
26*5eb64110SUlrich Weigand
27*5eb64110SUlrich Weiganddeclare void @llvm.experimental.stackmap(i64, i32, ...)
28