Clang Project

clang_source_code/test/CodeGen/ms-barriers-intrinsics.c
1// RUN: %clang_cc1 -ffreestanding -fms-extensions -fms-compatibility -fms-compatibility-version=17.00 \
2// RUN:         -triple i686--windows -emit-llvm %s -o - \
3// RUN:         | FileCheck %s -check-prefix=CHECK -check-prefix=CHECK-I386
4// RUN: %clang_cc1 -ffreestanding -fms-extensions -fms-compatibility -fms-compatibility-version=17.00 \
5// RUN:         -triple x86_64--windows -emit-llvm %s -o - \
6// RUN:         | FileCheck %s --check-prefix=CHECK --check-prefix=CHECK-X64
7
8// intrin.h needs size_t, but -ffreestanding prevents us from getting it from
9// stddef.h.  Work around it with this typedef.
10typedef __SIZE_TYPE__ size_t;
11
12#include <intrin.h>
13
14void test_ReadWriteBarrier() { _ReadWriteBarrier(); }
15// CHECK-LABEL: define dso_local void @test_ReadWriteBarrier
16// CHECK:   fence syncscope("singlethread") seq_cst
17// CHECK:   ret void
18// CHECK: }
19
20void test_ReadBarrier() { _ReadBarrier(); }
21// CHECK-LABEL: define dso_local void @test_ReadBarrier
22// CHECK:   fence syncscope("singlethread") seq_cst
23// CHECK:   ret void
24// CHECK: }
25
26void test_WriteBarrier() { _WriteBarrier(); }
27// CHECK-LABEL: define dso_local void @test_WriteBarrier
28// CHECK:   fence syncscope("singlethread") seq_cst
29// CHECK:   ret void
30// CHECK: }
31
32#if defined(__x86_64__)
33void test__faststorefence() { __faststorefence(); }
34// CHECK-X64-LABEL: define dso_local void @test__faststorefence
35// CHECK-X64:   fence seq_cst
36// CHECK-X64:   ret void
37// CHECK-X64: }
38#endif
39
40