From b05d84a24f8ab372a7a1c7bbdb72d772d4211646 Mon Sep 17 00:00:00 2001 From: vb-sc Date: Thu, 25 Apr 2024 08:51:54 +0000 Subject: [PATCH] [snippy] removed setting pc before register dump after execution of snippet --- .../tools/llvm-snippy/include/snippy/Generator/SimRunner.h | 5 ++--- llvm/tools/llvm-snippy/lib/Generator/GeneratorContext.cpp | 3 +-- llvm/tools/llvm-snippy/lib/Generator/SimRunner.cpp | 7 +------ 3 files changed, 4 insertions(+), 11 deletions(-) diff --git a/llvm/tools/llvm-snippy/include/snippy/Generator/SimRunner.h b/llvm/tools/llvm-snippy/include/snippy/Generator/SimRunner.h index 9fbab2232563..e4c1e9dd8df0 100644 --- a/llvm/tools/llvm-snippy/include/snippy/Generator/SimRunner.h +++ b/llvm/tools/llvm-snippy/include/snippy/Generator/SimRunner.h @@ -37,10 +37,9 @@ class SimRunner { return *CoInterp.front(); } - // Preform co-simulation run and returns PC before final instruction. + // Preform co-simulation run. // Each interpreter state will be reset before run. - ProgramCounterType run(StringRef Programm, - const IRegisterState &InitialRegState); + void run(StringRef Programm, const IRegisterState &InitialRegState); // Adds output section name to the sim config // in order to load it later to the model before execution. diff --git a/llvm/tools/llvm-snippy/lib/Generator/GeneratorContext.cpp b/llvm/tools/llvm-snippy/lib/Generator/GeneratorContext.cpp index b28d4378a56a..6a4d7ac1863b 100644 --- a/llvm/tools/llvm-snippy/lib/Generator/GeneratorContext.cpp +++ b/llvm/tools/llvm-snippy/lib/Generator/GeneratorContext.cpp @@ -298,9 +298,8 @@ void GeneratorContext::runSimulator(StringRef ImageToRun) { auto &SimRunner = getOrCreateSimRunner(); - auto FinalPC = SimRunner.run(ImageToRun, InitRegState); + SimRunner.run(ImageToRun, InitRegState); - I.setPC(FinalPC); I.dumpCurrentRegState(GenSettings->RegistersConfig.FinalStateOutputYaml); auto RangesToDump = getMemoryRangesToDump(I, DumpMemorySection); if (!RangesToDump.empty()) diff --git a/llvm/tools/llvm-snippy/lib/Generator/SimRunner.cpp b/llvm/tools/llvm-snippy/lib/Generator/SimRunner.cpp index 0fcc826ea667..e6c9f1e0f460 100644 --- a/llvm/tools/llvm-snippy/lib/Generator/SimRunner.cpp +++ b/llvm/tools/llvm-snippy/lib/Generator/SimRunner.cpp @@ -61,8 +61,7 @@ SimRunner::SimRunner(LLVMContext &Ctx, const SnippyTarget &TGT, } } -ProgramCounterType SimRunner::run(StringRef Program, - const IRegisterState &InitialRegState) { +void SimRunner::run(StringRef Program, const IRegisterState &InitialRegState) { auto StopPC = getAddressOfSymbolInImage(Program, Linker::GetExitSymbolName()); if (auto E = StopPC.takeError()) { auto Err = toString(std::move(E)); @@ -81,10 +80,7 @@ ProgramCounterType SimRunner::run(StringRef Program, auto &PrimI = getPrimaryInterpreter(); PrimI.logMessage("#===Simulation Start===\n"); - ProgramCounterType CurPC = PrimI.getPC(); - while (!PrimI.endOfProg()) { - CurPC = PrimI.getPC(); auto ExecRes = PrimI.step(); if (ExecRes == ExecutionResult::FatalError) PrimI.reportSimulationFatalError("Primary interpreter step failed"); @@ -106,7 +102,6 @@ ProgramCounterType SimRunner::run(StringRef Program, checkStates(/* CheckMemory */ false); } checkStates(/* CheckMemory */ true); - return CurPC; } void SimRunner::checkStates(bool CheckMemory) {