[llvm] [Clang] [OMPIRBuilder] Add Assertion to Prevent Null Pointer Dereference in OpenMP IR Builder (PR #115506)
via llvm-commits
llvm-commits at lists.llvm.org
Fri Nov 8 08:12:49 PST 2024
https://github.com/smanna12 created https://github.com/llvm/llvm-project/pull/115506
The fix in OMPIRBuilder.cpp adds an assertion to ensure that ArgStructType is not null before it is used.
This prevents potential null pointer dereference issues, improving the stability and reliability of the code.
>From b988d27bd43b684f3cdb8f7b19e2d9916fc26fb4 Mon Sep 17 00:00:00 2001
From: "Manna, Soumi" <soumi.manna at intel.com>
Date: Fri, 8 Nov 2024 08:08:41 -0800
Subject: [PATCH] [Clang][OpenMP] Add Assertion to Prevent Null Pointer
Dereference in OpenMP IR Builder
---
llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp b/llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
index d2e4dc1c85dfd2..869f237ff992cc 100644
--- a/llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
+++ b/llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
@@ -6966,6 +6966,10 @@ static Function *emitTargetTaskProxyFunction(OpenMPIRBuilder &OMPBuilder,
auto *ArgStructType =
dyn_cast<StructType>(ArgStructAlloca->getAllocatedType());
+ assert(ArgStructType &&
+ "Unable to find the struct type corresponding to the alloca "
+ "instruction");
+
AllocaInst *NewArgStructAlloca =
Builder.CreateAlloca(ArgStructType, nullptr, "structArg");
Value *TaskT = ProxyFn->getArg(1);
More information about the llvm-commits
mailing list