Skip to content

Commit

Permalink
More explict casts to uint64_t and missing headers (#772)
Browse files Browse the repository at this point in the history
  • Loading branch information
sjalander authored Jan 27, 2025
1 parent cd479c8 commit 7bcd5e0
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 13 deletions.
22 changes: 16 additions & 6 deletions jlm/llvm/opt/RvsdgTreePrinter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -106,12 +106,14 @@ RvsdgTreePrinter::AnnotateNumRvsdgNodes(
numSubregionNodes += annotateRegion(*subregion);
}

annotationMap.AddAnnotation(structuralNode, { label, numSubregionNodes });
annotationMap.AddAnnotation(
structuralNode,
{ label, static_cast<uint64_t>(numSubregionNodes) });
}
}

auto numNodes = region.nnodes();
annotationMap.AddAnnotation(&region, { label, numNodes });
annotationMap.AddAnnotation(&region, { label, static_cast<uint64_t>(numNodes) });

return numNodes;
};
Expand All @@ -134,12 +136,16 @@ RvsdgTreePrinter::AnnotateNumMemoryStateInputsOutputs(
auto argumentRange = region.Arguments();
auto numMemoryStateArguments =
std::count_if(argumentRange.begin(), argumentRange.end(), IsMemoryStateOutput);
annotationMap.AddAnnotation(&region, { argumentLabel, numMemoryStateArguments });
annotationMap.AddAnnotation(
&region,
{ argumentLabel, static_cast<uint64_t>(numMemoryStateArguments) });

auto resultRange = region.Results();
auto numMemoryStateResults =
std::count_if(resultRange.begin(), resultRange.end(), IsMemoryStateInput);
annotationMap.AddAnnotation(&region, { resultLabel, numMemoryStateResults });
annotationMap.AddAnnotation(
&region,
{ resultLabel, static_cast<uint64_t>(numMemoryStateResults) });

for (auto & node : region.Nodes())
{
Expand All @@ -154,7 +160,9 @@ RvsdgTreePrinter::AnnotateNumMemoryStateInputsOutputs(
numMemoryStateInputs++;
}
}
annotationMap.AddAnnotation(structuralNode, { inputLabel, numMemoryStateInputs });
annotationMap.AddAnnotation(
structuralNode,
{ inputLabel, static_cast<uint64_t>(numMemoryStateInputs) });

size_t numMemoryStateOutputs = 0;
for (size_t n = 0; n < structuralNode->noutputs(); n++)
Expand All @@ -165,7 +173,9 @@ RvsdgTreePrinter::AnnotateNumMemoryStateInputsOutputs(
numMemoryStateOutputs++;
}
}
annotationMap.AddAnnotation(structuralNode, { outputLabel, numMemoryStateOutputs });
annotationMap.AddAnnotation(
structuralNode,
{ outputLabel, static_cast<uint64_t>(numMemoryStateOutputs) });

for (size_t n = 0; n < structuralNode->nsubregions(); n++)
{
Expand Down
2 changes: 1 addition & 1 deletion jlm/llvm/opt/alias-analyses/PointerObjectSet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -920,7 +920,7 @@ EscapedFunctionConstraint::PropagateEscapedFunctionsDirectly(PointerObjectSet &
modified |= set.MarkAsPointingToExternal(index);
};

for (const auto [lambda, lambdaPO] : set.GetFunctionMap())
for (const auto & [lambda, lambdaPO] : set.GetFunctionMap())
{
if (set.HasEscaped(lambdaPO))
HandleEscapedFunction(set, lambdaPO, markAsPointeesEscaping, markAsPointsToExternal);
Expand Down
2 changes: 2 additions & 0 deletions jlm/util/Statistics.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@
#include <memory>
#include <optional>
#include <string>
#include <unordered_map>
#include <variant>
#include <vector>

namespace jlm::util
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1465,9 +1465,9 @@ TestStatistics()
assert(statisticsCollector.NumCollectedStatistics() == 1);
auto & statistics = *statisticsCollector.CollectedStatistics().begin();

assert(statistics.GetMeasurementValue<size_t>("#RvsdgNodes") == 3);
assert(statistics.GetMeasurementValue<size_t>("#RvsdgRegions") == 2);
assert(statistics.GetMeasurementValue<size_t>("#PointsToGraphMemoryNodes") == 2);
assert(statistics.GetMeasurementValue<uint64_t>("#RvsdgNodes") == 3);
assert(statistics.GetMeasurementValue<uint64_t>("#RvsdgRegions") == 2);
assert(statistics.GetMeasurementValue<uint64_t>("#PointsToGraphMemoryNodes") == 2);

assert(statistics.HasTimer("AnnotationTime"));
assert(statistics.HasTimer("PropagationPass1Time"));
Expand Down
10 changes: 7 additions & 3 deletions tests/jlm/rvsdg/RegionTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,7 @@ ToTree_EmptyRvsdgWithAnnotations()
AnnotationMap annotationMap;
annotationMap.AddAnnotation(
&rvsdg.GetRootRegion(),
Annotation("NumNodes", rvsdg.GetRootRegion().nnodes()));
Annotation("NumNodes", static_cast<uint64_t>(rvsdg.GetRootRegion().nnodes())));

// Act
auto tree = Region::ToTree(rvsdg.GetRootRegion(), annotationMap);
Expand Down Expand Up @@ -420,8 +420,12 @@ ToTree_RvsdgWithStructuralNodesAndAnnotations()
auto subregion2 = structuralNode2->subregion(2);

AnnotationMap annotationMap;
annotationMap.AddAnnotation(subregion2, Annotation("NumNodes", subregion2->nnodes()));
annotationMap.AddAnnotation(subregion2, Annotation("NumArguments", subregion2->narguments()));
annotationMap.AddAnnotation(
subregion2,
Annotation("NumNodes", static_cast<uint64_t>(subregion2->nnodes())));
annotationMap.AddAnnotation(
subregion2,
Annotation("NumArguments", static_cast<uint64_t>(subregion2->narguments())));

// Act
auto tree = Region::ToTree(rvsdg.GetRootRegion(), annotationMap);
Expand Down

0 comments on commit 7bcd5e0

Please sign in to comment.