[llvm] Boundary condition check hidden under assert (PR #122005)
Abhay Kanhere via llvm-commits
llvm-commits at lists.llvm.org
Tue Jan 7 14:32:54 PST 2025
https://github.com/AbhayKanhere created https://github.com/llvm/llvm-project/pull/122005
if asserts are disabled this code can return corrupted memory
>From a0b215a09f7bf23bf455f402df0d69bf7603d5e1 Mon Sep 17 00:00:00 2001
From: Abhay Kanhere <abhay at kanhere.net>
Date: Tue, 3 Dec 2024 16:43:50 -0800
Subject: [PATCH 1/2] [Nomination] Add additional Apple representative to the
Security Group
I'd like to nominate myself as an additional apple representative
(vendor contact) on the llvm security group.
I met many of you at the llvm-dev meeting roundtable(s) in Santa Clara.
I closely work with @ahmedbougacha @jloerofs at apple.
---
llvm/docs/Security.rst | 1 +
1 file changed, 1 insertion(+)
diff --git a/llvm/docs/Security.rst b/llvm/docs/Security.rst
index 67b6ebb4b04d94..aaa599b787a76d 100644
--- a/llvm/docs/Security.rst
+++ b/llvm/docs/Security.rst
@@ -36,6 +36,7 @@ meet the criteria for inclusion below. The list is in the format
`* ${full_name} (${affiliation}) [${github_username}]`. If a github
username for an individual isn't available, the brackets will be empty.
+* Abhay Kanhere (Apple) [@AbhayKanhere]
* Ahmed Bougacha (Apple) [@ahmedbougacha]
* Artur Pilipenko (Azul Systems Inc) []
* Boovaragavan Dasarathan (Nvidia) [@mrragava]
>From ea71125d26ce5c1bf0523f7fb2e0730066498d61 Mon Sep 17 00:00:00 2001
From: Abhay Kanhere <abhay at kanhere.net>
Date: Tue, 7 Jan 2025 14:19:35 -0800
Subject: [PATCH 2/2] [CodeGen][DebugValues] Fix unhandled error condition in
VarLoc When assert() are disabled, this function can return corrupt data.
---
llvm/lib/CodeGen/LiveDebugValues/VarLocBasedImpl.cpp | 12 ++++--------
1 file changed, 4 insertions(+), 8 deletions(-)
diff --git a/llvm/lib/CodeGen/LiveDebugValues/VarLocBasedImpl.cpp b/llvm/lib/CodeGen/LiveDebugValues/VarLocBasedImpl.cpp
index a5e6bebcd29c7f..6306476fac657f 100644
--- a/llvm/lib/CodeGen/LiveDebugValues/VarLocBasedImpl.cpp
+++ b/llvm/lib/CodeGen/LiveDebugValues/VarLocBasedImpl.cpp
@@ -997,13 +997,6 @@ class VarLocBasedLDV : public LDVImpl {
return *VLS;
}
- const VarLocSet &getVarLocsInMBB(const MachineBasicBlock *MBB,
- const VarLocInMBB &Locs) const {
- auto It = Locs.find(MBB);
- assert(It != Locs.end() && "MBB not in map");
- return *It->second;
- }
-
/// Tests whether this instruction is a spill to a stack location.
bool isSpillInstruction(const MachineInstr &MI, MachineFunction *MF);
@@ -1286,7 +1279,10 @@ void VarLocBasedLDV::printVarLocInMBB(const MachineFunction &MF,
for (const MachineBasicBlock &BB : MF) {
if (!V.count(&BB))
continue;
- const VarLocSet &L = getVarLocsInMBB(&BB, V);
+ auto It = V.find(&BB);
+ if (It == V.end())
+ continue;
+ const VarLocSet &L = *It->second;
if (L.empty())
continue;
SmallVector<VarLoc, 32> VarLocs;
More information about the llvm-commits
mailing list