]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - test/Transforms/GVNHoist/hoist-pr28606.ll
Vendor import of llvm trunk r351319 (just before the release_80 branch
[FreeBSD/FreeBSD.git] / test / Transforms / GVNHoist / hoist-pr28606.ll
1 ; RUN: opt -gvn-hoist -S < %s | FileCheck %s
2
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"
5
6 %struct.S = type { i8* }
7
8 declare void @f(<{ %struct.S }>* inalloca)
9
10
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.
13 ;
14 ; CHECK-LABEL: @test
15 ; CHECK: alloca i8
16 ; CHECK: stacksave
17 ; CHECK: alloca inalloca
18 ; CHECK-NOT: alloca i8
19
20 ; Check that store instructions are hoisted.
21 ; CHECK: store i8
22 ; CHECK-NOT: store i8
23 ; CHECK: stackrestore
24
25 define void @test(i1 %b) {
26 entry:
27   %x = alloca i8
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
32
33 true:
34   %p = getelementptr inbounds %struct.S, %struct.S* %0, i32 0, i32 0
35   store i8* %x, i8** %p, align 4
36   br label %exit
37
38 false:
39   %p2 = getelementptr inbounds %struct.S, %struct.S* %0, i32 0, i32 0
40   store i8* %x, i8** %p2, align 4
41   br label %exit
42
43 exit:
44   call void @f(<{ %struct.S }>* inalloca %argmem)
45   call void @llvm.stackrestore(i8* %inalloca.save)
46   ret void
47 }
48
49 declare i8* @llvm.stacksave()
50 declare void @llvm.stackrestore(i8*)