59 uint64_t numNonEscaped)
70 const uint64_t totalMemoryStates =
71 numAllocas + numMallocs + numDeltas + numImports + numLambdas + numExternal;
85 uint64_t numAllocas = 0;
86 uint64_t numMallocs = 0;
87 uint64_t numDeltas = 0;
88 uint64_t numImports = 0;
89 uint64_t numLambdas = 0;
90 uint64_t numExternal = 0;
92 uint64_t numNonEscaped = 0;
94 for (
const auto memoryNode : memoryNodes.
Items())
99 const auto kind = pointsToGraph.
getNodeKind(memoryNode);
121 throw std::logic_error(
"Unknown MemoryNode kind");
221 static std::unique_ptr<EncodingStatistics>
224 return std::make_unique<EncodingStatistics>(sourceFile);
280 JLM_ASSERT(is<MemoryStateType>(state.Type()));
287 const std::vector<MemoryNodeStatePair *> & memoryNodeStatePairs,
288 const std::vector<rvsdg::Output *> & states)
290 JLM_ASSERT(memoryNodeStatePairs.size() == states.size());
291 for (
size_t n = 0; n < memoryNodeStatePairs.size(); n++)
297 const std::vector<MemoryNodeStatePair *> & memoryNodeStatePairs,
300 auto it = states.
begin();
301 for (
auto memoryNodeStatePair : memoryNodeStatePairs)
303 memoryNodeStatePair->ReplaceState(*it);
309 static std::vector<rvsdg::Output *>
310 States(
const std::vector<MemoryNodeStatePair *> & memoryNodeStatePairs)
312 std::vector<rvsdg::Output *> states;
313 for (
auto & memoryNodeStatePair : memoryNodeStatePairs)
314 states.push_back(memoryNodeStatePair->State_);
339 if (
const auto it =
states_.find(memoryNode); it !=
states_.end())
345 const MemoryNodeStatePair *
357 MemoryNodeStatePair *
360 if (
const auto statePair =
TryGetState(memoryNode))
362 throw std::logic_error(
"Memory node does not have a state.");
365 std::vector<MemoryNodeStatePair *>
368 std::vector<MemoryNodeStatePair *> memoryNodeStatePairs;
369 for (
auto & memoryNode : memoryNodes.
Items())
371 memoryNodeStatePairs.push_back(
GetState(memoryNode));
374 return memoryNodeStatePairs;
384 std::vector<MemoryNodeStatePair *>
387 std::vector<MemoryNodeStatePair *> memoryNodeStatePairs;
388 for (
auto & memoryNode : memoryNodes.
Items())
390 if (
const auto statePair =
TryGetState(memoryNode))
391 memoryNodeStatePairs.push_back(statePair);
394 return memoryNodeStatePairs;
404 MemoryNodeStatePair *
407 auto [it, added] =
states_.insert({ memoryNode, { memoryNode, state } });
409 throw std::logic_error(
"Memory node already has a state.");
413 static std::unique_ptr<StateMap>
416 return std::make_unique<StateMap>();
422 std::unordered_map<PointsToGraph::NodeIndex, MemoryNodeStatePair>
states_;
474 std::vector<StateMap::MemoryNodeStatePair *>
492 std::vector<StateMap::MemoryNodeStatePair *>
500 std::vector<StateMap::MemoryNodeStatePair *>
536 std::unordered_map<const rvsdg::Region *, std::unique_ptr<StateMap>>
StateMaps_;
595 static std::unique_ptr<MemoryStateEncoder::Context>
598 return std::make_unique<Context>(modRefSummary);
612 static std::vector<MemoryNodeId>
615 std::vector<MemoryNodeId> memoryNodeIds;
616 for (
const auto memoryNode : memoryNodes.
Items())
618 memoryNodeIds.push_back(memoryNode);
621 return memoryNodeIds;
626 MemoryStateEncoder::MemoryStateEncoder() = default;
630 rvsdg::RvsdgModule & rvsdgModule,
634 Context_ = Context::Create(modRefSummary);
637 statistics->Start(rvsdgModule.Rvsdg());
638 EncodeRegion(rvsdgModule.Rvsdg().GetRootRegion());
641 statistics->AddIntraProceduralRegionMemoryStateCounts(
642 Context_->GetInterProceduralRegionCounter());
643 statistics->AddLoadMemoryStateCounts(Context_->GetLoadCounter());
644 statistics->AddStoreMemoryStateCounts(Context_->GetStoreCounter());
645 statistics->AddCallEntryMergeStateCounts(Context_->GetCallEntryMergeCounter());
663 for (
const auto node : traverser)
685 else if (
auto deltaNode =
dynamic_cast<const rvsdg::DeltaNode *
>(&structuralNode))
689 else if (
auto phiNode =
dynamic_cast<const rvsdg::PhiNode *
>(&structuralNode))
693 else if (
auto gammaNode =
dynamic_cast<rvsdg::GammaNode *
>(&structuralNode))
697 else if (
auto thetaNode =
dynamic_cast<rvsdg::ThetaNode *
>(&structuralNode))
714 EncodeAlloca(simpleNode);
718 EncodeMalloc(simpleNode);
722 EncodeLoad(simpleNode);
726 EncodeStore(simpleNode);
730 EncodeCall(simpleNode);
734 EncodeFree(simpleNode);
738 EncodeMemcpy(simpleNode);
742 EncodeMemset(simpleNode);
751 JLM_ASSERT(!hasMemoryState(simpleNode));
760 auto & stateMap =
Context_->GetRegionalizedStateMap();
761 auto allocaMemoryNodes = stateMap.GetSimpleNodeModRef(allocaNode);
763 auto allocaMemoryNode = *allocaMemoryNodes.Items().begin();
764 auto & allocaNodeStateOutput = *allocaNode.
output(1);
768 if (
const auto statePair = stateMap.TryGetState(*allocaNode.
region(), allocaMemoryNode))
772 auto & joinOutput = *joinNode.
output(0);
773 statePair->ReplaceState(joinOutput);
777 stateMap.InsertState(allocaMemoryNode, allocaNodeStateOutput);
785 auto & stateMap =
Context_->GetRegionalizedStateMap();
786 auto mallocMemoryNodes = stateMap.GetSimpleNodeModRef(mallocNode);
788 auto mallocMemoryNode = *mallocMemoryNodes.Items().begin();
796 if (
const auto statePair = stateMap.TryGetState(*mallocNode.
region(), mallocMemoryNode))
800 auto & joinOutput = *joinNode.
output(0);
801 statePair->ReplaceState(joinOutput);
805 stateMap.InsertState(mallocMemoryNode, mallocNodeStateOutput);
813 auto & stateMap =
Context_->GetRegionalizedStateMap();
815 const auto & memoryNodes = stateMap.GetSimpleNodeModRef(node);
816 Context_->GetLoadCounter().CountEntity(
817 Context_->GetModRefSummary().GetPointsToGraph(),
820 const auto memoryNodeStatePairs = stateMap.GetExistingStates(*node.
region(), memoryNodes);
826 memoryNodeStatePairs,
833 auto & stateMap =
Context_->GetRegionalizedStateMap();
835 const auto & memoryNodes = stateMap.GetSimpleNodeModRef(node);
836 Context_->GetStoreCounter().CountEntity(
837 Context_->GetModRefSummary().GetPointsToGraph(),
840 const auto memoryNodeStatePairs = stateMap.GetExistingStates(*node.
region(), memoryNodes);
846 memoryNodeStatePairs,
854 auto & stateMap =
Context_->GetRegionalizedStateMap();
858 auto memoryNodeStatePairs = stateMap.GetExistingStates(freeNode);
867 memoryNodeStatePairs,
874 const auto region = callNode.
region();
875 auto & regionalizedStateMap =
Context_->GetRegionalizedStateMap();
877 const auto & memoryNodes = regionalizedStateMap.GetSimpleNodeModRef(callNode);
878 Context_->GetCallEntryMergeCounter().CountEntity(
879 Context_->GetModRefSummary().GetPointsToGraph(),
882 const auto statePairs = regionalizedStateMap.GetExistingStates(*region, memoryNodes);
884 std::vector<rvsdg::Output *> inputStates;
885 std::vector<MemoryNodeId> memoryNodeIds;
886 for (
auto statePair : statePairs)
888 inputStates.emplace_back(&statePair->State());
889 memoryNodeIds.push_back(statePair->MemoryNode());
892 auto & entryMergeNode =
907 auto & stateMap =
Context_->GetRegionalizedStateMap();
909 auto memoryNodeStatePairs = stateMap.GetExistingStates(memcpyNode);
921 auto & stateMap =
Context_->GetRegionalizedStateMap();
923 auto memoryNodeStatePairs = stateMap.GetExistingStates(memsetNode);
944 const auto & memoryNodes =
Context_->GetModRefSummary().GetLambdaEntryModRef(lambdaNode);
945 Context_->GetInterProceduralRegionCounter().CountEntity(
946 Context_->GetModRefSummary().GetPointsToGraph(),
950 auto & stateMap =
Context_->GetRegionalizedStateMap();
952 stateMap.PushRegion(*lambdaNode.
subregion());
953 auto & lambdaEntrySplitNode =
958 for (
auto & memoryNode : memoryNodes.Items())
959 stateMap.InsertState(memoryNode, *states[n++]);
978 memoryStateArgument.divertUsersWhere(
982 return rvsdg::TryGetOwnerNode<rvsdg::SimpleNode>(user) != &lambdaEntrySplitNode;
990 const auto & memoryNodes =
Context_->GetModRefSummary().GetLambdaExitModRef(lambdaNode);
991 auto & stateMap =
Context_->GetRegionalizedStateMap();
994 std::vector<rvsdg::Output *> states;
995 std::vector<MemoryNodeId> memoryNodeIds;
996 auto & subregion = *lambdaNode.
subregion();
997 const auto memoryNodeStatePairs = stateMap.GetStates(subregion, memoryNodes);
998 for (
const auto memoryNodeStatePair : memoryNodeStatePairs)
1000 states.push_back(&memoryNodeStatePair->State());
1001 memoryNodeIds.push_back(memoryNodeStatePair->MemoryNode());
1004 const auto mergedState =
1006 memoryStateResult.divert_to(mergedState);
1008 stateMap.PopRegion(*lambdaNode.
subregion());
1026 for (
auto & subregion : gammaNode.
Subregions())
1027 Context_->GetRegionalizedStateMap().PushRegion(subregion);
1031 for (
auto & subregion : gammaNode.
Subregions())
1036 for (
auto & subregion : gammaNode.
Subregions())
1037 Context_->GetRegionalizedStateMap().PopRegion(subregion);
1043 auto region = gammaNode.
region();
1044 auto & stateMap =
Context_->GetRegionalizedStateMap();
1045 auto memoryNodes =
Context_->GetModRefSummary().GetGammaEntryModRef(gammaNode);
1048 for ([[maybe_unused]]
auto & subregion : gammaNode.
Subregions())
1049 Context_->GetInterProceduralRegionCounter().CountEntity(
1050 Context_->GetModRefSummary().GetPointsToGraph(),
1053 auto memoryNodeStatePairs = stateMap.GetExistingStates(*region, memoryNodes);
1054 for (
auto & memoryNodeStatePair : memoryNodeStatePairs)
1056 auto gammaInput = gammaNode.
AddEntryVar(&memoryNodeStatePair->State());
1057 for (
auto & argument : gammaInput.branchArgument)
1058 stateMap.InsertState(memoryNodeStatePair->MemoryNode(), *argument);
1065 auto & stateMap =
Context_->GetRegionalizedStateMap();
1066 auto memoryNodes =
Context_->GetModRefSummary().GetGammaExitModRef(gammaNode);
1067 auto memoryNodeStatePairs = stateMap.GetExistingStates(*gammaNode.
region(), memoryNodes);
1069 for (
auto & memoryNodeStatePair : memoryNodeStatePairs)
1071 std::vector<rvsdg::Output *> states;
1073 for (
auto & subregion : gammaNode.
Subregions())
1075 auto & state = stateMap.GetState(subregion, memoryNodeStatePair->MemoryNode())->State();
1076 states.push_back(&state);
1080 memoryNodeStatePair->ReplaceState(*state);
1096 std::vector<rvsdg::Output *>
1099 auto region = thetaNode.
region();
1100 auto & stateMap =
Context_->GetRegionalizedStateMap();
1101 const auto & memoryNodes =
Context_->GetModRefSummary().GetThetaModRef(thetaNode);
1102 Context_->GetInterProceduralRegionCounter().CountEntity(
1103 Context_->GetModRefSummary().GetPointsToGraph(),
1106 std::vector<rvsdg::Output *> thetaStateOutputs;
1107 auto memoryNodeStatePairs = stateMap.GetExistingStates(*region, memoryNodes);
1108 for (
auto & memoryNodeStatePair : memoryNodeStatePairs)
1110 auto loopvar = thetaNode.
AddLoopVar(&memoryNodeStatePair->State());
1111 stateMap.InsertState(memoryNodeStatePair->MemoryNode(), *loopvar.pre);
1112 thetaStateOutputs.push_back(loopvar.output);
1115 return thetaStateOutputs;
1121 const std::vector<rvsdg::Output *> & thetaStateOutputs)
1124 auto & stateMap =
Context_->GetRegionalizedStateMap();
1125 const auto & memoryNodes =
Context_->GetModRefSummary().GetThetaModRef(thetaNode);
1126 auto memoryNodeStatePairs = stateMap.GetExistingStates(*thetaNode.
region(), memoryNodes);
1128 JLM_ASSERT(memoryNodeStatePairs.size() == thetaStateOutputs.size());
1129 for (
size_t n = 0; n < thetaStateOutputs.size(); n++)
1131 auto thetaStateOutput = thetaStateOutputs[n];
1132 auto & memoryNodeStatePair = memoryNodeStatePairs[n];
1133 auto memoryNode = memoryNodeStatePair->MemoryNode();
1135 JLM_ASSERT(loopvar.input->origin() == &memoryNodeStatePair->State());
1137 auto & subregionState = stateMap.GetState(*subregion, memoryNode)->State();
1138 loopvar.post->divert_to(&subregionState);
1139 memoryNodeStatePair->ReplaceState(*thetaStateOutput);
1146 const std::vector<rvsdg::Output *> & memoryStates)
1150 if (
const auto loadVolatileOperation =
1157 loadVolatileOperation->GetLoadedType(),
1158 loadVolatileOperation->GetAlignment());
1163 oldLoadedValueOutput.divert_users(&newLoadedValueOutput);
1164 oldIOStateOutput.divert_users(&newIOStateOutput);
1168 if (
const auto loadNonVolatileOperation =
1174 loadNonVolatileOperation->GetLoadedType(),
1175 loadNonVolatileOperation->GetAlignment());
1178 oldLoadedValueOutput.divert_users(&newLoadedValueOutput);
1188 const std::vector<rvsdg::Output *> & memoryStates)
1190 if (
const auto oldStoreVolatileOperation =
1198 oldStoreVolatileOperation->GetAlignment());
1201 oldIOStateOutput.divert_users(&newIOStateOutput);
1202 return newStoreNode;
1205 if (
const auto oldStoreNonVolatileOperation =
1212 oldStoreNonVolatileOperation->GetAlignment());
1218 std::vector<rvsdg::Output *>
1221 const std::vector<rvsdg::Output *> & memoryStates)
1229 if (is<MemCpyVolatileOperation>(memcpyNode.
GetOperation()))
1232 auto & newMemcpyNode =
1240 return { std::next(results.begin()), results.end() };
1242 if (is<MemCpyNonVolatileOperation>(memcpyNode.
GetOperation()))
1247 throw std::logic_error(
"Unhandled memcpy operation type.");
1250 std::vector<rvsdg::Output *>
1253 const std::vector<rvsdg::Output *> & memoryStates)
1261 if (is<MemSetNonVolatileOperation>(memsetNode.
GetOperation()))
1267 throw std::logic_error(
"Unhandled memset operation type.");
static jlm::util::StatisticsCollector statisticsCollector
static rvsdg::SimpleNode & CreateNode(rvsdg::Region ®ion, const std::vector< rvsdg::Output * > &operands, std::vector< MemoryNodeId > memoryNodeIds)
static rvsdg::SimpleNode & CreateNode(rvsdg::Output &operand, std::vector< MemoryNodeId > memoryNodeIds)
static rvsdg::Input & GetMemoryStateInput(const rvsdg::Node &node) noexcept
static rvsdg::Output & GetMemoryStateOutput(const rvsdg::Node &node) noexcept
Dead Node Elimination Optimization.
void Run(rvsdg::RvsdgModule &module, util::StatisticsCollector &statisticsCollector) override
Perform RVSDG transformation.
static std::unique_ptr< llvm::ThreeAddressCode > Create(const Variable *pointer, const std::vector< const Variable * > &memoryStates, const Variable *iOState)
static rvsdg::SimpleNode & CreateNode(rvsdg::Output &operand, std::vector< MemoryNodeId > memoryNodeIds)
static rvsdg::SimpleNode & CreateNode(rvsdg::Region ®ion, const std::vector< rvsdg::Output * > &operands, const std::vector< MemoryNodeId > &memoryNodeIds)
static rvsdg::SimpleNode & CreateNode(rvsdg::Region ®ion, std::unique_ptr< LoadNonVolatileOperation > loadOperation, const std::vector< rvsdg::Output * > &operands)
static rvsdg::Input & AddressInput(const rvsdg::Node &node) noexcept
static rvsdg::Output & LoadedValueOutput(const rvsdg::Node &node)
static rvsdg::Node::OutputIteratorRange MemoryStateOutputs(const rvsdg::Node &node) noexcept
static rvsdg::Input & IOStateInput(const rvsdg::Node &node) noexcept
static rvsdg::SimpleNode & CreateNode(rvsdg::Region ®ion, std::unique_ptr< LoadVolatileOperation > loadOperation, const std::vector< rvsdg::Output * > &operands)
static rvsdg::Output & IOStateOutput(const rvsdg::Node &node)
static rvsdg::Output & memoryStateOutput(const rvsdg::Node &node)
static std::unique_ptr< llvm::ThreeAddressCode > create(const Variable *destination, const Variable *source, const Variable *length, const std::vector< const Variable * > &memoryStates)
static rvsdg::SimpleNode & CreateNode(rvsdg::Output &destination, rvsdg::Output &source, rvsdg::Output &length, rvsdg::Output &ioState, const std::vector< rvsdg::Output * > &memoryStates)
static rvsdg::SimpleNode & createNode(rvsdg::Output &destination, rvsdg::Output &value, rvsdg::Output &length, const std::vector< rvsdg::Output * > &memoryStates)
static rvsdg::Input & destinationInput(const rvsdg::Node &node) noexcept
static rvsdg::Input & lengthInput(const rvsdg::Node &node) noexcept
static rvsdg::Input & valueInput(const rvsdg::Node &node) noexcept
static rvsdg::SimpleNode & CreateNode(const std::vector< rvsdg::Output * > &operands)
static rvsdg::Output * Create(const std::vector< rvsdg::Output * > &operands)
static rvsdg::SimpleNode & CreateNode(rvsdg::Output &address, rvsdg::Output &value, const std::vector< rvsdg::Output * > &memoryStates, size_t alignment)
static rvsdg::Input & StoredValueInput(const rvsdg::Node &node) noexcept
static rvsdg::Node::OutputIteratorRange MemoryStateOutputs(const rvsdg::Node &node) noexcept
static rvsdg::Input & AddressInput(const rvsdg::Node &node) noexcept
static rvsdg::Output & IOStateOutput(const rvsdg::Node &node) noexcept
static rvsdg::SimpleNode & CreateNode(rvsdg::Region ®ion, std::unique_ptr< StoreVolatileOperation > storeOperation, const std::vector< rvsdg::Output * > &operands)
static rvsdg::Input & IOStateInput(const rvsdg::Node &node) noexcept
Statistics class for memory state encoder encoding.
static std::unique_ptr< EncodingStatistics > Create(const util::FilePath &sourceFile)
static constexpr auto NumMaxMemoryState_
void AddStoreMemoryStateCounts(const MemoryStateTypeCounter &counter)
static constexpr auto NumStoreOperations_
static constexpr auto NumIntraProceduralRegions_
void AddCallEntryMergeStateCounts(const MemoryStateTypeCounter &counter)
static constexpr auto NumTotalMallocState_
static constexpr auto NumTotalAllocaState_
void AddLoadMemoryStateCounts(const MemoryStateTypeCounter &counter)
static constexpr auto NumCallEntryMergeOperations_
static constexpr auto RegionArgumentStateSuffix_
static constexpr auto NumTotalNonEscapedState_
static constexpr auto NumTotalExternalState_
static constexpr auto LoadStateSuffix_
void AddMemoryStateTypeCounter(const std::string &suffix, const MemoryStateTypeCounter &counter)
void AddIntraProceduralRegionMemoryStateCounts(const MemoryStateTypeCounter &counter)
static constexpr auto CallEntryMergeStateSuffix_
EncodingStatistics(const util::FilePath &sourceFile)
static constexpr auto NumMaxNonEscapedMemoryState_
static constexpr auto NumTotalDeltaState_
~EncodingStatistics() override=default
static constexpr auto NumTotalImportState_
static constexpr auto StoreStateSuffix_
static constexpr auto NumTotalLambdaState_
static constexpr auto NumLoadOperations_
void Start(const rvsdg::Graph &graph)
Context for the memory state encoder.
Context(const ModRefSummary &modRefSummary)
RegionalizedStateMap RegionalizedStateMap_
static std::unique_ptr< MemoryStateEncoder::Context > Create(const ModRefSummary &modRefSummary)
Context & operator=(const Context &)=delete
MemoryStateTypeCounter & GetCallEntryMergeCounter()
MemoryStateTypeCounter & GetStoreCounter()
MemoryStateTypeCounter & GetLoadCounter()
MemoryStateTypeCounter LoadCounter_
const ModRefSummary & GetModRefSummary() const noexcept
Context(const Context &)=delete
MemoryStateTypeCounter & GetInterProceduralRegionCounter()
RegionalizedStateMap & GetRegionalizedStateMap() noexcept
MemoryStateTypeCounter CallEntryMergeCounter_
MemoryStateTypeCounter InterProceduralRegionCounter_
MemoryStateTypeCounter StoreCounter_
const ModRefSummary & ModRefSummary_
Context(Context &&)=delete
Context & operator=(Context &&)=delete
static std::vector< rvsdg::Output * > ReplaceMemcpyNode(const rvsdg::SimpleNode &memcpyNode, const std::vector< rvsdg::Output * > &memoryStates)
void EncodeMalloc(const rvsdg::SimpleNode &mallocNode)
void EncodeCall(const rvsdg::SimpleNode &callNode)
void EncodeLambdaEntry(const rvsdg::LambdaNode &lambdaNode)
void EncodeAlloca(const rvsdg::SimpleNode &allocaNode)
static rvsdg::SimpleNode & ReplaceStoreNode(const rvsdg::SimpleNode &node, const std::vector< rvsdg::Output * > &memoryStates)
void EncodeStructuralNode(rvsdg::StructuralNode &structuralNode)
void EncodeDelta(const rvsdg::DeltaNode &deltaNode)
void EncodeLambda(const rvsdg::LambdaNode &lambda)
void EncodeLoad(const rvsdg::SimpleNode &node)
void EncodeGammaExit(rvsdg::GammaNode &gammaNode)
void EncodeStore(const rvsdg::SimpleNode &node)
std::unique_ptr< Context > Context_
void EncodeGammaEntry(rvsdg::GammaNode &gammaNode)
void EncodeRegion(rvsdg::Region ®ion)
static rvsdg::SimpleNode & ReplaceLoadNode(const rvsdg::SimpleNode &node, const std::vector< rvsdg::Output * > &memoryStates)
~MemoryStateEncoder() noexcept
void EncodeSimpleNode(const rvsdg::SimpleNode &simpleNode)
std::vector< rvsdg::Output * > EncodeThetaEntry(rvsdg::ThetaNode &thetaNode)
void EncodePhi(const rvsdg::PhiNode &phiNode)
static std::vector< rvsdg::Output * > ReplaceMemsetNode(const rvsdg::SimpleNode &memsetNode, const std::vector< rvsdg::Output * > &memoryStates)
void EncodeMemcpy(const rvsdg::SimpleNode &memcpyNode)
void EncodeGamma(rvsdg::GammaNode &gammaNode)
void EncodeFree(const rvsdg::SimpleNode &freeNode)
void EncodeMemset(const rvsdg::SimpleNode &memsetNode)
void EncodeLambdaExit(const rvsdg::LambdaNode &lambdaNode)
void EncodeThetaExit(rvsdg::ThetaNode &thetaNode, const std::vector< rvsdg::Output * > &thetaStateOutputs)
void EncodeTheta(rvsdg::ThetaNode &thetaNode)
virtual const util::HashSet< PointsToGraph::NodeIndex > & GetSimpleNodeModRef(const rvsdg::SimpleNode &node) const =0
bool isExternallyAvailable(NodeIndex index) const
NodeKind getNodeKind(NodeIndex index) const
Hash map for mapping Rvsdg regions to StateMap class instances.
std::unordered_map< const rvsdg::Region *, std::unique_ptr< StateMap > > StateMaps_
StateMap::MemoryNodeStatePair * GetState(const rvsdg::Region ®ion, PointsToGraph::NodeIndex memoryNode)
const ModRefSummary & ModRefSummary_
void PushRegion(const rvsdg::Region ®ion)
bool HasState(const rvsdg::Region ®ion, PointsToGraph::NodeIndex memoryNode) const
std::vector< StateMap::MemoryNodeStatePair * > GetExistingStates(const rvsdg::SimpleNode &node) const
StateMap::MemoryNodeStatePair * InsertState(PointsToGraph::NodeIndex memoryNode, rvsdg::Output &state)
RegionalizedStateMap(RegionalizedStateMap &&)=delete
RegionalizedStateMap(const ModRefSummary &modRefSummary)
RegionalizedStateMap & operator=(RegionalizedStateMap &&)=delete
std::vector< StateMap::MemoryNodeStatePair * > GetExistingStates(const rvsdg::Region ®ion, const util::HashSet< PointsToGraph::NodeIndex > &memoryNodes) const
const util::HashSet< PointsToGraph::NodeIndex > & GetSimpleNodeModRef(const rvsdg::SimpleNode &node) const
RegionalizedStateMap(const RegionalizedStateMap &)=delete
StateMap::MemoryNodeStatePair * TryGetState(const rvsdg::Region ®ion, PointsToGraph::NodeIndex memoryNode) const
RegionalizedStateMap & operator=(const RegionalizedStateMap &)=delete
std::vector< StateMap::MemoryNodeStatePair * > GetStates(const rvsdg::Region ®ion, const util::HashSet< PointsToGraph::NodeIndex > &memoryNodes)
void PopRegion(const rvsdg::Region ®ion)
StateMap & GetStateMap(const rvsdg::Region ®ion) const noexcept
static void ReplaceStates(const std::vector< MemoryNodeStatePair * > &memoryNodeStatePairs, const rvsdg::Node::OutputIteratorRange &states)
static void ReplaceStates(const std::vector< MemoryNodeStatePair * > &memoryNodeStatePairs, const std::vector< rvsdg::Output * > &states)
void ReplaceState(rvsdg::Output &state) noexcept
PointsToGraph::NodeIndex MemoryNode_
static std::vector< rvsdg::Output * > States(const std::vector< MemoryNodeStatePair * > &memoryNodeStatePairs)
MemoryNodeStatePair(PointsToGraph::NodeIndex memoryNode, rvsdg::Output &state)
PointsToGraph::NodeIndex MemoryNode() const noexcept
rvsdg::Output & State() const noexcept
Hash map for mapping points-to graph memory nodes to RVSDG memory states.
std::unordered_map< PointsToGraph::NodeIndex, MemoryNodeStatePair > states_
std::vector< MemoryNodeStatePair * > GetExistingStates(const util::HashSet< PointsToGraph::NodeIndex > &memoryNodes)
StateMap & operator=(StateMap &&)=delete
MemoryNodeStatePair * GetState(PointsToGraph::NodeIndex memoryNode)
StateMap(const StateMap &)=delete
MemoryNodeStatePair * InsertState(PointsToGraph::NodeIndex memoryNode, rvsdg::Output &state)
std::vector< MemoryNodeStatePair * > GetStates(const util::HashSet< PointsToGraph::NodeIndex > &memoryNodes)
bool HasState(PointsToGraph::NodeIndex memoryNode) const noexcept
static std::unique_ptr< StateMap > Create()
StateMap & operator=(const StateMap &)=delete
MemoryNodeStatePair * TryGetState(PointsToGraph::NodeIndex memoryNode) noexcept
StateMap(StateMap &&)=delete
const MemoryNodeStatePair * TryGetState(PointsToGraph::NodeIndex memoryNode) const noexcept
Conditional operator / pattern matching.
EntryVar AddEntryVar(rvsdg::Output *origin)
Routes a variable into the gamma branches.
ExitVar AddExitVar(const std::vector< rvsdg::Output * > &values)
Routes per-branch result of gamma to output.
Region & GetRootRegion() const noexcept
rvsdg::Region * subregion() const noexcept
rvsdg::Region * region() const noexcept
size_t ninputs() const noexcept
size_t noutputs() const noexcept
rvsdg::Region * region() const noexcept
const std::shared_ptr< const rvsdg::Type > & Type() const noexcept
void divert_users(jlm::rvsdg::Output *new_origin)
A phi node represents the fixpoint of mutually recursive definitions.
rvsdg::Region * subregion() const noexcept
Represent acyclic RVSDG subgraphs.
const SimpleOperation & GetOperation() const noexcept override
NodeInput * input(size_t index) const noexcept
NodeOutput * output(size_t index) const noexcept
SubregionIteratorRange Subregions()
LoopVar MapOutputLoopVar(const rvsdg::Output &output) const
Maps variable at exit to full varibale description.
rvsdg::Region * subregion() const noexcept
LoopVar AddLoopVar(rvsdg::Output *origin)
Creates a new loop-carried variable.
IteratorRange< ItemConstIterator > Items() const noexcept
void CollectDemandedStatistics(std::unique_ptr< Statistics > statistics)
util::Timer & GetTimer(const std::string &name)
Statistics(const Statistics::Id &statisticsId, util::FilePath sourceFile)
util::Timer & AddTimer(std::string name)
void AddMeasurement(std::string name, T value)
#define JLM_UNREACHABLE(msg)
static std::vector< MemoryNodeId > GetMemoryNodeIds(const util::HashSet< PointsToGraph::NodeIndex > &memoryNodes)
rvsdg::Input & GetMemoryStateRegionResult(const rvsdg::LambdaNode &lambdaNode) noexcept
rvsdg::Output & GetMemoryStateRegionArgument(const rvsdg::LambdaNode &lambdaNode) noexcept
void MatchTypeWithDefault(T &obj, const Fns &... fns)
Pattern match over subclass type of given object with default handler.
void MatchTypeOrFail(T &obj, const Fns &... fns)
Pattern match over subclass type of given object.
size_t nnodes(const jlm::rvsdg::Region *region) noexcept
static std::vector< jlm::rvsdg::Output * > outputs(const Node *node)
Helper struct for counting up MemoryNodes, among some set of entities that use them.
void CountEntity(const PointsToGraph &pointsToGraph, util::HashSet< PointsToGraph::NodeIndex > memoryNodes)
uint64_t MaxNonEscapedMemoryStateEntity
void CountEntity(uint64_t numAllocas, uint64_t numMallocs, uint64_t numDeltas, uint64_t numImports, uint64_t numLambdas, uint64_t numExternal, uint64_t numNonEscaped)
uint64_t MaxMemoryStateEntity
rvsdg::Output * output
Output of gamma.
static const char * NumRvsdgNodesBefore
static const char * Timer