[clang] Implement lifetime analysis for lifetime_capture_by(X) (#115921)
[llvm-project.git] / clang / test / CodeGen / mozilla-ms-inline-asm.c
blob2e379c1bb8a23b50b8241976f10853e26ad3593a
1 // REQUIRES: x86-registered-target
2 // RUN: %clang_cc1 %s -triple i386-apple-darwin10 -fasm-blocks -emit-llvm -o - | opt -passes=strip -S | FileCheck %s
4 // Some test cases for MS inline asm support from Mozilla code base.
6 void invoke_copy_to_stack() {}
8 void invoke(void* that, unsigned methodIndex,
9 unsigned paramCount, void* params)
11 // CHECK: @invoke
12 // CHECK: %5 = alloca ptr, align 4
13 // CHECK: %6 = alloca i32, align 4
14 // CHECK: %7 = alloca i32, align 4
15 // CHECK: %8 = alloca ptr, align 4
16 // CHECK: store ptr %0, ptr %5, align 4
17 // CHECK: store i32 %1, ptr %6, align 4
18 // CHECK: store i32 %2, ptr %7, align 4
19 // CHECK: store ptr %3, ptr %8, align 4
20 // CHECK: call void asm sideeffect inteldialect
21 // CHECK-SAME: mov edx,$1
22 // CHECK-SAME: test edx,edx
23 // CHECK-SAME: jz {{[^_]*}}__MSASMLABEL_.${:uid}__noparams
24 // ^ Can't use {{.*}} here because the matching is greedy.
25 // CHECK-SAME: mov eax,edx
26 // CHECK-SAME: shl eax,$$3
27 // CHECK-SAME: sub esp,eax
28 // CHECK-SAME: mov ecx,esp
29 // CHECK-SAME: push $0
30 // CHECK-SAME: call ${2:P}
31 // CHECK-SAME: {{.*}}__MSASMLABEL_.${:uid}__noparams:
32 // CHECK-SAME: mov ecx,$3
33 // CHECK-SAME: push ecx
34 // CHECK-SAME: mov edx,[ecx]
35 // CHECK-SAME: mov eax,$4
36 // CHECK-SAME: call dword ptr[edx + eax * $$4]
37 // CHECK-SAME: mov esp,ebp
38 // CHECK-SAME: pop ebp
39 // CHECK-SAME: ret
40 // CHECK: "=*m,*m,*m,*m,*m,~{eax},~{ebp},~{ecx},~{edx},~{flags},~{esp},~{dirflag},~{fpsr},~{flags}"
41 // CHECK: (ptr elementtype(ptr) %8, ptr elementtype(i32) %7, ptr elementtype(void (...)) @invoke_copy_to_stack, ptr elementtype(ptr) %5, ptr elementtype(i32) %6)
42 // CHECK: ret void
43 __asm {
44 mov edx,paramCount
45 test edx,edx
46 jz noparams
47 mov eax,edx
48 shl eax,3
49 sub esp,eax
50 mov ecx,esp
51 push params
52 call invoke_copy_to_stack
53 noparams:
54 mov ecx,that
55 push ecx
56 mov edx,[ecx]
57 mov eax,methodIndex
58 call dword ptr[edx+eax*4]
59 mov esp,ebp
60 pop ebp
61 ret