diff options
Diffstat (limited to 'contrib/llvm/lib/IR/MDBuilder.cpp')
-rw-r--r-- | contrib/llvm/lib/IR/MDBuilder.cpp | 41 |
1 files changed, 31 insertions, 10 deletions
diff --git a/contrib/llvm/lib/IR/MDBuilder.cpp b/contrib/llvm/lib/IR/MDBuilder.cpp index c7fcf7a..b4c5ca7 100644 --- a/contrib/llvm/lib/IR/MDBuilder.cpp +++ b/contrib/llvm/lib/IR/MDBuilder.cpp @@ -53,24 +53,38 @@ MDNode *MDBuilder::createBranchWeights(ArrayRef<uint32_t> Weights) { return MDNode::get(Context, Vals); } +MDNode *MDBuilder::createFunctionEntryCount(uint64_t Count) { + SmallVector<Metadata *, 2> Vals(2); + Vals[0] = createString("function_entry_count"); + + Type *Int64Ty = Type::getInt64Ty(Context); + Vals[1] = createConstant(ConstantInt::get(Int64Ty, Count)); + + return MDNode::get(Context, Vals); +} + MDNode *MDBuilder::createRange(const APInt &Lo, const APInt &Hi) { assert(Lo.getBitWidth() == Hi.getBitWidth() && "Mismatched bitwidths!"); + + Type *Ty = IntegerType::get(Context, Lo.getBitWidth()); + return createRange(ConstantInt::get(Ty, Lo), ConstantInt::get(Ty, Hi)); +} + +MDNode *MDBuilder::createRange(Constant *Lo, Constant *Hi) { // If the range is everything then it is useless. if (Hi == Lo) return nullptr; // Return the range [Lo, Hi). - Type *Ty = IntegerType::get(Context, Lo.getBitWidth()); - Metadata *Range[2] = {createConstant(ConstantInt::get(Ty, Lo)), - createConstant(ConstantInt::get(Ty, Hi))}; + Metadata *Range[2] = {createConstant(Lo), createConstant(Hi)}; return MDNode::get(Context, Range); } MDNode *MDBuilder::createAnonymousAARoot(StringRef Name, MDNode *Extra) { // To ensure uniqueness the root node is self-referential. - MDNode *Dummy = MDNode::getTemporary(Context, None); + auto Dummy = MDNode::getTemporary(Context, None); - SmallVector<Metadata *, 3> Args(1, Dummy); + SmallVector<Metadata *, 3> Args(1, Dummy.get()); if (Extra) Args.push_back(Extra); if (!Name.empty()) @@ -82,7 +96,7 @@ MDNode *MDBuilder::createAnonymousAARoot(StringRef Name, MDNode *Extra) { // !1 = metadata !{metadata !0} <- root // Replace the dummy operand with the root node itself and delete the dummy. Root->replaceOperandWith(0, Root); - MDNode::deleteTemporary(Dummy); + // We now have // !1 = metadata !{metadata !1} <- self-referential root return Root; @@ -154,9 +168,16 @@ MDNode *MDBuilder::createTBAAScalarTypeNode(StringRef Name, MDNode *Parent, /// \brief Return metadata for a TBAA tag node with the given /// base type, access type and offset relative to the base type. MDNode *MDBuilder::createTBAAStructTagNode(MDNode *BaseType, MDNode *AccessType, - uint64_t Offset) { + uint64_t Offset, bool IsConstant) { Type *Int64 = Type::getInt64Ty(Context); - Metadata *Ops[3] = {BaseType, AccessType, - createConstant(ConstantInt::get(Int64, Offset))}; - return MDNode::get(Context, Ops); + if (IsConstant) { + Metadata *Ops[4] = {BaseType, AccessType, + createConstant(ConstantInt::get(Int64, Offset)), + createConstant(ConstantInt::get(Int64, 1))}; + return MDNode::get(Context, Ops); + } else { + Metadata *Ops[3] = {BaseType, AccessType, + createConstant(ConstantInt::get(Int64, Offset))}; + return MDNode::get(Context, Ops); + } } |