summaryrefslogtreecommitdiffstats
path: root/llvm
diff options
context:
space:
mode:
authorRong Xu <xur@google.com>2016-03-30 16:56:31 +0000
committerRong Xu <xur@google.com>2016-03-30 16:56:31 +0000
commit311ada11f8c738dfcd27d219f7e4c2ff52ab6c08 (patch)
tree7c69f188e194831207186e7595e322da933fd896 /llvm
parent38dc83417b860e510bc376dbad4c4194df2e883c (diff)
downloadbcm5719-llvm-311ada11f8c738dfcd27d219f7e4c2ff52ab6c08.tar.gz
bcm5719-llvm-311ada11f8c738dfcd27d219f7e4c2ff52ab6c08.zip
[PGO] Use ArrayRef in annotateValueSite()
Using ArrayRef in annotateValueSite's parameter instead of using an array and it's size. Differential Revision: http://reviews.llvm.org/D18568 llvm-svn: 264879
Diffstat (limited to 'llvm')
-rw-r--r--llvm/include/llvm/ProfileData/InstrProf.h5
-rw-r--r--llvm/lib/ProfileData/InstrProf.cpp11
-rw-r--r--llvm/unittests/ProfileData/InstrProfTest.cpp3
3 files changed, 10 insertions, 9 deletions
diff --git a/llvm/include/llvm/ProfileData/InstrProf.h b/llvm/include/llvm/ProfileData/InstrProf.h
index 31fcffe2ef7..1566ffd1272 100644
--- a/llvm/include/llvm/ProfileData/InstrProf.h
+++ b/llvm/include/llvm/ProfileData/InstrProf.h
@@ -229,10 +229,9 @@ void annotateValueSite(Module &M, Instruction &Inst,
const InstrProfRecord &InstrProfR,
InstrProfValueKind ValueKind, uint32_t SiteIndx,
uint32_t MaxMDCount = 3);
-/// Same as the above interface but using the ValueData array directly, as
-/// well as \p Sum.
+/// Same as the above interface but using an ArrayRef, as well as \p Sum.
void annotateValueSite(Module &M, Instruction &Inst,
- const InstrProfValueData VD[], uint32_t NV,
+ ArrayRef<InstrProfValueData> VDs,
uint64_t Sum, InstrProfValueKind ValueKind,
uint32_t MaxMDCount);
diff --git a/llvm/lib/ProfileData/InstrProf.cpp b/llvm/lib/ProfileData/InstrProf.cpp
index 1be3df4699c..8514b44777e 100644
--- a/llvm/lib/ProfileData/InstrProf.cpp
+++ b/llvm/lib/ProfileData/InstrProf.cpp
@@ -606,11 +606,12 @@ void annotateValueSite(Module &M, Instruction &Inst,
std::unique_ptr<InstrProfValueData[]> VD =
InstrProfR.getValueForSite(ValueKind, SiteIdx, &Sum);
- annotateValueSite(M, Inst, VD.get(), NV, Sum, ValueKind, MaxMDCount);
+ ArrayRef<InstrProfValueData> VDs(VD.get(), NV);
+ annotateValueSite(M, Inst, VDs, Sum, ValueKind, MaxMDCount);
}
void annotateValueSite(Module &M, Instruction &Inst,
- const InstrProfValueData VD[], uint32_t NV,
+ ArrayRef<InstrProfValueData> VDs,
uint64_t Sum, InstrProfValueKind ValueKind,
uint32_t MaxMDCount) {
LLVMContext &Ctx = M.getContext();
@@ -627,11 +628,11 @@ void annotateValueSite(Module &M, Instruction &Inst,
// Value Profile Data
uint32_t MDCount = MaxMDCount;
- for (uint32_t I = 0; I < NV; ++I) {
+ for (auto &VD : VDs) {
Vals.push_back(MDHelper.createConstant(
- ConstantInt::get(Type::getInt64Ty(Ctx), VD[I].Value)));
+ ConstantInt::get(Type::getInt64Ty(Ctx), VD.Value)));
Vals.push_back(MDHelper.createConstant(
- ConstantInt::get(Type::getInt64Ty(Ctx), VD[I].Count)));
+ ConstantInt::get(Type::getInt64Ty(Ctx), VD.Count)));
if (--MDCount == 0)
break;
}
diff --git a/llvm/unittests/ProfileData/InstrProfTest.cpp b/llvm/unittests/ProfileData/InstrProfTest.cpp
index 7dd072c849b..3b514859732 100644
--- a/llvm/unittests/ProfileData/InstrProfTest.cpp
+++ b/llvm/unittests/ProfileData/InstrProfTest.cpp
@@ -330,7 +330,8 @@ TEST_P(MaybeSparseInstrProfTest, annotate_vp_data) {
// Annotate with 4 records.
InstrProfValueData VD0Sorted[] = {{1000, 6}, {2000, 5}, {3000, 4}, {4000, 3},
{5000, 2}, {6000, 1}};
- annotateValueSite(*M, *Inst, &VD0Sorted[2], 4, 10, IPVK_IndirectCallTarget, 5);
+ annotateValueSite(*M, *Inst, makeArrayRef(VD0Sorted).slice(2), 10,
+ IPVK_IndirectCallTarget, 5);
Res = getValueProfDataFromInst(*Inst, IPVK_IndirectCallTarget, 5,
ValueData, N, T);
ASSERT_TRUE(Res);
OpenPOWER on IntegriCloud