Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[snippy] removed setting pc before register dump after execution of snippet #26

Merged
merged 1 commit into from
Apr 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions llvm/tools/llvm-snippy/include/snippy/Generator/SimRunner.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
3 changes: 1 addition & 2 deletions llvm/tools/llvm-snippy/lib/Generator/GeneratorContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand Down
7 changes: 1 addition & 6 deletions llvm/tools/llvm-snippy/lib/Generator/SimRunner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand All @@ -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");
Expand All @@ -106,7 +102,6 @@ ProgramCounterType SimRunner::run(StringRef Program,
checkStates(/* CheckMemory */ false);
}
checkStates(/* CheckMemory */ true);
return CurPC;
}

void SimRunner::checkStates(bool CheckMemory) {
Expand Down