[Workflow] Try to fix code-formatter failing to find changes in some cases.
[llvm-project.git] / third-party / benchmark / test / clobber_memory_assembly_test.cc
blobab269130cd5cc3cc55afa911b525ec07ad4dc7a3
1 #include <benchmark/benchmark.h>
3 #ifdef __clang__
4 #pragma clang diagnostic ignored "-Wreturn-type"
5 #endif
7 extern "C" {
9 extern int ExternInt;
10 extern int ExternInt2;
11 extern int ExternInt3;
14 // CHECK-LABEL: test_basic:
15 extern "C" void test_basic() {
16 int x;
17 benchmark::DoNotOptimize(&x);
18 x = 101;
19 benchmark::ClobberMemory();
20 // CHECK: leaq [[DEST:[^,]+]], %rax
21 // CHECK: movl $101, [[DEST]]
22 // CHECK: ret
25 // CHECK-LABEL: test_redundant_store:
26 extern "C" void test_redundant_store() {
27 ExternInt = 3;
28 benchmark::ClobberMemory();
29 ExternInt = 51;
30 // CHECK-DAG: ExternInt
31 // CHECK-DAG: movl $3
32 // CHECK: movl $51
35 // CHECK-LABEL: test_redundant_read:
36 extern "C" void test_redundant_read() {
37 int x;
38 benchmark::DoNotOptimize(&x);
39 x = ExternInt;
40 benchmark::ClobberMemory();
41 x = ExternInt2;
42 // CHECK: leaq [[DEST:[^,]+]], %rax
43 // CHECK: ExternInt(%rip)
44 // CHECK: movl %eax, [[DEST]]
45 // CHECK-NOT: ExternInt2
46 // CHECK: ret
49 // CHECK-LABEL: test_redundant_read2:
50 extern "C" void test_redundant_read2() {
51 int x;
52 benchmark::DoNotOptimize(&x);
53 x = ExternInt;
54 benchmark::ClobberMemory();
55 x = ExternInt2;
56 benchmark::ClobberMemory();
57 // CHECK: leaq [[DEST:[^,]+]], %rax
58 // CHECK: ExternInt(%rip)
59 // CHECK: movl %eax, [[DEST]]
60 // CHECK: ExternInt2(%rip)
61 // CHECK: movl %eax, [[DEST]]
62 // CHECK: ret