clobber_memory_assembly_test.cc
Go to the documentation of this file.
1 #include <benchmark/benchmark.h>
2 
3 #ifdef __clang__
4 #pragma clang diagnostic ignored "-Wreturn-type"
5 #endif
6 
7 extern "C" {
8 
9 extern int ExternInt;
10 extern int ExternInt2;
11 extern int ExternInt3;
12 
13 }
14 
15 // CHECK-LABEL: test_basic:
16 extern "C" void test_basic() {
17  int x;
19  x = 101;
20  benchmark::ClobberMemory();
21  // CHECK: leaq [[DEST:[^,]+]], %rax
22  // CHECK: movl $101, [[DEST]]
23  // CHECK: ret
24 }
25 
26 // CHECK-LABEL: test_redundant_store:
27 extern "C" void test_redundant_store() {
28  ExternInt = 3;
29  benchmark::ClobberMemory();
30  ExternInt = 51;
31  // CHECK-DAG: ExternInt
32  // CHECK-DAG: movl $3
33  // CHECK: movl $51
34 }
35 
36 // CHECK-LABEL: test_redundant_read:
37 extern "C" void test_redundant_read() {
38  int x;
40  x = ExternInt;
41  benchmark::ClobberMemory();
42  x = ExternInt2;
43  // CHECK: leaq [[DEST:[^,]+]], %rax
44  // CHECK: ExternInt(%rip)
45  // CHECK: movl %eax, [[DEST]]
46  // CHECK-NOT: ExternInt2
47  // CHECK: ret
48 }
49 
50 // CHECK-LABEL: test_redundant_read2:
51 extern "C" void test_redundant_read2() {
52  int x;
54  x = ExternInt;
55  benchmark::ClobberMemory();
56  x = ExternInt2;
57  benchmark::ClobberMemory();
58  // CHECK: leaq [[DEST:[^,]+]], %rax
59  // CHECK: ExternInt(%rip)
60  // CHECK: movl %eax, [[DEST]]
61  // CHECK: ExternInt2(%rip)
62  // CHECK: movl %eax, [[DEST]]
63  // CHECK: ret
64 }
ExternInt
int ExternInt
ExternInt3
int ExternInt3
benchmark::DoNotOptimize
BENCHMARK_ALWAYS_INLINE void DoNotOptimize(Tp const &value)
Definition: benchmark/include/benchmark/benchmark.h:375
test_redundant_read2
void test_redundant_read2()
Definition: clobber_memory_assembly_test.cc:51
x
int x
Definition: bloaty/third_party/googletest/googlemock/test/gmock-matchers_test.cc:3610
test_redundant_read
void test_redundant_read()
Definition: clobber_memory_assembly_test.cc:37
test_redundant_store
void test_redundant_store()
Definition: clobber_memory_assembly_test.cc:27
test_basic
void test_basic()
Definition: clobber_memory_assembly_test.cc:16
ExternInt2
int ExternInt2


grpc
Author(s):
autogenerated on Fri May 16 2025 02:57:55