diff --git a/include/revng/Support/OverflowSafeInt.h b/include/revng/Support/OverflowSafeInt.h index 6b15ddfd7..f966cbde9 100644 --- a/include/revng/Support/OverflowSafeInt.h +++ b/include/revng/Support/OverflowSafeInt.h @@ -9,6 +9,7 @@ #include "llvm/Support/MathExtras.h" #include "revng/ADT/Concepts.h" +#include "revng/Support/Debug.h" template class OverflowSafeInt { diff --git a/include/revng/TupleTree/TupleTree.h b/include/revng/TupleTree/TupleTree.h index 58e653ed3..e423a21bc 100644 --- a/include/revng/TupleTree/TupleTree.h +++ b/include/revng/TupleTree/TupleTree.h @@ -165,7 +165,7 @@ public: public: static llvm::Expected fromString(llvm::StringRef YAMLString) { - TupleTree Result{}; + TupleTree Result; auto MaybeRoot = revng::detail::fromStringImpl(YAMLString); if (not MaybeRoot) diff --git a/lib/Model/Pass/PurgeUnnamedAndUnreachableTypes.cpp b/lib/Model/Pass/PurgeUnnamedAndUnreachableTypes.cpp index 7e6f10371..c0c68c00b 100644 --- a/lib/Model/Pass/PurgeUnnamedAndUnreachableTypes.cpp +++ b/lib/Model/Pass/PurgeUnnamedAndUnreachableTypes.cpp @@ -66,6 +66,7 @@ void model::purgeInvalidTypes(TupleTree &Model) { std::optional MaybeSize = Field.Type()->size(VH); return !Field.Type()->verify(VH) && MaybeSize.has_value(); }; + // TODO: purge overlapping struct fields for (auto &&Struct : Model->TypeDefinitions() | model::filter::Struct) Struct.Fields().erase_if(IsFieldInvalid); for (auto &&Union : Model->TypeDefinitions() | model::filter::Union) { @@ -77,11 +78,13 @@ void model::purgeInvalidTypes(TupleTree &Model) { // Note: changing the key of an element in a sorted container shouldn't // be allowed. However, it should be fine in this case, since we // preserve the ordering. + // TODO: don't do the above, recreate the list for (auto &[Index, Field] : llvm::enumerate(Union.Fields())) Field.Index() = Index; revng_assert(Union.Fields().isSorted()); } } + // TODO: purge duplicate enum entries // If there are still any invalid types, we have to get rid of them. auto IsTypeInvalid = [&VH](const model::UpcastableTypeDefinition &T) { diff --git a/lib/Model/Processing.cpp b/lib/Model/Processing.cpp index ccc4fddb0..873a5244f 100644 --- a/lib/Model/Processing.cpp +++ b/lib/Model/Processing.cpp @@ -55,7 +55,7 @@ unsigned dropTypesDependingOnDefinitions(TupleTree &Model, // Prepare for deletion all the nodes reachable from Types std::set ToDelete; for (const model::TypeDefinition *Type : Types) { - for (const auto *Node : depth_first(TypeToNode.at(Type))) { + for (const ForwardNode *Node : depth_first(TypeToNode.at(Type))) { ToDelete.insert(Node->T); } } diff --git a/lib/Model/Verification.cpp b/lib/Model/Verification.cpp index ef47113d4..fbe4ac5d8 100644 --- a/lib/Model/Verification.cpp +++ b/lib/Model/Verification.cpp @@ -426,7 +426,7 @@ static RecursiveCoroutine verifyImpl(VerifyHelper &VH, revng_assert(T.Kind() == model::TypeDefinitionKind::EnumDefinition); if (T.Entries().empty()) - rc_return VH.fail("Every enum definition must have at least one entry."); + rc_return VH.fail("Every enum definition must have at least one entry.", T); if (T.UnderlyingType().isEmpty()) rc_return VH.fail("Every enum must have an underlying type.", T); diff --git a/lib/PromoteStackPointer/SegregateStackAccessesPass.cpp b/lib/PromoteStackPointer/SegregateStackAccessesPass.cpp index befa29252..75df1f7e0 100644 --- a/lib/PromoteStackPointer/SegregateStackAccessesPass.cpp +++ b/lib/PromoteStackPointer/SegregateStackAccessesPass.cpp @@ -820,7 +820,9 @@ private: // Analyze stack usage // - // Analysis preparation: split basic blocks at call sites + // Analysis preparation: split basic blocks at call sites. + // This enables us to use the *final* value of the monotone framework + // associated to the basic block of stack_size_at_call_site. { std::set SplitPoints; for (BasicBlock &BB : F) @@ -855,7 +857,7 @@ private: handleCallSite(AnalysisResult, SSACSCall); // - // Handle memory access, possibly targeting stack arguments + // Handle memory access, possibly targeting formal stack arguments // if (Redirector != nullptr) for (BasicBlock &BB : F) @@ -1304,6 +1306,9 @@ private: }; std::map Stores; BasicBlock *BB = SSACSCall->getParent(); + + // We use the *final* value. In fact, we split the basic block before the + // call to the isolated function as appropriate. const std::set &BlockFinalResult = AnalysisResult.at(BB) .OutValue; for (const StoredByte &Byte : BlockFinalResult) { diff --git a/lib/Support/PathList.cpp b/lib/Support/PathList.cpp index c244d25a5..33b8abac5 100644 --- a/lib/Support/PathList.cpp +++ b/lib/Support/PathList.cpp @@ -123,7 +123,7 @@ findFileInPaths(llvm::StringRef FileName, } revng_assert(FoundFileName, - ("failed to find `" + FileName + "`.").str().c_str()); + ("Failed to find `" + FileName + "`.").str().c_str()); return FoundFileName; } diff --git a/python/revng/support/__init__.py b/python/revng/support/__init__.py index abc71b2b9..d4824c59a 100644 --- a/python/revng/support/__init__.py +++ b/python/revng/support/__init__.py @@ -1,6 +1,7 @@ # # This file is distributed under the MIT License. See LICENSE.md for details. # + import mmap import os import re