• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1; RUN: opt -gvn-hoist -S < %s | FileCheck %s
2
3target datalayout = "e-m:x-p:32:32-i64:64-f80:32-n8:16:32-a:0:32-S32"
4target triple = "i686-pc-windows-msvc18.0.0"
5
6%struct.S = type { i8* }
7
8declare 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
25define void @test(i1 %b) {
26entry:
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
33true:
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
38false:
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
43exit:
44  call void @f(<{ %struct.S }>* inalloca %argmem)
45  call void @llvm.stackrestore(i8* %inalloca.save)
46  ret void
47}
48
49declare i8* @llvm.stacksave()
50declare void @llvm.stackrestore(i8*)
51