mirror of
https://github.com/revng/revng
synced 2026-06-21 14:07:57 +00:00
Minor changes
This commit is contained in:
@@ -9,6 +9,7 @@
|
||||
#include "llvm/Support/MathExtras.h"
|
||||
|
||||
#include "revng/ADT/Concepts.h"
|
||||
#include "revng/Support/Debug.h"
|
||||
|
||||
template<std::integral T>
|
||||
class OverflowSafeInt {
|
||||
|
||||
@@ -165,7 +165,7 @@ public:
|
||||
|
||||
public:
|
||||
static llvm::Expected<TupleTree> fromString(llvm::StringRef YAMLString) {
|
||||
TupleTree Result{};
|
||||
TupleTree Result;
|
||||
|
||||
auto MaybeRoot = revng::detail::fromStringImpl<T>(YAMLString);
|
||||
if (not MaybeRoot)
|
||||
|
||||
@@ -66,6 +66,7 @@ void model::purgeInvalidTypes(TupleTree<model::Binary> &Model) {
|
||||
std::optional<uint64_t> 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::Binary> &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) {
|
||||
|
||||
@@ -55,7 +55,7 @@ unsigned dropTypesDependingOnDefinitions(TupleTree<model::Binary> &Model,
|
||||
// Prepare for deletion all the nodes reachable from Types
|
||||
std::set<const model::TypeDefinition *> ToDelete;
|
||||
for (const model::TypeDefinition *Type : Types) {
|
||||
for (const auto *Node : depth_first(TypeToNode.at(Type))) {
|
||||
for (const ForwardNode<TypeNode> *Node : depth_first(TypeToNode.at(Type))) {
|
||||
ToDelete.insert(Node->T);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -426,7 +426,7 @@ static RecursiveCoroutine<bool> 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);
|
||||
|
||||
@@ -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<Instruction *> 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<StoreInst *, StoreInfo> 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<StoredByte> &BlockFinalResult = AnalysisResult.at(BB)
|
||||
.OutValue;
|
||||
for (const StoredByte &Byte : BlockFinalResult) {
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#
|
||||
# This file is distributed under the MIT License. See LICENSE.md for details.
|
||||
#
|
||||
|
||||
import mmap
|
||||
import os
|
||||
import re
|
||||
|
||||
Reference in New Issue
Block a user