1 ; RUN: opt -gvn-hoist -S < %s | FileCheck %s
3 target datalayout = "e-m:x-p:32:32-i64:64-f80:32-n8:16:32-a:0:32-S32"
4 target triple = "i686-pc-windows-msvc18.0.0"
6 %struct.S = type { i8* }
8 declare void @f(<{ %struct.S }>* inalloca)
11 ; Check that we don't clone the %x alloca and insert it in the live range of
12 ; %argmem, which would break the inalloca contract.
17 ; CHECK: alloca inalloca
18 ; CHECK-NOT: alloca i8
20 ; Check that store instructions are hoisted.
25 define void @test(i1 %b) {
28 %inalloca.save = call i8* @llvm.stacksave()
29 %argmem = alloca inalloca <{ %struct.S }>, align 4
30 %0 = getelementptr inbounds <{ %struct.S }>, <{ %struct.S }>* %argmem, i32 0, i32 0
31 br i1 %b, label %true, label %false
34 %p = getelementptr inbounds %struct.S, %struct.S* %0, i32 0, i32 0
35 store i8* %x, i8** %p, align 4
39 %p2 = getelementptr inbounds %struct.S, %struct.S* %0, i32 0, i32 0
40 store i8* %x, i8** %p2, align 4
44 call void @f(<{ %struct.S }>* inalloca %argmem)
45 call void @llvm.stackrestore(i8* %inalloca.save)
49 declare i8* @llvm.stacksave()
50 declare void @llvm.stackrestore(i8*)