[llvm] [Hexagon] Fix -Wuninitialized warning (PR #125565)
Brian Cain via llvm-commits
llvm-commits at lists.llvm.org
Mon Feb 3 11:53:57 PST 2025
https://github.com/androm3da created https://github.com/llvm/llvm-project/pull/125565
`gcc (GCC) 14.2.1 20240910` reports the warning below on the baseline, this change fixes the warning.
In file included from /home/user/CLionProjects/llvm-project/llvm/lib/Target/Hexagon/BitTracker.cpp:55:
/home/user/CLionProjects/llvm-project/llvm/lib/Target/Hexagon/BitTracker.h: In constructor ‘llvm::BitTracker::UseQueueType::UseQueueType()’:
/home/user/CLionProjects/llvm-project/llvm/lib/Target/Hexagon/BitTracker.h:75:27: warning: member ‘llvm::BitTracker::UseQueueType::Dist’ is used uninitialized [-Wuninitialized]
75 | UseQueueType() : Uses(Dist) {}
| ^~~~
Fixes #125545
>From 9856d42f0d9aab6c3bd57c313c8059501bfcb357 Mon Sep 17 00:00:00 2001
From: Brian Cain <brian.cain at oss.qualcomm.com>
Date: Mon, 3 Feb 2025 11:51:53 -0800
Subject: [PATCH] [Hexagon] Fix -Wuninitialized warning
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
`gcc (GCC) 14.2.1 20240910` reports the warning below on the baseline, this
change fixes the warning.
In file included from /home/user/CLionProjects/llvm-project/llvm/lib/Target/Hexagon/BitTracker.cpp:55:
/home/user/CLionProjects/llvm-project/llvm/lib/Target/Hexagon/BitTracker.h: In constructor ‘llvm::BitTracker::UseQueueType::UseQueueType()’:
/home/user/CLionProjects/llvm-project/llvm/lib/Target/Hexagon/BitTracker.h:75:27: warning: member ‘llvm::BitTracker::UseQueueType::Dist’ is used uninitialized [-Wuninitialized]
75 | UseQueueType() : Uses(Dist) {}
| ^~~~
Fixes #125545
---
llvm/lib/Target/Hexagon/BitTracker.h | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/llvm/lib/Target/Hexagon/BitTracker.h b/llvm/lib/Target/Hexagon/BitTracker.h
index 08c0359a4b7f06..a07abdb7303321 100644
--- a/llvm/lib/Target/Hexagon/BitTracker.h
+++ b/llvm/lib/Target/Hexagon/BitTracker.h
@@ -72,7 +72,7 @@ struct BitTracker {
// Priority queue of instructions using modified registers, ordered by
// their relative position in a basic block.
struct UseQueueType {
- UseQueueType() : Uses(Dist) {}
+ UseQueueType() : Dist(), Uses(Dist) {}
unsigned size() const {
return Uses.size();
@@ -100,9 +100,9 @@ struct BitTracker {
bool operator()(const MachineInstr *MI, const MachineInstr *MJ) const;
DenseMap<const MachineInstr*,unsigned> &Dist;
};
- std::priority_queue<MachineInstr*, std::vector<MachineInstr*>, Cmp> Uses;
DenseSet<const MachineInstr*> Set; // Set to avoid adding duplicate entries.
DenseMap<const MachineInstr*,unsigned> Dist;
+ std::priority_queue<MachineInstr *, std::vector<MachineInstr *>, Cmp> Uses;
};
void reset();
More information about the llvm-commits
mailing list