Skip to content

Commit 8d23c19

Browse files
author
Erich Keane
authored
[SYCL][NFC] Move SYCL pipe metadata call to be inside the null check for D (#1436)
Found by a static analysis tool, maybeEmitPipeStorageMetadata immediately dereferences the "D" parameter. However, the current branch is in a situation where "D" could be nullptr. This patch moves it up into the checked section so that we don't risk this crash. Signed-off-by: Erich Keane <erich.keane@intel.com>
1 parent 925a587 commit 8d23c19

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

clang/lib/CodeGen/CodeGenModule.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3689,6 +3689,9 @@ CodeGenModule::GetOrCreateLLVMGlobal(StringRef MangledName,
36893689
}
36903690
}
36913691
}
3692+
3693+
if (LangOpts.SYCLIsDevice)
3694+
maybeEmitPipeStorageMetadata(D, GV, *this);
36923695
}
36933696

36943697
if (GV->isDeclaration())
@@ -3700,9 +3703,6 @@ CodeGenModule::GetOrCreateLLVMGlobal(StringRef MangledName,
37003703
assert(getContext().getTargetAddressSpace(ExpectedAS) ==
37013704
Ty->getPointerAddressSpace());
37023705

3703-
if (LangOpts.SYCLIsDevice)
3704-
maybeEmitPipeStorageMetadata(D, GV, *this);
3705-
37063706
if (AddrSpace != ExpectedAS)
37073707
return getTargetCodeGenInfo().performAddrSpaceCast(*this, GV, AddrSpace,
37083708
ExpectedAS, Ty);

0 commit comments

Comments
 (0)