blob: e70e30d1a7ed49c5aedb62d366e71f15cc8cf58f [file] [log] [blame]
Reid Kleckner6ee00a22016-08-12 22:23:04 +00001; RUN: opt -always-inline -S < %s | FileCheck %s
2
3; We used to misclassify inalloca as a static alloca in the inliner. This only
4; arose with for alwaysinline functions, because the normal inliner refuses to
5; inline such things.
6
7; Generated using this C++ source:
8; struct Foo {
9; Foo();
10; Foo(const Foo &o);
11; ~Foo();
12; int a;
13; };
14; __forceinline void h(Foo o) {}
15; __forceinline void g() { h(Foo()); }
16; void f() { g(); }
17
18; ModuleID = 't.cpp'
19source_filename = "t.cpp"
20target datalayout = "e-m:x-p:32:32-i64:64-f80:32-n8:16:32-a:0:32-S32"
21target triple = "i386-pc-windows-msvc19.0.24210"
22
23%struct.Foo = type { i32 }
24
25declare i8* @llvm.stacksave()
26declare void @llvm.stackrestore(i8*)
27
28declare x86_thiscallcc %struct.Foo* @"\01??0Foo@@QAE@XZ"(%struct.Foo* returned) unnamed_addr
29declare x86_thiscallcc void @"\01??1Foo@@QAE@XZ"(%struct.Foo*) unnamed_addr
30
31define void @f() {
32entry:
33 call void @g()
34 ret void
35}
36
37define internal void @g() alwaysinline {
38entry:
39 %inalloca.save = call i8* @llvm.stacksave()
40 %argmem = alloca inalloca <{ %struct.Foo }>, align 4
41 %0 = getelementptr inbounds <{ %struct.Foo }>, <{ %struct.Foo }>* %argmem, i32 0, i32 0
42 %call = call x86_thiscallcc %struct.Foo* @"\01??0Foo@@QAE@XZ"(%struct.Foo* %0)
43 call void @h(<{ %struct.Foo }>* inalloca %argmem)
44 call void @llvm.stackrestore(i8* %inalloca.save)
45 ret void
46}
47
48; Function Attrs: alwaysinline inlinehint nounwind
49define internal void @h(<{ %struct.Foo }>* inalloca) alwaysinline {
50entry:
51 %o = getelementptr inbounds <{ %struct.Foo }>, <{ %struct.Foo }>* %0, i32 0, i32 0
52 call x86_thiscallcc void @"\01??1Foo@@QAE@XZ"(%struct.Foo* %o)
53 ret void
54}
55
56; CHECK: define void @f()
57; CHECK: %inalloca.save.i = call i8* @llvm.stacksave()
58; CHECK: alloca inalloca <{ %struct.Foo }>, align 4
59; CHECK: %call.i = call x86_thiscallcc %struct.Foo* @"\01??0Foo@@QAE@XZ"(%struct.Foo* %0)
60; CHECK: %o.i.i = getelementptr inbounds <{ %struct.Foo }>, <{ %struct.Foo }>* %argmem.i, i32 0, i32 0
61; CHECK: call x86_thiscallcc void @"\01??1Foo@@QAE@XZ"(%struct.Foo* %o.i.i)
62; CHECK: call void @llvm.stackrestore(i8* %inalloca.save.i)
63; CHECK: ret void