Cache TTRs in Model tools

This commit is contained in:
Pietro Fezzardi
2022-10-21 14:08:17 +02:00
committed by Alessandro Di Federico
parent fff0fbd874
commit d520fd5aea
3 changed files with 11 additions and 4 deletions
+9 -2
View File
@@ -213,8 +213,15 @@ public:
return *Module;
}
TupleTree<model::Binary> &getModel() { return Model; }
const TupleTree<model::Binary> &getModel() const { return Model; }
TupleTree<model::Binary> &getWriteableModel() {
Model.evictCachedReferences();
return Model;
}
const model::Binary &getReadOnlyModel() {
Model.cacheReferences();
return *std::as_const(Model);
}
public:
llvm::Error save(const llvm::Twine &Path, ModelOutputType::Values Type) {
+1 -1
View File
@@ -51,7 +51,7 @@ int main(int Argc, char *Argv[]) {
if (not Diff)
ExitOnError(Diff.takeError());
Diff->apply(Model->getModel());
Diff->apply(Model->getWriteableModel());
auto DesiredOutput = Options.getDesiredOutput(Model->hasModule());
ExitOnError(Model->save(Options.getPath(), DesiredOutput));
+1 -1
View File
@@ -43,7 +43,7 @@ int main(int Argc, char *Argv[]) {
revng_abort(EC.message().c_str());
TypeSystemPrinter TSPrinter(Out);
TSPrinter.print(*MaybeModel->getModel());
TSPrinter.print(MaybeModel->getReadOnlyModel());
return EXIT_SUCCESS;
}