65 lines · plain
1#include <benchmark/benchmark.h>2 3#ifdef __clang__4#pragma clang diagnostic ignored "-Wreturn-type"5#endif6BENCHMARK_DISABLE_DEPRECATED_WARNING7 8extern "C" {9 10extern int ExternInt;11extern int ExternInt2;12extern int ExternInt3;13}14 15// CHECK-LABEL: test_basic:16extern "C" void test_basic() {17 int x;18 benchmark::DoNotOptimize(&x);19 x = 101;20 benchmark::ClobberMemory();21 // CHECK: leaq [[DEST:[^,]+]], %rax22 // CHECK: movl $101, [[DEST]]23 // CHECK: ret24}25 26// CHECK-LABEL: test_redundant_store:27extern "C" void test_redundant_store() {28 ExternInt = 3;29 benchmark::ClobberMemory();30 ExternInt = 51;31 // CHECK-DAG: ExternInt32 // CHECK-DAG: movl $333 // CHECK: movl $5134}35 36// CHECK-LABEL: test_redundant_read:37extern "C" void test_redundant_read() {38 int x;39 benchmark::DoNotOptimize(&x);40 x = ExternInt;41 benchmark::ClobberMemory();42 x = ExternInt2;43 // CHECK: leaq [[DEST:[^,]+]], %rax44 // CHECK: ExternInt(%rip)45 // CHECK: movl %eax, [[DEST]]46 // CHECK-NOT: ExternInt247 // CHECK: ret48}49 50// CHECK-LABEL: test_redundant_read2:51extern "C" void test_redundant_read2() {52 int x;53 benchmark::DoNotOptimize(&x);54 x = ExternInt;55 benchmark::ClobberMemory();56 x = ExternInt2;57 benchmark::ClobberMemory();58 // CHECK: leaq [[DEST:[^,]+]], %rax59 // CHECK: ExternInt(%rip)60 // CHECK: movl %eax, [[DEST]]61 // CHECK: ExternInt2(%rip)62 // CHECK: movl %eax, [[DEST]]63 // CHECK: ret64}65