1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt -passes=gvn-hoist -S < %s | FileCheck %s
4 target datalayout = "e-m:x-p:32:32-i64:64-f80:32-n8:16:32-a:0:32-S32"
5 target triple = "i686-pc-windows-msvc18.0.0"
7 %struct.S = type { ptr, ptr }
9 declare void @f(ptr inalloca(<{ %struct.S }>))
12 ; Check that we don't clone the %x alloca and insert it in the live range of
13 ; %argmem, which would break the inalloca contract.
14 define void @test(i1 %b) {
17 ; CHECK-NEXT: [[X:%.*]] = alloca i8, align 1
18 ; CHECK-NEXT: [[INALLOCA_SAVE:%.*]] = call ptr @llvm.stacksave.p0()
19 ; CHECK-NEXT: [[ARGMEM:%.*]] = alloca inalloca <{ [[STRUCT_S:%.*]] }>, align 4
20 ; CHECK-NEXT: [[TMP0:%.*]] = getelementptr inbounds [[STRUCT_S]], ptr [[ARGMEM]], i32 0, i32 1
21 ; CHECK-NEXT: store ptr [[X]], ptr [[TMP0]], align 4
22 ; CHECK-NEXT: br i1 [[B:%.*]], label [[TRUE:%.*]], label [[FALSE:%.*]]
24 ; CHECK-NEXT: [[P:%.*]] = getelementptr inbounds [[STRUCT_S]], ptr [[ARGMEM]], i32 0, i32 1
25 ; CHECK-NEXT: br label [[EXIT:%.*]]
27 ; CHECK-NEXT: [[P2:%.*]] = getelementptr inbounds [[STRUCT_S]], ptr [[ARGMEM]], i32 0, i32 1
28 ; CHECK-NEXT: br label [[EXIT]]
30 ; CHECK-NEXT: call void @f(ptr inalloca(<{ [[STRUCT_S]] }>) [[ARGMEM]])
31 ; CHECK-NEXT: call void @llvm.stackrestore.p0(ptr [[INALLOCA_SAVE]])
32 ; CHECK-NEXT: ret void
36 %inalloca.save = call ptr @llvm.stacksave()
37 %argmem = alloca inalloca <{ %struct.S }>, align 4
38 br i1 %b, label %true, label %false
41 %p = getelementptr inbounds %struct.S, ptr %argmem, i32 0, i32 1
42 store ptr %x, ptr %p, align 4
46 %p2 = getelementptr inbounds %struct.S, ptr %argmem, i32 0, i32 1
47 store ptr %x, ptr %p2, align 4
51 call void @f(ptr inalloca(<{ %struct.S }>) %argmem)
52 call void @llvm.stackrestore(ptr %inalloca.save)
56 declare ptr @llvm.stacksave()
57 declare void @llvm.stackrestore(ptr)