Skip to content

Commit 8aa835c

Browse files
authored
[ctxprof] Fix warnings post PR llvm#130655 (llvm#131198)
1 parent d642eec commit 8aa835c

File tree

2 files changed

+12
-7
lines changed

2 files changed

+12
-7
lines changed

compiler-rt/lib/ctx_profile/CtxInstrProfiling.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,10 @@ struct ContextRoot {
130130
// The current design trades off a bit of overhead at the first time a function
131131
// is encountered *for flat profiling* for avoiding size penalties.
132132
struct FunctionData {
133+
// Constructor for test only - since this is expected to be
134+
// initialized by the compiler.
135+
FunctionData() { Mutex.Init(); }
136+
133137
FunctionData *Next = nullptr;
134138
ContextNode *volatile FlatCtx = nullptr;
135139
::__sanitizer::StaticSpinMutex Mutex;

compiler-rt/lib/ctx_profile/tests/CtxInstrProfilingTest.cpp

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ TEST_F(ContextTest, Callsite) {
6969
__llvm_ctx_profile_expected_callee[0] = &FakeCalleeAddress;
7070
__llvm_ctx_profile_callsite[0] = &Ctx->subContexts()[2];
7171
// This is what the callee does
72-
FunctionData FData = {0};
72+
FunctionData FData;
7373
auto *Subctx =
7474
__llvm_ctx_profile_get_context(&FData, &FakeCalleeAddress, 2, 3, 1);
7575
// This should not have required creating a flat context.
@@ -93,7 +93,7 @@ TEST_F(ContextTest, ScratchNoCollectionProfilingNotStarted) {
9393
int FakeCalleeAddress = 0;
9494
// this would be the very first function executing this. the TLS is empty,
9595
// too.
96-
FunctionData FData = {0};
96+
FunctionData FData;
9797
auto *Ctx =
9898
__llvm_ctx_profile_get_context(&FData, &FakeCalleeAddress, 2, 3, 1);
9999
// We never entered a context (_start_context was never called) - so the
@@ -111,7 +111,7 @@ TEST_F(ContextTest, ScratchNoCollectionProfilingStarted) {
111111
__llvm_ctx_profile_start_collection();
112112
// this would be the very first function executing this. the TLS is empty,
113113
// too.
114-
FunctionData FData = {0};
114+
FunctionData FData;
115115
auto *Ctx =
116116
__llvm_ctx_profile_get_context(&FData, &FakeCalleeAddress, 2, 3, 1);
117117
// We never entered a context (_start_context was never called) - so the
@@ -130,7 +130,7 @@ TEST_F(ContextTest, ScratchDuringCollection) {
130130
int OtherFakeCalleeAddress = 0;
131131
__llvm_ctx_profile_expected_callee[0] = &FakeCalleeAddress;
132132
__llvm_ctx_profile_callsite[0] = &Ctx->subContexts()[2];
133-
FunctionData FData[3] = {0};
133+
FunctionData FData[3];
134134
auto *Subctx = __llvm_ctx_profile_get_context(
135135
&FData[0], &OtherFakeCalleeAddress, 2, 3, 1);
136136
// We expected a different callee - so return scratch. It mimics what happens
@@ -175,7 +175,7 @@ TEST_F(ContextTest, NeedMoreMemory) {
175175
const auto *CurrentMem = Root.CurrentMem;
176176
__llvm_ctx_profile_expected_callee[0] = &FakeCalleeAddress;
177177
__llvm_ctx_profile_callsite[0] = &Ctx->subContexts()[2];
178-
FunctionData FData = {0};
178+
FunctionData FData;
179179
// Allocate a massive subcontext to force new arena allocation
180180
auto *Subctx =
181181
__llvm_ctx_profile_get_context(&FData, &FakeCalleeAddress, 3, 1 << 20, 1);
@@ -216,7 +216,7 @@ TEST_F(ContextTest, Dump) {
216216
int FakeCalleeAddress = 0;
217217
__llvm_ctx_profile_expected_callee[0] = &FakeCalleeAddress;
218218
__llvm_ctx_profile_callsite[0] = &Ctx->subContexts()[2];
219-
FunctionData FData = {0};
219+
FunctionData FData;
220220
auto *Subctx =
221221
__llvm_ctx_profile_get_context(&FData, &FakeCalleeAddress, 2, 3, 1);
222222
(void)Subctx;
@@ -267,7 +267,7 @@ TEST_F(ContextTest, Dump) {
267267
void writeFlat(GUID Guid, const uint64_t *Buffer,
268268
size_t BufferSize) override {
269269
++FlatsWritten;
270-
EXPECT_EQ(BufferSize, 3);
270+
EXPECT_EQ(BufferSize, 3U);
271271
EXPECT_EQ(Buffer[0], 15U);
272272
EXPECT_EQ(Buffer[1], 0U);
273273
EXPECT_EQ(Buffer[2], 0U);
@@ -284,6 +284,7 @@ TEST_F(ContextTest, Dump) {
284284
__llvm_ctx_profile_start_collection();
285285
auto *Flat =
286286
__llvm_ctx_profile_get_context(&FData, &FakeCalleeAddress, 2, 3, 1);
287+
(void)Flat;
287288
EXPECT_NE(FData.FlatCtx, nullptr);
288289
FData.FlatCtx->counters()[0] = 15U;
289290
TestProfileWriter W2(&Root, 0);

0 commit comments

Comments
 (0)