@@ -134,6 +134,45 @@ template <IR IRTy> static void RAUW(benchmark::State &State) {
134134 }
135135}
136136
137+ static std::string generateRUOWIR (unsigned NumOperands) {
138+ std::stringstream SS;
139+ auto GenOps = [&SS, NumOperands]() {
140+ for (auto Cnt : seq<unsigned >(0 , NumOperands)) {
141+ SS << " i8 %arg" << Cnt;
142+ bool IsLast = Cnt + 1 == NumOperands;
143+ if (!IsLast)
144+ SS << " , " ;
145+ }
146+ };
147+
148+ SS << " define void @foo(" ;
149+ GenOps ();
150+ SS << " ) {\n " ;
151+
152+ SS << " call void @foo(" ;
153+ GenOps ();
154+ SS << " )\n " ;
155+ SS << " ret void" ;
156+ SS << " }" ;
157+ return SS.str ();
158+ }
159+
160+ template <IR IRTy> static void RUOW (benchmark::State &State) {
161+ LLVMContext LLVMCtx;
162+ sandboxir::Context Ctx (LLVMCtx);
163+ std::unique_ptr<llvm::Module> LLVMM;
164+ unsigned NumOperands = State.range (0 );
165+ auto *BB = genIR<IRTy>(LLVMM, LLVMCtx, Ctx, generateRUOWIR, NumOperands);
166+
167+ auto It = BB->begin ();
168+ auto *F = BB->getParent ();
169+ auto *Arg0 = F->getArg (0 );
170+ auto *Arg1 = F->getArg (1 );
171+ auto *Call = &*It++;
172+ for (auto _ : State)
173+ Call->replaceUsesOfWith (Arg0, Arg1);
174+ }
175+
137176BENCHMARK (GetType<IR::LLVM>);
138177BENCHMARK (GetType<IR::SBox>);
139178
@@ -143,4 +182,7 @@ BENCHMARK(BBWalk<IR::SBox>)->Args({1024});
143182BENCHMARK (RAUW<IR::LLVM>)->Args({512 });
144183BENCHMARK (RAUW<IR::SBox>)->Args({512 });
145184
185+ BENCHMARK (RUOW<IR::LLVM>)->Args({4096 });
186+ BENCHMARK (RUOW<IR::SBox>)->Args({4096 });
187+
146188BENCHMARK_MAIN ();
0 commit comments