@@ -46,6 +46,12 @@ struct TBAATree {
4646
4747 mlir::LLVM::TBAATypeDescriptorAttr getRoot () const { return parent; }
4848
49+ // / For the given name, get or create a subtree in the current
50+ // / subtree. For example, this is used for creating subtrees
51+ // / inside the "global data" subtree for the COMMON block variables
52+ // / belonging to the same COMMON block.
53+ SubtreeState &getOrCreateNamedSubtree (mlir::StringAttr name);
54+
4955 private:
5056 SubtreeState (mlir::MLIRContext *ctx, std::string name,
5157 mlir::LLVM::TBAANodeAttr grandParent)
@@ -57,6 +63,9 @@ struct TBAATree {
5763 const std::string parentId;
5864 mlir::MLIRContext *const context;
5965 mlir::LLVM::TBAATypeDescriptorAttr parent;
66+ // A map of named sub-trees, e.g. sub-trees of the COMMON blocks
67+ // placed under the "global data" root.
68+ llvm::DenseMap<mlir::StringAttr, SubtreeState> namedSubtrees;
6069 };
6170
6271 // / A subtree for POINTER/TARGET variables data.
@@ -131,22 +140,29 @@ class TBAAForrest {
131140 // responsibility to provide unique name for the scope.
132141 // If the scope string is empty, returns the TBAA tree for the
133142 // "root" scope of the given function.
134- inline const TBAATree &getFuncTreeWithScope (mlir::func::FuncOp func,
135- llvm::StringRef scope) {
143+ inline TBAATree &getMutableFuncTreeWithScope (mlir::func::FuncOp func,
144+ llvm::StringRef scope) {
136145 mlir::StringAttr name = func.getSymNameAttr ();
137146 if (!scope.empty ())
138147 name = mlir::StringAttr::get (name.getContext (),
139148 llvm::Twine (name) + " - " + scope);
140149 return getFuncTree (name);
141150 }
142151
152+ inline const TBAATree &getFuncTreeWithScope (mlir::func::FuncOp func,
153+ llvm::StringRef scope) {
154+ return getMutableFuncTreeWithScope (func, scope);
155+ }
156+
143157private:
144- const TBAATree &getFuncTree (mlir::StringAttr symName) {
158+ TBAATree &getFuncTree (mlir::StringAttr symName) {
145159 if (!separatePerFunction)
146160 symName = mlir::StringAttr::get (symName.getContext (), " " );
147161 if (!trees.contains (symName))
148162 trees.insert ({symName, TBAATree::buildTree (symName)});
149- return trees.at (symName);
163+ auto it = trees.find (symName);
164+ assert (it != trees.end ());
165+ return it->second ;
150166 }
151167
152168 // Should each function use a different tree?
0 commit comments