diff options
Diffstat (limited to 'llvm/lib/IR')
-rw-r--r-- | llvm/lib/IR/Function.cpp | 5 | ||||
-rw-r--r-- | llvm/lib/IR/MDBuilder.cpp | 8 | ||||
-rw-r--r-- | llvm/lib/IR/Verifier.cpp | 7 |
3 files changed, 14 insertions, 6 deletions
diff --git a/llvm/lib/IR/Function.cpp b/llvm/lib/IR/Function.cpp index 7063f6f40a3..b413d38abab 100644 --- a/llvm/lib/IR/Function.cpp +++ b/llvm/lib/IR/Function.cpp @@ -1320,10 +1320,11 @@ void Function::setValueSubclassDataBit(unsigned Bit, bool On) { setValueSubclassData(getSubclassDataFromValue() & ~(1 << Bit)); } -void Function::setEntryCount(uint64_t Count, +void Function::setEntryCount(uint64_t Count, bool Synthetic, const DenseSet<GlobalValue::GUID> *S) { MDBuilder MDB(getContext()); - setMetadata(LLVMContext::MD_prof, MDB.createFunctionEntryCount(Count, S)); + setMetadata(LLVMContext::MD_prof, + MDB.createFunctionEntryCount(Count, Synthetic, S)); } Optional<uint64_t> Function::getEntryCount() const { diff --git a/llvm/lib/IR/MDBuilder.cpp b/llvm/lib/IR/MDBuilder.cpp index 6d77a8f2d60..9d467fb9f6d 100644 --- a/llvm/lib/IR/MDBuilder.cpp +++ b/llvm/lib/IR/MDBuilder.cpp @@ -58,10 +58,14 @@ MDNode *MDBuilder::createUnpredictable() { } MDNode *MDBuilder::createFunctionEntryCount( - uint64_t Count, const DenseSet<GlobalValue::GUID> *Imports) { + uint64_t Count, bool Synthetic, + const DenseSet<GlobalValue::GUID> *Imports) { Type *Int64Ty = Type::getInt64Ty(Context); SmallVector<Metadata *, 8> Ops; - Ops.push_back(createString("function_entry_count")); + if (Synthetic) + Ops.push_back(createString("synthetic_function_entry_count")); + else + Ops.push_back(createString("function_entry_count")); Ops.push_back(createConstant(ConstantInt::get(Int64Ty, Count))); if (Imports) { SmallVector<GlobalValue::GUID, 2> OrderID(Imports->begin(), Imports->end()); diff --git a/llvm/lib/IR/Verifier.cpp b/llvm/lib/IR/Verifier.cpp index ab93b855776..89af3db34c0 100644 --- a/llvm/lib/IR/Verifier.cpp +++ b/llvm/lib/IR/Verifier.cpp @@ -1695,8 +1695,11 @@ void Verifier::verifyFunctionMetadata( "expected string with name of the !prof annotation", MD); MDString *MDS = cast<MDString>(MD->getOperand(0)); StringRef ProfName = MDS->getString(); - Assert(ProfName.equals("function_entry_count"), - "first operand should be 'function_entry_count'", MD); + Assert(ProfName.equals("function_entry_count") || + ProfName.equals("synthetic_function_entry_count"), + "first operand should be 'function_entry_count'" + " or 'synthetic_function_entry_count'", + MD); // Check second operand. Assert(MD->getOperand(1) != nullptr, "second operand should not be null", |