@@ -349,31 +349,25 @@ TEST_F(InstrProfTest, test_merge_traces_sampled) {
349349 IsSubsetOf ({FooTrace, BarTrace, GooTrace, BarTrace, GooTrace, FooTrace}));
350350}
351351
352+ using ::llvm::memprof::IndexedMemProfData;
352353using ::llvm::memprof::IndexedMemProfRecord;
353354using ::llvm::memprof::MemInfoBlock;
354- using FrameIdMapTy =
355- llvm::MapVector<::llvm::memprof::FrameId, ::llvm::memprof::Frame>;
356- using CallStackIdMapTy =
357- llvm::MapVector<::llvm::memprof::CallStackId,
358- ::llvm::SmallVector<::llvm::memprof::FrameId>>;
359-
360- static FrameIdMapTy getFrameMapping () {
361- FrameIdMapTy Mapping;
362- Mapping.insert ({0 , {0x123 , 1 , 2 , false }});
363- Mapping.insert ({1 , {0x345 , 3 , 4 , true }});
364- Mapping.insert ({2 , {0x125 , 5 , 6 , false }});
365- Mapping.insert ({3 , {0x567 , 7 , 8 , true }});
366- Mapping.insert ({4 , {0x124 , 5 , 6 , false }});
367- Mapping.insert ({5 , {0x789 , 8 , 9 , true }});
368- return Mapping;
369- }
370355
371- static CallStackIdMapTy getCallStackMapping () {
372- CallStackIdMapTy Mapping;
373- Mapping.insert ({0x111 , {0 , 1 }});
374- Mapping.insert ({0x222 , {2 , 3 }});
375- Mapping.insert ({0x333 , {4 , 5 }});
376- return Mapping;
356+ IndexedMemProfData getMemProfDataForTest () {
357+ IndexedMemProfData MemProfData;
358+
359+ MemProfData.Frames .insert ({0 , {0x123 , 1 , 2 , false }});
360+ MemProfData.Frames .insert ({1 , {0x345 , 3 , 4 , true }});
361+ MemProfData.Frames .insert ({2 , {0x125 , 5 , 6 , false }});
362+ MemProfData.Frames .insert ({3 , {0x567 , 7 , 8 , true }});
363+ MemProfData.Frames .insert ({4 , {0x124 , 5 , 6 , false }});
364+ MemProfData.Frames .insert ({5 , {0x789 , 8 , 9 , true }});
365+
366+ MemProfData.CallStacks .insert ({0x111 , {0 , 1 }});
367+ MemProfData.CallStacks .insert ({0x222 , {2 , 3 }});
368+ MemProfData.CallStacks .insert ({0x333 , {4 , 5 }});
369+
370+ return MemProfData;
377371}
378372
379373// Populate all of the fields of MIB.
@@ -452,9 +446,7 @@ TEST_F(InstrProfTest, test_memprof_v2_full_schema) {
452446 const IndexedMemProfRecord IndexedMR = makeRecordV2 (
453447 /* AllocFrames=*/ {0x111 , 0x222 },
454448 /* CallSiteFrames=*/ {0x333 }, MIB, memprof::getFullSchema ());
455- memprof::IndexedMemProfData MemProfData;
456- MemProfData.Frames = getFrameMapping ();
457- MemProfData.CallStacks = getCallStackMapping ();
449+ IndexedMemProfData MemProfData = getMemProfDataForTest ();
458450 MemProfData.Records .try_emplace (0x9999 , IndexedMR);
459451 Writer.addMemProfData (MemProfData, Err);
460452
@@ -491,9 +483,7 @@ TEST_F(InstrProfTest, test_memprof_v2_partial_schema) {
491483 const IndexedMemProfRecord IndexedMR = makeRecordV2 (
492484 /* AllocFrames=*/ {0x111 , 0x222 },
493485 /* CallSiteFrames=*/ {0x333 }, MIB, memprof::getHotColdSchema ());
494- memprof::IndexedMemProfData MemProfData;
495- MemProfData.Frames = getFrameMapping ();
496- MemProfData.CallStacks = getCallStackMapping ();
486+ IndexedMemProfData MemProfData = getMemProfDataForTest ();
497487 MemProfData.Records .try_emplace (0x9999 , IndexedMR);
498488 Writer.addMemProfData (MemProfData, Err);
499489
@@ -602,9 +592,7 @@ TEST_F(InstrProfTest, test_memprof_merge) {
602592 /* AllocFrames=*/ {0x111 , 0x222 },
603593 /* CallSiteFrames=*/ {}, makePartialMIB (), memprof::getHotColdSchema ());
604594
605- memprof::IndexedMemProfData MemProfData;
606- MemProfData.Frames = getFrameMapping ();
607- MemProfData.CallStacks = getCallStackMapping ();
595+ IndexedMemProfData MemProfData = getMemProfDataForTest ();
608596 MemProfData.Records .try_emplace (0x9999 , IndexedMR);
609597 Writer2.addMemProfData (MemProfData, Err);
610598
0 commit comments