llvm.org GIT mirror llvm / 082bb7c
Add MDBuilder utilities for path-aware TBAA. Add utilities to create struct nodes in TBAA type DAG and to create path-aware tags. The format of struct nodes in TBAA type DAG: a unique name, a list of fields with field offsets and field types. The format of path-aware tags: a base type in TBAA type DAG, an access type and an offset relative to the base type. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@178564 91177308-0d34-0410-b5e6-96231b3b80d8 Manman Ren 7 years ago
1 changed file(s) with 23 addition(s) and 0 deletion(s). Raw diff Collapse all Expand all
155155 return MDNode::get(Context, Vals);
156156 }
157157
158 /// \brief Return metadata for a TBAA struct node in the type DAG
159 /// with the given name, parents in the TBAA DAG.
160 MDNode *createTBAAStructTypeNode(StringRef Name,
161 ArrayRef > Fields) {
162 SmallVector Ops(Fields.size() * 2 + 1);
163 Type *Int64 = IntegerType::get(Context, 64);
164 Ops[0] = createString(Name);
165 for (unsigned i = 0, e = Fields.size(); i != e; ++i) {
166 Ops[i * 2 + 1] = ConstantInt::get(Int64, Fields[i].first);
167 Ops[i * 2 + 2] = Fields[i].second;
168 }
169 return MDNode::get(Context, Ops);
170 }
171
172 /// \brief Return metadata for a TBAA tag node with the given
173 /// base type, access type and offset relative to the base type.
174 MDNode *createTBAAStructTagNode(MDNode *BaseType, MDNode *AccessType,
175 uint64_t Offset) {
176 Type *Int64 = IntegerType::get(Context, 64);
177 Value *Ops[3] = { BaseType, AccessType, ConstantInt::get(Int64, Offset) };
178 return MDNode::get(Context, Ops);
179 }
180
158181 };
159182
160183 } // end namespace llvm