mirror of
https://github.com/revng/revng
synced 2026-06-21 14:07:57 +00:00
Add missing llvm::Error checks
This commit is contained in:
@@ -127,12 +127,12 @@ public:
|
||||
/// Given a target, all occurrences of that target from every container in
|
||||
/// every step will be registered in the returned invalidation map. The
|
||||
/// propagations will not be calculated.
|
||||
llvm::Error getInvalidations(const Target &Target,
|
||||
pipeline::TargetInStepSet &Invalidations) const;
|
||||
void getInvalidations(const Target &Target,
|
||||
pipeline::TargetInStepSet &Invalidations) const;
|
||||
|
||||
/// Deduces and register in the invalidation map all the targets that have
|
||||
/// been produced starting from targets already presents in the map.
|
||||
llvm::Error getInvalidations(pipeline::TargetInStepSet &Invalidated) const;
|
||||
void getInvalidations(pipeline::TargetInStepSet &Invalidated) const;
|
||||
|
||||
public:
|
||||
template<typename... PipeWrappers>
|
||||
|
||||
@@ -768,8 +768,10 @@ IT::translate(PTCInstruction *Instr, MetaAddress PC, MetaAddress NextPC) {
|
||||
InArgs);
|
||||
|
||||
// Check if there was an error while translating the instruction
|
||||
if (!Result)
|
||||
if (!Result) {
|
||||
llvm::consumeError(Result.takeError());
|
||||
return Abort;
|
||||
}
|
||||
|
||||
size_t OutSize = TheInstruction.OutArguments.size();
|
||||
revng_assert(Result->size() == OutSize);
|
||||
|
||||
@@ -282,7 +282,6 @@ Error MachOImporter::import() {
|
||||
}
|
||||
|
||||
Error TheError = Error::success();
|
||||
|
||||
for (const MachOBindEntry &U : MachO.bindTable(TheError))
|
||||
registerBindEntry(&U);
|
||||
if (TheError)
|
||||
|
||||
@@ -48,7 +48,7 @@ public:
|
||||
std::vector<std::vector<pipeline::Kind *>> AcceptedKinds;
|
||||
|
||||
public:
|
||||
llvm::Error run(pipeline::ExecutionContext &Context) {
|
||||
void run(pipeline::ExecutionContext &Context) {
|
||||
std::vector<std::unique_ptr<WellKnownModel>> WellKnownModels;
|
||||
std::map<WellKnownFunctionKey,
|
||||
std::pair<WellKnownModel *, model::Function *>>
|
||||
@@ -58,10 +58,8 @@ public:
|
||||
// Load all well-known models
|
||||
for (const std::string &Path :
|
||||
revng::ResourceFinder.list("share/revng/well-known-models", ".yml")) {
|
||||
auto MaybeModel = TupleTree<model::Binary>::fromFile(Path);
|
||||
revng_assert(MaybeModel);
|
||||
using namespace std;
|
||||
auto NewWKM = make_unique<WellKnownModel>(std::move(*MaybeModel), Model);
|
||||
auto Model = llvm::cantFail(TupleTree<model::Binary>::fromFile(Path));
|
||||
auto NewWKM = std::make_unique<WellKnownModel>(std::move(Model), Model);
|
||||
WellKnownModels.push_back(std::move(NewWKM));
|
||||
}
|
||||
|
||||
@@ -106,8 +104,6 @@ public:
|
||||
|
||||
model::flattenPrimitiveTypedefs(Model);
|
||||
model::deduplicateCollidingNames(Model);
|
||||
|
||||
return llvm::Error::success();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
+6
-13
@@ -106,7 +106,7 @@ static void explainPipeline(const ContainerToTargetsMap &Targets,
|
||||
ExplanationLogger << DoLog;
|
||||
}
|
||||
|
||||
Error Runner::getInvalidations(TargetInStepSet &Invalidated) const {
|
||||
void Runner::getInvalidations(TargetInStepSet &Invalidated) const {
|
||||
|
||||
for (const Step &NextS : *this) {
|
||||
if (not NextS.hasPredecessor())
|
||||
@@ -123,8 +123,6 @@ Error Runner::getInvalidations(TargetInStepSet &Invalidated) const {
|
||||
NextS.containers().intersect(Deduced);
|
||||
Outputs.merge(Deduced);
|
||||
}
|
||||
|
||||
return Error::success();
|
||||
}
|
||||
|
||||
Step &Runner::addStep(Step &&NewStep) {
|
||||
@@ -135,8 +133,8 @@ Step &Runner::addStep(Step &&NewStep) {
|
||||
return *ReversePostOrderIndexes.back();
|
||||
}
|
||||
|
||||
llvm::Error Runner::getInvalidations(const Target &Target,
|
||||
TargetInStepSet &Invalidations) const {
|
||||
void Runner::getInvalidations(const Target &Target,
|
||||
TargetInStepSet &Invalidations) const {
|
||||
for (const Step &Step : *this)
|
||||
for (const auto &Container : Step.containers()) {
|
||||
if (Container.second == nullptr)
|
||||
@@ -146,16 +144,13 @@ llvm::Error Runner::getInvalidations(const Target &Target,
|
||||
Invalidations[Step.getName()].add(Container.first(), Target);
|
||||
}
|
||||
}
|
||||
if (llvm::Error Error = getInvalidations(Invalidations); !!Error)
|
||||
return Error;
|
||||
|
||||
return llvm::Error::success();
|
||||
getInvalidations(Invalidations);
|
||||
}
|
||||
|
||||
Error Runner::invalidate(const Target &Target) {
|
||||
llvm::StringMap<ContainerToTargetsMap> Invalidations;
|
||||
if (llvm::Error Error = getInvalidations(Target, Invalidations); !!Error)
|
||||
return Error;
|
||||
getInvalidations(Target, Invalidations);
|
||||
return invalidate(Invalidations);
|
||||
}
|
||||
|
||||
@@ -482,8 +477,6 @@ void Runner::getDiffInvalidations(const GlobalTupleTreeDiff &Diff,
|
||||
llvm::Error Runner::apply(const GlobalTupleTreeDiff &Diff,
|
||||
TargetInStepSet &Map) {
|
||||
getDiffInvalidations(Diff, Map);
|
||||
if (auto Error = getInvalidations(Map))
|
||||
return Error;
|
||||
|
||||
getInvalidations(Map);
|
||||
return invalidate(Map);
|
||||
}
|
||||
|
||||
@@ -563,8 +563,7 @@ PipelineManager::invalidateAllPossibleTargets() {
|
||||
|
||||
TargetInStepSet Map;
|
||||
Map[Step.first()][Container.first()].push_back(Target);
|
||||
if (auto Error = Runner->getInvalidations(Map))
|
||||
return std::move(Error);
|
||||
Runner->getInvalidations(Map);
|
||||
if (auto Error = Runner->invalidate(Map))
|
||||
return std::move(Error);
|
||||
|
||||
|
||||
@@ -28,9 +28,8 @@ std::string getComponentsHash() {
|
||||
|
||||
std::string Result;
|
||||
for (std::string &File : Files) {
|
||||
auto MaybeBuffer = llvm::MemoryBuffer::getFile(File);
|
||||
revng_assert(MaybeBuffer);
|
||||
llvm::StringRef Contents = MaybeBuffer->get()->getBuffer().trim();
|
||||
auto Buf = cantFail(errorOrToExpected(llvm::MemoryBuffer::getFile(File)));
|
||||
llvm::StringRef Contents = Buf->getBuffer().trim();
|
||||
Result.append(Contents.begin(), Contents.end());
|
||||
}
|
||||
|
||||
|
||||
@@ -25,6 +25,7 @@
|
||||
#include "revng/MFP/Graph.h"
|
||||
#include "revng/MFP/MFP.h"
|
||||
#include "revng/Support/Assert.h"
|
||||
#include "revng/Support/Error.h"
|
||||
#include "revng/TypeShrinking/BitLiveness.h"
|
||||
#include "revng/TypeShrinking/DataFlowGraph.h"
|
||||
|
||||
@@ -289,7 +290,9 @@ BitLivenessPass::Result BitLivenessPass::run(llvm::Function &F,
|
||||
Entry.Operands = MFPResult.OutValue;
|
||||
}
|
||||
|
||||
revng_assert(not DataFlowGraph.verify());
|
||||
if (llvm::Error Error = DataFlowGraph.verify())
|
||||
revng_abort(revng::unwrapError(std::move(Error)).c_str());
|
||||
|
||||
MFP::Graph<BitLivenessAnalysis> MFPGraph(&DataFlowGraph, MFPRes);
|
||||
|
||||
return Result;
|
||||
|
||||
+4
-10
@@ -822,9 +822,7 @@ BOOST_AUTO_TEST_CASE(SingleElementPipelineForwardFinedGrained) {
|
||||
llvm::StringMap<ContainerToTargetsMap> Invalidations;
|
||||
Invalidations[Name].add(CName, {}, RootKind);
|
||||
|
||||
auto Error = Pipeline.getInvalidations(Invalidations);
|
||||
BOOST_TEST(!Error);
|
||||
|
||||
Pipeline.getInvalidations(Invalidations);
|
||||
const auto &EndContainerInvalidations = Invalidations["end"][CName];
|
||||
BOOST_TEST(not EndContainerInvalidations.empty());
|
||||
BOOST_TEST((EndContainerInvalidations == TargetsList({ T, T2 })));
|
||||
@@ -854,8 +852,7 @@ BOOST_AUTO_TEST_CASE(SingleElementPipelineInvalidation) {
|
||||
Target ToKill({}, RootKind);
|
||||
|
||||
llvm::StringMap<ContainerToTargetsMap> Invalidations;
|
||||
auto Error = Pipeline.getInvalidations(ToKill, Invalidations);
|
||||
BOOST_TEST(!Error);
|
||||
Pipeline.getInvalidations(ToKill, Invalidations);
|
||||
const auto &QuantifOfInvalidated = Invalidations["end"][CName]
|
||||
.front()
|
||||
.getPathComponents();
|
||||
@@ -1320,11 +1317,8 @@ BOOST_AUTO_TEST_CASE(MultiStepInvalidationTest) {
|
||||
pipeline::TargetInStepSet Invalidations;
|
||||
Invalidations[Name][CName].push_back(T);
|
||||
|
||||
auto Error = Pipeline.getInvalidations(Invalidations);
|
||||
BOOST_TEST(!Error);
|
||||
|
||||
Error = Pipeline.invalidate(Invalidations);
|
||||
|
||||
Pipeline.getInvalidations(Invalidations);
|
||||
llvm::Error Error = Pipeline.invalidate(Invalidations);
|
||||
BOOST_TEST(!Error);
|
||||
|
||||
BOOST_TEST(C1.get(T) == 0);
|
||||
|
||||
@@ -77,7 +77,7 @@ int main(int argc, char *argv[]) {
|
||||
auto Manager = AbortOnError(BaseOptions.makeManager());
|
||||
|
||||
auto Map = getTargetInStepSet(Manager.getRunner());
|
||||
AbortOnError(Manager.getRunner().getInvalidations(Map));
|
||||
Manager.getRunner().getInvalidations(Map);
|
||||
|
||||
if (DumpPredictedRemovals) {
|
||||
dumpTargetInStepSet(llvm::outs(), Map);
|
||||
|
||||
Reference in New Issue
Block a user