Files
revng-revng/lib/Pipeline/GlobalsMap.cpp
Giacomo Vercesi 566cb6310b PipelineC: make indexed object stably sorted
Many Pipeline objects (Globals, Ranks, Kinds, Targets in a TargetList)
were ordered by load order, this makes the playback of traces difficult.
Moreover the order of loading of pipeline files also influences the
ordering of other elements (Step, Analys{is,esLists}). These are also
ordered to prevent incosistent ordering.
2023-04-20 14:43:13 +02:00

40 lines
1.0 KiB
C++

/// \file GlobalsMap.cpp
/// \brief GlobalsMap methods implementations
//
// This file is distributed under the MIT License. See LICENSE.md for details.
//
#include <system_error>
#include "llvm/ADT/StringRef.h"
#include "llvm/Support/FileSystem.h"
#include "llvm/Support/Path.h"
#include "llvm/Support/raw_ostream.h"
#include "revng/Pipeline/GlobalsMap.h"
using namespace std;
using namespace pipeline;
using namespace llvm;
llvm::Error GlobalsMap::storeToDisk(llvm::StringRef Path) const {
for (const auto &Global : Map) {
llvm::SmallString<128> Filename;
llvm::sys::path::append(Filename, Path, Global.first);
if (auto E = Global.second->storeToDisk(Filename); !!E)
return E;
}
return llvm::Error::success();
}
llvm::Error GlobalsMap::loadFromDisk(llvm::StringRef Path) {
for (const auto &Global : Map) {
llvm::SmallString<128> Filename;
llvm::sys::path::append(Filename, Path, Global.first);
if (auto E = Global.second->loadFromDisk(Filename); !!E)
return E;
}
return llvm::Error::success();
}