Skip to content

[ctxprof] Fix warnings post PR #130655 #131198

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

Merged
merged 2 commits into from
Mar 13, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions compiler-rt/lib/ctx_profile/CtxInstrProfiling.h
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,10 @@ struct ContextRoot {
// The current design trades off a bit of overhead at the first time a function
// is encountered *for flat profiling* for avoiding size penalties.
struct FunctionData {
// Constructor for test only - since this is expected to be
// initialized by the compiler.
FunctionData() { Mutex.Init(); }

FunctionData *Next = nullptr;
ContextNode *volatile FlatCtx = nullptr;
::__sanitizer::StaticSpinMutex Mutex;
Expand Down
15 changes: 8 additions & 7 deletions compiler-rt/lib/ctx_profile/tests/CtxInstrProfilingTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ TEST_F(ContextTest, Callsite) {
__llvm_ctx_profile_expected_callee[0] = &FakeCalleeAddress;
__llvm_ctx_profile_callsite[0] = &Ctx->subContexts()[2];
// This is what the callee does
FunctionData FData = {0};
FunctionData FData;
auto *Subctx =
__llvm_ctx_profile_get_context(&FData, &FakeCalleeAddress, 2, 3, 1);
// This should not have required creating a flat context.
Expand All @@ -93,7 +93,7 @@ TEST_F(ContextTest, ScratchNoCollectionProfilingNotStarted) {
int FakeCalleeAddress = 0;
// this would be the very first function executing this. the TLS is empty,
// too.
FunctionData FData = {0};
FunctionData FData;
auto *Ctx =
__llvm_ctx_profile_get_context(&FData, &FakeCalleeAddress, 2, 3, 1);
// We never entered a context (_start_context was never called) - so the
Expand All @@ -111,7 +111,7 @@ TEST_F(ContextTest, ScratchNoCollectionProfilingStarted) {
__llvm_ctx_profile_start_collection();
// this would be the very first function executing this. the TLS is empty,
// too.
FunctionData FData = {0};
FunctionData FData;
auto *Ctx =
__llvm_ctx_profile_get_context(&FData, &FakeCalleeAddress, 2, 3, 1);
// We never entered a context (_start_context was never called) - so the
Expand All @@ -130,7 +130,7 @@ TEST_F(ContextTest, ScratchDuringCollection) {
int OtherFakeCalleeAddress = 0;
__llvm_ctx_profile_expected_callee[0] = &FakeCalleeAddress;
__llvm_ctx_profile_callsite[0] = &Ctx->subContexts()[2];
FunctionData FData[3] = {0};
FunctionData FData[3];
auto *Subctx = __llvm_ctx_profile_get_context(
&FData[0], &OtherFakeCalleeAddress, 2, 3, 1);
// We expected a different callee - so return scratch. It mimics what happens
Expand Down Expand Up @@ -175,7 +175,7 @@ TEST_F(ContextTest, NeedMoreMemory) {
const auto *CurrentMem = Root.CurrentMem;
__llvm_ctx_profile_expected_callee[0] = &FakeCalleeAddress;
__llvm_ctx_profile_callsite[0] = &Ctx->subContexts()[2];
FunctionData FData = {0};
FunctionData FData;
// Allocate a massive subcontext to force new arena allocation
auto *Subctx =
__llvm_ctx_profile_get_context(&FData, &FakeCalleeAddress, 3, 1 << 20, 1);
Expand Down Expand Up @@ -216,7 +216,7 @@ TEST_F(ContextTest, Dump) {
int FakeCalleeAddress = 0;
__llvm_ctx_profile_expected_callee[0] = &FakeCalleeAddress;
__llvm_ctx_profile_callsite[0] = &Ctx->subContexts()[2];
FunctionData FData = {0};
FunctionData FData;
auto *Subctx =
__llvm_ctx_profile_get_context(&FData, &FakeCalleeAddress, 2, 3, 1);
(void)Subctx;
Expand Down Expand Up @@ -267,7 +267,7 @@ TEST_F(ContextTest, Dump) {
void writeFlat(GUID Guid, const uint64_t *Buffer,
size_t BufferSize) override {
++FlatsWritten;
EXPECT_EQ(BufferSize, 3);
EXPECT_EQ(BufferSize, 3U);
EXPECT_EQ(Buffer[0], 15U);
EXPECT_EQ(Buffer[1], 0U);
EXPECT_EQ(Buffer[2], 0U);
Expand All @@ -284,6 +284,7 @@ TEST_F(ContextTest, Dump) {
__llvm_ctx_profile_start_collection();
auto *Flat =
__llvm_ctx_profile_get_context(&FData, &FakeCalleeAddress, 2, 3, 1);
(void)Flat;
EXPECT_NE(FData.FlatCtx, nullptr);
FData.FlatCtx->counters()[0] = 15U;
TestProfileWriter W2(&Root, 0);
Expand Down
Loading