-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[memprof] Use InstrProfWriter::addMemProfData in a unit test (NFC) #116921
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[memprof] Use InstrProfWriter::addMemProfData in a unit test (NFC) #116921
Conversation
This patch uses InstrProfWriter::addMemProfData to add the complete MemProf profile to the writer context.
@llvm/pr-subscribers-llvm-transforms Author: Kazu Hirata (kazutakahirata) ChangesThis patch uses InstrProfWriter::addMemProfData to add the complete Full diff: https://github.com/llvm/llvm-project/pull/116921.diff 1 Files Affected:
diff --git a/llvm/unittests/Transforms/Instrumentation/MemProfUseTest.cpp b/llvm/unittests/Transforms/Instrumentation/MemProfUseTest.cpp
index ec81d2e5609163..2f703fd74b5677 100644
--- a/llvm/unittests/Transforms/Instrumentation/MemProfUseTest.cpp
+++ b/llvm/unittests/Transforms/Instrumentation/MemProfUseTest.cpp
@@ -434,31 +434,30 @@ attributes #1 = { "no-trapping-math"="true" "stack-protector-buffer-size"="8" "t
ASSERT_THAT_ERROR(Writer.mergeProfileKind(InstrProfKind::MemProf),
Succeeded());
- const std::pair<memprof::FrameId, memprof::Frame> Frames[] = {
- // The call sites within foo.
- {0, {GUIDFoo, 1, 8, false}},
- {1, {GUIDFoo, 2, 3, false}},
- {2, {GUIDFoo, 3, 3, false}},
- // Line/column numbers below don't matter.
- {3, {GUIDBar, 9, 9, false}},
- {4, {GUIDZzz, 9, 9, false}},
- {5, {GUIDBaz, 9, 9, false}}};
- for (const auto &[FrameId, Frame] : Frames)
- Writer.addMemProfFrame(FrameId, Frame, Err);
-
- const std::pair<memprof::CallStackId, SmallVector<memprof::FrameId>>
- CallStacks[] = {
- {0x111, {3, 0}}, // bar called by foo
- {0x222, {4, 1}}, // zzz called by foo
- {0x333, {5, 2}} // baz called by foo
- };
- for (const auto &[CSId, CallStack] : CallStacks)
- Writer.addMemProfCallStack(CSId, CallStack, Err);
-
const IndexedMemProfRecord IndexedMR = makeRecordV2(
/*AllocFrames=*/{0x111, 0x222, 0x333},
/*CallSiteFrames=*/{}, MIB, memprof::getHotColdSchema());
- Writer.addMemProfRecord(/*Id=*/0x9999, IndexedMR);
+
+ memprof::IndexedMemProfData MemProfData;
+ // The call sites within foo.
+ MemProfData.Frames.try_emplace(0, GUIDFoo, 1, 8, false);
+ MemProfData.Frames.try_emplace(1, GUIDFoo, 2, 3, false);
+ MemProfData.Frames.try_emplace(2, GUIDFoo, 3, 3, false);
+ // Line/column numbers below don't matter.
+ MemProfData.Frames.try_emplace(3, GUIDBar, 9, 9, false);
+ MemProfData.Frames.try_emplace(4, GUIDZzz, 9, 9, false);
+ MemProfData.Frames.try_emplace(5, GUIDBaz, 9, 9, false);
+ MemProfData.CallStacks.try_emplace(
+ 0x111,
+ std::initializer_list<memprof::FrameId>{3, 0}); // bar called by foo
+ MemProfData.CallStacks.try_emplace(
+ 0x222,
+ std::initializer_list<memprof::FrameId>{4, 1}); // zzz called by foo
+ MemProfData.CallStacks.try_emplace(
+ 0x333,
+ std::initializer_list<memprof::FrameId>{5, 2}); // baz called by foo
+ MemProfData.Records.try_emplace(0x9999, IndexedMR);
+ Writer.addMemProfData(MemProfData, Err);
auto Profile = Writer.writeBuffer();
|
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/92/builds/10048 Here is the relevant piece of the build log for the reference
|
This patch uses InstrProfWriter::addMemProfData to add the complete
MemProf profile to the writer context.