xref: /llvm-project/llvm/benchmarks/GetIntrinsicInfoTableEntriesBM.cpp (revision b55c52c047a167f42abbde9a33356cfb96b82c7f)
1 //===- GetIntrinsicInfoTableEntries.cpp - IIT signature benchmark ---------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 
9 #include "benchmark/benchmark.h"
10 #include "llvm/ADT/SmallVector.h"
11 #include "llvm/IR/Intrinsics.h"
12 
13 using namespace llvm;
14 using namespace Intrinsic;
15 
16 static void BM_GetIntrinsicInfoTableEntries(benchmark::State &state) {
17   SmallVector<IITDescriptor> Table;
18   for (auto _ : state) {
19     for (ID ID = 1; ID < num_intrinsics; ++ID) {
20       // This makes sure the vector does not keep growing, as well as after the
21       // first iteration does not result in additional allocations.
22       Table.clear();
23       getIntrinsicInfoTableEntries(ID, Table);
24     }
25   }
26 }
27 
28 BENCHMARK(BM_GetIntrinsicInfoTableEntries);
29 
30 BENCHMARK_MAIN();
31