[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
Thu Nov 21 06:29:02 PST 2024
https://github.com/smanna12 updated https://github.com/llvm/llvm-project/pull/115506
>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 1/2] [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);
>From c5ca712b664e5860c675f9f42a1e2d1a8bd053db Mon Sep 17 00:00:00 2001
From: "Manna, Soumi" <soumi.manna at intel.com>
Date: Thu, 21 Nov 2024 06:28:25 -0800
Subject: [PATCH 2/2] Add cast instaed of dyn_cast<>
---
llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp | 7 +------
1 file changed, 1 insertion(+), 6 deletions(-)
diff --git a/llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp b/llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
index 869f237ff992cc..78eb73ef67d816 100644
--- a/llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
+++ b/llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
@@ -6963,12 +6963,7 @@ static Function *emitTargetTaskProxyFunction(OpenMPIRBuilder &OMPBuilder,
assert(ArgStructAlloca &&
"Unable to find the alloca instruction corresponding to arguments "
"for extracted function");
- auto *ArgStructType =
- dyn_cast<StructType>(ArgStructAlloca->getAllocatedType());
-
- assert(ArgStructType &&
- "Unable to find the struct type corresponding to the alloca "
- "instruction");
+ auto *ArgStructType = cast<StructType>(ArgStructAlloca->getAllocatedType());
AllocaInst *NewArgStructAlloca =
Builder.CreateAlloca(ArgStructType, nullptr, "structArg");
More information about the llvm-commits
mailing list