FName, Num, Weight);
}
+ sampleprof_error addSampleRecord(LineLocation Location,
+ const SampleRecord &SampleRecord, uint64_t Weight = 1) {
+ return BodySamples[Location].merge(SampleRecord, Weight);
+ }
+
// Remove a call target and decrease the body sample correspondingly. Return
// the number of body samples actually decreased.
uint64_t removeCalledTargetAndBodySample(uint32_t LineOffset,
// To retain the context, checksum, attributes of the original profile, make
// a copy of it if no profile is found.
SampleContext &Context = FS.getContext();
- auto Ret = OutputProfiles.emplace(Context, FS);
+ auto Ret = OutputProfiles.try_emplace(Context, FS);
FunctionSamples &Profile = Ret.first->second;
if (Ret.second) {
// When it's the copy of the old profile, just clear all the inlinees'
// We recompute TotalSamples later, so here set to zero.
Profile.setTotalSamples(0);
} else {
- for (const auto &Line : FS.getBodySamples()) {
- Profile.addBodySamples(Line.first.LineOffset, Line.first.Discriminator,
- Line.second.getSamples());
+ for (const auto &[LineLocation, SampleRecord] : FS.getBodySamples()) {
+ Profile.addSampleRecord(LineLocation, SampleRecord);
}
}
; CHECK:baz:169:10
; CHECK-NEXT: 1: 10
; CHECK-NEXT: 3: 20
+; CHECK-NEXT: 4: 36 corge:15 quux:13 qux:8
+; CHECK-NEXT: 4.1: 12 thud:5 grault:4 quux:3
; CHECK-NEXT: 5: 20 foo:20
; CHECK-NEXT: 6: 2 bar:2
; CHECK-NEXT: 10: 1
; CHECK-NEXT: 4: 1
; CHECK-NEXT: !CFGChecksum: 3
; CHECK-NEXT: !Attributes: 3
-; CHECK-NEXT:main:91:1
+; CHECK-NEXT:main:104:1
; CHECK-NEXT: 4: 1
; CHECK-NEXT: 4.2: 1
; CHECK-NEXT: 7: 1
; CHECK-NEXT: 9: 3 bar:2 foo:1
-; CHECK-NEXT: 10: 3 baz:2 foo:1
+; CHECK-NEXT: 10: 16 baz:15 foo:1
; CHECK-NEXT: !CFGChecksum: 2
; CHECK-NEXT: !Attributes: 2
; CHECK-NEXT:bar:15:14