6 #ifndef JLM_LLVM_OPT_ALIAS_ANALYSES_POINTEROBJECTSET_HPP
7 #define JLM_LLVM_OPT_ALIAS_ANALYSES_POINTEROBJECTSET_HPP
21 #include <unordered_map>
168 std::unordered_map<const rvsdg::Output *, PointerObjectIndex>
RegisterMap_;
170 std::unordered_map<const rvsdg::SimpleNode *, PointerObjectIndex>
AllocaMap_;
172 std::unordered_map<const rvsdg::SimpleNode *, PointerObjectIndex>
MallocMap_;
174 std::unordered_map<const rvsdg::DeltaNode *, PointerObjectIndex>
GlobalMap_;
178 std::unordered_map<const LlvmGraphImport *, PointerObjectIndex>
ImportMap_;
197 template<
typename NewPo
inteeFunctor>
202 NewPointeeFunctor & onNewPointee);
262 const rvsdg::Output & rvsdgOutput,
306 [[nodiscard]] const rvsdg::LambdaNode &
556 : Superset_(superset),
575 Superset_ = superset;
847 std::variant<SupersetConstraint, StoreConstraint, LoadConstraint, FunctionCallConstraint>;
865 TwoPhaseLeastRecentlyFired,
890 [[nodiscard]]
static const char *
891 WorklistSolverPolicyToString(WorklistSolverPolicy policy);
910 size_t NumWorkItemsPopped{};
916 size_t NumWorkItemNewPointees{};
961 ConstraintSetFrozen_(false)
981 IsFrozen() const noexcept;
1017 GetConstraints() const noexcept;
1022 [[nodiscard]]
size_t
1023 NumBaseConstraints() const noexcept;
1031 [[nodiscard]] std::pair<
size_t,
size_t>
1032 NumFlagConstraints() const noexcept;
1038 util::graph::Graph &
1039 DrawSubsetGraph(util::graph::Writer & writer) const;
1067 PerformOfflineVariableSubstitution(
bool storeRefCycleUnificationRoot);
1078 NormalizeConstraints();
1101 bool enableOnlineCycleDetection,
1102 bool enableHybridCycleDetection,
1103 bool enableLazyCycleDetection,
1104 bool enableDifferencePropagation,
1105 bool enablePreferImplicitPropation);
1140 std::tuple<
size_t, std::vector<util::HashSet<
PointerObjectIndex>>, std::vector<
bool>>
1141 CreateOvsSubsetGraph();
1156 bool EnableOnlineCycleDetection,
1157 bool EnableHybridCycleDetection,
1158 bool EnableLazyCycleDetection,
1159 bool EnableDifferencePropagation,
1160 bool EnablePreferImplicitPointees>
1172 bool ConstraintSetFrozen_;
EscapeFlagConstraint()=delete
EscapedFunctionConstraint()=delete
void SetPointer(PointerObjectIndex pointer)
PointerObjectIndex Pointer_
FunctionCallConstraint(PointerObjectIndex pointer, const rvsdg::SimpleNode &callNode)
PointerObjectIndex GetPointer() const noexcept
const rvsdg::SimpleNode & CallNode_
const rvsdg::SimpleNode & GetCallNode() const noexcept
PointerObjectIndex Value_
PointerObjectIndex GetPointer() const noexcept
void SetValue(PointerObjectIndex value)
PointerObjectIndex GetValue() const noexcept
void SetPointer(PointerObjectIndex pointer)
PointerObjectIndex Pointer_
LoadConstraint(PointerObjectIndex value, PointerObjectIndex pointer)
PointerObjectConstraintSet(PointerObjectSet &set)
PointerObjectConstraintSet(PointerObjectConstraintSet &&other)=delete
PointerObjectConstraintSet & operator=(const PointerObjectConstraintSet &other)=delete
PointerObjectConstraintSet & operator=(PointerObjectConstraintSet &&other)=delete
PointerObjectConstraintSet(const PointerObjectConstraintSet &other)=delete
std::variant< SupersetConstraint, StoreConstraint, LoadConstraint, FunctionCallConstraint > ConstraintVariant
const util::BijectiveMap< const rvsdg::LambdaNode *, PointerObjectIndex > & GetFunctionMap() const noexcept
PointerObjectIndex CreateMallocMemoryObject(const rvsdg::SimpleNode &mallocNode, bool canPoint)
PointerObjectIndex UnifyPointerObjects(PointerObjectIndex object1, PointerObjectIndex object2)
PointerObjectIndex AddPointerObject(PointerObjectKind kind, bool canPoint)
size_t NumMemoryPointerObjects() const noexcept
bool IsPointingTo(PointerObjectIndex pointer, PointerObjectIndex pointee) const
PointerObjectIndex CreateDummyRegisterPointerObject()
PointerObjectKind GetPointerObjectKind(PointerObjectIndex index) const noexcept
size_t GetNumSetInsertionAttempts() const noexcept
std::vector< PointerObjectIndex > PointerObjectParents_
const std::unordered_map< const rvsdg::SimpleNode *, PointerObjectIndex > & GetMallocMap() const noexcept
bool IsPointerObjectRegister(PointerObjectIndex index) const noexcept
size_t GetNumExplicitPointeesRemoved() const noexcept
std::unordered_map< const rvsdg::Output *, PointerObjectIndex > RegisterMap_
PointerObjectIndex CreateGlobalMemoryObject(const rvsdg::DeltaNode &deltaNode, bool canPoint)
void MapRegisterToExistingPointerObject(const rvsdg::Output &rvsdgOutput, PointerObjectIndex pointerObject)
size_t NumRegisterPointerObjects() const noexcept
const util::HashSet< PointerObjectIndex > & GetPointsToSet(PointerObjectIndex index) const
bool HasPointeesEscaping(PointerObjectIndex index) const noexcept
bool PropagateNewPointees(PointerObjectIndex superset, PointerObjectIndex subset, NewPointeeFunctor &onNewPointee)
bool IsLoadedAsScalar(PointerObjectIndex index) const noexcept
void RemoveAllPointees(PointerObjectIndex index)
size_t NumSetInsertionAttempts_
size_t NumExplicitPointeesRemoved_
size_t NumMemoryPointerObjectsCanPoint() const noexcept
std::unordered_map< const rvsdg::SimpleNode *, PointerObjectIndex > AllocaMap_
PointerObjectIndex CreateRegisterPointerObject(const rvsdg::Output &rvsdgOutput)
bool CanPoint(PointerObjectIndex index) const noexcept
bool AddToPointsToSet(PointerObjectIndex pointer, PointerObjectIndex pointee)
PointerObjectIndex GetRegisterPointerObject(const rvsdg::Output &rvsdgOutput) const
std::vector< uint8_t > PointerObjectRank_
bool MarkAsLoadingAsScalar(PointerObjectIndex index)
const std::unordered_map< const rvsdg::SimpleNode *, PointerObjectIndex > & GetAllocaMap() const noexcept
std::unordered_map< const rvsdg::DeltaNode *, PointerObjectIndex > GlobalMap_
std::unique_ptr< PointerObjectSet > Clone() const
bool IsPointingToExternal(PointerObjectIndex index) const noexcept
std::unordered_map< const rvsdg::SimpleNode *, PointerObjectIndex > MallocMap_
bool HasIdenticalSolAs(const PointerObjectSet &other) const
bool IsStoredAsScalar(PointerObjectIndex index) const noexcept
bool HasEscaped(PointerObjectIndex index) const noexcept
bool MarkAsPointeesEscaping(PointerObjectIndex index)
const std::unordered_map< const LlvmGraphImport *, PointerObjectIndex > & GetImportMap() const noexcept
PointerObjectSet()=default
const std::unordered_map< const rvsdg::DeltaNode *, PointerObjectIndex > & GetGlobalMap() const noexcept
std::vector< util::HashSet< PointerObjectIndex > > PointsToSets_
PointerObjectIndex CreateAllocaMemoryObject(const rvsdg::SimpleNode &allocaNode, bool canPoint)
bool CanTrackPointeesImplicitly(PointerObjectIndex index) const noexcept
bool MarkAsStoringAsScalar(PointerObjectIndex index)
bool MarkAsPointingToExternal(PointerObjectIndex index)
PointerObjectIndex GetUnificationRoot(PointerObjectIndex index) const noexcept
bool IsUnificationRoot(PointerObjectIndex index) const noexcept
PointerObjectIndex CreateFunctionMemoryObject(const rvsdg::LambdaNode &lambdaNode)
std::vector< PointerObject > PointerObjects_
size_t NumPointerObjects() const noexcept
const rvsdg::LambdaNode & GetLambdaNodeFromFunctionMemoryObject(PointerObjectIndex index) const
const std::unordered_map< const rvsdg::Output *, PointerObjectIndex > & GetRegisterMap() const noexcept
PointerObjectIndex CreateImportMemoryObject(const LlvmGraphImport &importNode, bool canPoint)
bool MarkAsEscaped(PointerObjectIndex index)
util::BijectiveMap< const rvsdg::LambdaNode *, PointerObjectIndex > FunctionMap_
PointerObjectIndex GetFunctionMemoryObject(const rvsdg::LambdaNode &lambdaNode) const
bool MakePointsToSetSuperset(PointerObjectIndex superset, PointerObjectIndex subset)
std::optional< PointerObjectIndex > TryGetRegisterPointerObject(const rvsdg::Output &rvsdgOutput) const
std::unordered_map< const LlvmGraphImport *, PointerObjectIndex > ImportMap_
size_t NumPointerObjectsOfKind(PointerObjectKind kind) const noexcept
PointerObjectIndex GetPointer() const noexcept
PointerObjectIndex GetValue() const noexcept
StoreConstraint(PointerObjectIndex pointer, PointerObjectIndex value)
PointerObjectIndex Pointer_
PointerObjectIndex Value_
void SetValue(PointerObjectIndex value)
void SetPointer(PointerObjectIndex pointer)
PointerObjectIndex GetSubset() const noexcept
PointerObjectIndex GetSuperset() const noexcept
void SetSubset(PointerObjectIndex subset)
PointerObjectIndex Superset_
SupersetConstraint(PointerObjectIndex superset, PointerObjectIndex subset)
void SetSuperset(PointerObjectIndex superset)
PointerObjectIndex Subset_
const SimpleOperation & GetOperation() const noexcept override
uint32_t PointerObjectIndex
static constexpr int BitWidthOfEnum(T endValue)
std::optional< size_t > NumLazyCyclesDetected
WorklistSolverPolicy Policy
std::optional< size_t > NumLazyCycleUnifications
std::optional< size_t > NumOnlineCycleUnifications
WorklistStatistics(WorklistSolverPolicy policy)
std::optional< size_t > NumTopologicalWorklistSweeps
std::optional< size_t > NumOnlineCyclesDetected
std::optional< size_t > NumLazyCyclesDetectionAttempts
std::optional< size_t > NumPipExplicitPointeesRemoved
std::optional< size_t > NumHybridCycleUnifications
bool CanPoint() const noexcept
const uint8_t CanPointFlag
bool IsRegister() const noexcept
PointerObject(PointerObjectKind kind, bool canPoint)
bool CanTrackPointeesImplicitly() const noexcept