Skip to content

Commit 20c5aea

Browse files
authored
[SYCL][NVPTX] Fix SYCL NVPTX passes if function operand is null-ref (#3272)
1 parent d988bb3 commit 20c5aea

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

llvm/lib/Target/NVPTX/SYCL/GlobalOffset.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -342,8 +342,10 @@ class GlobalOffset : public ModulePass {
342342
continue;
343343

344344
// Get a pointer to the entry point function from the metadata.
345-
auto FuncConstant =
346-
dyn_cast<ConstantAsMetadata>(MetadataNode->getOperand(0));
345+
const auto &FuncOperand = MetadataNode->getOperand(0);
346+
if (!FuncOperand)
347+
continue;
348+
auto FuncConstant = dyn_cast<ConstantAsMetadata>(FuncOperand);
347349
if (!FuncConstant)
348350
continue;
349351
auto Func = dyn_cast<Function>(FuncConstant->getValue());

llvm/lib/Target/NVPTX/SYCL/LocalAccessorToSharedMemory.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,8 @@ class LocalAccessorToSharedMemory : public ModulePass {
6565

6666
// Get a pointer to the entry point function from the metadata.
6767
const MDOperand &FuncOperand = MetadataNode->getOperand(0);
68+
if (!FuncOperand)
69+
continue;
6870
auto FuncConstant = dyn_cast<ConstantAsMetadata>(FuncOperand);
6971
if (!FuncConstant)
7072
continue;

0 commit comments

Comments
 (0)