[llvm] [SandboxVectorizer][NFCI] Fix use of possibly-uninitialized scalar. (PR #122201)
Tyler Lanphear via llvm-commits
llvm-commits at lists.llvm.org
Wed Jan 8 17:17:40 PST 2025
https://github.com/tylanphear created https://github.com/llvm/llvm-project/pull/122201
The `EraseCallbackID` field is not always initialized in the ctor for SeedCollector; if not, it will be used uninitialized by its dtor. This could potentially lead to the erasure of a random callback, leading to a bug.
Fixed by initializing to a purposefully invalid ID (`std::numeric_limits<ContextID>::max()`)
>From 807217e0e987ca370b8892a3d9a03fe7e2ae184b Mon Sep 17 00:00:00 2001
From: Tyler Lanphear <tyler.lanphear at intel.com>
Date: Wed, 8 Jan 2025 17:14:09 -0800
Subject: [PATCH] [SandboxVectorizer][NFCI] Fix use of possibly-uninitialized
scalar.
The `EraseCallbackID` field is not always initialized in the ctor for
SeedCollector, if not, it will be used uninitialized by its dtor. This
could potentially lead to the erasure of a random callback, leading to a
bug.
Fixed by initializing to a purposefully invalid ID
(`std::numeric_limits<ContextID>::max()`)
---
.../Transforms/Vectorize/SandboxVectorizer/SeedCollector.h | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/llvm/include/llvm/Transforms/Vectorize/SandboxVectorizer/SeedCollector.h b/llvm/include/llvm/Transforms/Vectorize/SandboxVectorizer/SeedCollector.h
index 6e16a84d832e5e..cc4ebb5c508414 100644
--- a/llvm/include/llvm/Transforms/Vectorize/SandboxVectorizer/SeedCollector.h
+++ b/llvm/include/llvm/Transforms/Vectorize/SandboxVectorizer/SeedCollector.h
@@ -292,7 +292,9 @@ class SeedCollector {
SeedContainer StoreSeeds;
SeedContainer LoadSeeds;
Context &Ctx;
- Context::CallbackID EraseCallbackID;
+ Context::CallbackID EraseCallbackID =
+ std::numeric_limits<Context::CallbackID>::max();
+
/// \Returns the number of SeedBundle groups for all seed types.
/// This is to be used for limiting compilation time.
unsigned totalNumSeedGroups() const {
More information about the llvm-commits
mailing list