llvm/llvm/benchmarks/SandboxIRBench.cpp

//===- SandboxIRBench.cpp -------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
//
// These tests measure the performance of some core SandboxIR functions and
// compare them against LLVM IR.
//
//===----------------------------------------------------------------------===//

#include "benchmark/benchmark.h"
#include "llvm/AsmParser/Parser.h"
#include "llvm/IR/BasicBlock.h"
#include "llvm/IR/DataLayout.h"
#include "llvm/IR/Function.h"
#include "llvm/IR/Instruction.h"
#include "llvm/IR/Module.h"
#include "llvm/SandboxIR/SandboxIR.h"
#include "llvm/Support/SourceMgr.h"
#include <memory>
#include <sstream>

usingnamespacellvm;

static std::unique_ptr<Module> parseIR(LLVMContext &C, const char *IR) {}

enum class IR {};
// Traits to get llvm::BasicBlock/sandboxir::BasicBlock from IR::LLVM/IR::SBox.
template <IR IRTy> struct TypeSelect {};
template <> struct TypeSelect<IR::LLVM> {};
template <> struct TypeSelect<IR::SBoxNoTracking> {};
template <> struct TypeSelect<IR::SBoxTracking> {};

template <IR IRTy>
static typename TypeSelect<IRTy>::BasicBlock *
genIR(std::unique_ptr<llvm::Module> &LLVMM, LLVMContext &LLVMCtx,
      sandboxir::Context &Ctx,
      std::function<std::string(unsigned)> GenerateIRStr,
      unsigned NumInstrs = 0u) {}

template <IR IRTy> static void finalize(sandboxir::Context &Ctx) {}

static std::string generateBBWalkIR(unsigned Size) {}

template <IR IRTy> static void SBoxIRCreation(benchmark::State &State) {}

template <IR IRTy> static void BBWalk(benchmark::State &State) {}

static std::string generateGetTypeIR(unsigned Size) {}

template <IR IRTy> static void GetType(benchmark::State &State) {}

static std::string generateRAUWIR(unsigned Size) {}

template <IR IRTy> static void RAUW(benchmark::State &State) {}

static std::string generateRUOWIR(unsigned NumOperands) {}

template <IR IRTy> static void RUOW(benchmark::State &State) {}

// Measure the time it takes to create Sandbox IR without/with tracking.
BENCHMARK();
BENCHMARK();

BENCHMARK();
BENCHMARK();

BENCHMARK();
BENCHMARK();

BENCHMARK();
BENCHMARK();
BENCHMARK();

BENCHMARK();
BENCHMARK();
BENCHMARK();

BENCHMARK_MAIN();