1 ; In PR41658, argpromotion put an inalloca in a position that per the
2 ; calling convention is passed in a register. This test verifies that
3 ; we don't do that anymore. It also verifies that the combination of
4 ; globalopt and argpromotion is able to optimize the call safely.
6 ; RUN: opt -S -argpromotion %s | FileCheck --check-prefix=THIS %s
7 ; RUN: opt -S -globalopt -argpromotion %s | FileCheck --check-prefix=OPT %s
8 ; THIS: define internal x86_thiscallcc void @internalfun(%struct.a* %this, <{ %struct.a
9 ; OPT: define internal fastcc void @internalfun(<{ %struct.a }>* %0)
11 target datalayout = "e-m:x-p:32:32-i64:64-f80:32-n8:16:32-a:0:32-S32"
12 target triple = "i386-pc-windows-msvc19.11.0"
14 %struct.a = type { i8 }
16 define internal x86_thiscallcc void @internalfun(%struct.a* %this, <{ %struct.a }>* inalloca) {
18 %a = getelementptr inbounds <{ %struct.a }>, <{ %struct.a }>* %0, i32 0, i32 0
19 %argmem = alloca inalloca <{ %struct.a }>, align 4
20 %1 = getelementptr inbounds <{ %struct.a }>, <{ %struct.a }>* %argmem, i32 0, i32 0
21 %call = call x86_thiscallcc %struct.a* @copy_ctor(%struct.a* %1, %struct.a* dereferenceable(1) %a)
22 call void @ext(<{ %struct.a }>* inalloca %argmem)
26 ; This is here to ensure @internalfun is live.
27 define void @exportedfun(%struct.a* %a) {
28 %inalloca.save = tail call i8* @llvm.stacksave()
29 %argmem = alloca inalloca <{ %struct.a }>, align 4
30 call x86_thiscallcc void @internalfun(%struct.a* %a, <{ %struct.a }>* inalloca %argmem)
31 call void @llvm.stackrestore(i8* %inalloca.save)
35 declare x86_thiscallcc %struct.a* @copy_ctor(%struct.a* returned, %struct.a* dereferenceable(1))
36 declare void @ext(<{ %struct.a }>* inalloca)
37 declare i8* @llvm.stacksave()
38 declare void @llvm.stackrestore(i8*)