[llvm] 362da64 - [SandboxIR][Bench] Test RAUW (#107440)
via llvm-commits
llvm-commits at lists.llvm.org
Thu Sep 5 12:32:12 PDT 2024
Author: vporpo
Date: 2024-09-05T12:32:07-07:00
New Revision: 362da640dd18e2ef960e0d2198fe8378104c4119
URL: https://github.com/llvm/llvm-project/commit/362da640dd18e2ef960e0d2198fe8378104c4119
DIFF: https://github.com/llvm/llvm-project/commit/362da640dd18e2ef960e0d2198fe8378104c4119.diff
LOG: [SandboxIR][Bench] Test RAUW (#107440)
Added:
Modified:
llvm/benchmarks/SandboxIRBench.cpp
Removed:
################################################################################
diff --git a/llvm/benchmarks/SandboxIRBench.cpp b/llvm/benchmarks/SandboxIRBench.cpp
index 633de6db1f5e24..1a7f808af21f2b 100644
--- a/llvm/benchmarks/SandboxIRBench.cpp
+++ b/llvm/benchmarks/SandboxIRBench.cpp
@@ -106,10 +106,40 @@ template <IR IRTy> static void GetType(benchmark::State &State) {
benchmark::DoNotOptimize(I->getType());
}
+static std::string generateRAUWIR(unsigned Size) {
+ std::stringstream SS;
+ SS << "define void @foo(i32 %v1, i32 %v2) {\n";
+ SS << " %def1 = add i32 %v1, %v2\n";
+ SS << " %def2 = add i32 %v1, %v2\n";
+ for (auto Cnt : seq<unsigned>(0, Size))
+ SS << " %add" << Cnt << " = add i32 %def1, %def1\n";
+ SS << "ret void";
+ SS << "}";
+ return SS.str();
+}
+
+template <IR IRTy> static void RAUW(benchmark::State &State) {
+ LLVMContext LLVMCtx;
+ sandboxir::Context Ctx(LLVMCtx);
+ std::unique_ptr<llvm::Module> LLVMM;
+ unsigned NumInstrs = State.range(0);
+ auto *BB = genIR<IRTy>(LLVMM, LLVMCtx, Ctx, generateRAUWIR, NumInstrs);
+ auto It = BB->begin();
+ auto *Def1 = &*It++;
+ auto *Def2 = &*It++;
+ for (auto _ : State) {
+ Def1->replaceAllUsesWith(Def2);
+ Def2->replaceAllUsesWith(Def1);
+ }
+}
+
BENCHMARK(GetType<IR::LLVM>);
BENCHMARK(GetType<IR::SBox>);
BENCHMARK(BBWalk<IR::LLVM>)->Args({1024});
BENCHMARK(BBWalk<IR::SBox>)->Args({1024});
+BENCHMARK(RAUW<IR::LLVM>)->Args({512});
+BENCHMARK(RAUW<IR::SBox>)->Args({512});
+
BENCHMARK_MAIN();
More information about the llvm-commits
mailing list