Reid Kleckner | 40e7663 | 2018-08-14 01:24:35 +0000 | [diff] [blame] | 1 | ; RUN: opt -dse -S < %s | FileCheck %s |
| 2 | |
| 3 | ; Don't eliminate stores to allocas before tail calls to functions that use |
| 4 | ; byval. It's correct to mark calls like these as 'tail'. To implement this tail |
| 5 | ; call, the backend should copy the bytes from the alloca into the argument area |
| 6 | ; before clearing the stack. |
| 7 | |
| 8 | target datalayout = "e-m:e-p:32:32-f64:32:64-f80:32-n8:16:32-S128" |
| 9 | target triple = "i386-unknown-linux-gnu" |
| 10 | |
| 11 | declare void @g(i32* byval %p) |
| 12 | |
| 13 | define void @f(i32* byval %x) { |
| 14 | entry: |
| 15 | %p = alloca i32 |
| 16 | %v = load i32, i32* %x |
| 17 | store i32 %v, i32* %p |
| 18 | tail call void @g(i32* byval %p) |
| 19 | ret void |
| 20 | } |
| 21 | ; CHECK-LABEL: define void @f(i32* byval %x) |
| 22 | ; CHECK: store i32 %v, i32* %p |
| 23 | ; CHECK: tail call void @g(i32* byval %p) |