Skip to content

[SYCL] Fixes to issues reported by a static analyzer run #17550

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Mar 27, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion sycl-jit/common/include/Kernel.h
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,7 @@ struct FrozenPropertyValue {
FrozenPropertyValue(std::string_view Name, uint32_t Value)
: Name{Name}, IsUIntValue{true}, UIntValue{Value}, Bytes{0} {}
FrozenPropertyValue(std::string_view Name, const uint8_t *Ptr, size_t Size)
: Name{Name}, IsUIntValue{false}, Bytes{Size} {
: Name{Name}, IsUIntValue{false}, UIntValue{0}, Bytes{Size} {
std::memcpy(Bytes.begin(), Ptr, Size);
}
};
Expand Down
17 changes: 11 additions & 6 deletions sycl-jit/jit-compiler/lib/translation/KernelTranslation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,13 @@ KernelTranslator::loadKernels(llvm::LLVMContext &LLVMCtx,
// read last. This could cause problems if different modules contain
// definitions with the same name, but different body/content.
// Check that this is not problematic.
Linker::linkModules(*Result, std::move(NewMod),
Linker::Flags::OverrideFromSrc);
const bool HasErrors = Linker::linkModules(
*Result, std::move(NewMod), Linker::Flags::OverrideFromSrc);
if (HasErrors) {
return createStringError(inconvertibleErrorCode(),
"Failed to link modules");
}

if (AddressBits != BinInfo.AddressBits) {
return createStringError(
inconvertibleErrorCode(),
Expand Down Expand Up @@ -300,9 +305,9 @@ KernelTranslator::translateToPTX(SYCLKernelInfo &KernelInfo, llvm::Module &Mod,
}

// FIXME: Check whether we can provide more accurate target information here
auto *TargetMachine = Target->createTargetMachine(
std::unique_ptr<TargetMachine> TargetMachine(Target->createTargetMachine(
TargetTriple, CPU, Features, {}, llvm::Reloc::PIC_, std::nullopt,
llvm::CodeGenOptLevel::Default);
llvm::CodeGenOptLevel::Default));

llvm::legacy::PassManager PM;

Expand Down Expand Up @@ -380,9 +385,9 @@ KernelTranslator::translateToAMDGCN(SYCLKernelInfo &KernelInfo,
}

// FIXME: Check whether we can provide more accurate target information here
auto *TargetMachine = Target->createTargetMachine(
std::unique_ptr<TargetMachine> TargetMachine(Target->createTargetMachine(
TargetTriple, CPU, Features, {}, llvm::Reloc::PIC_, std::nullopt,
llvm::CodeGenOptLevel::Default);
llvm::CodeGenOptLevel::Default));

std::string AMDObj;
{
Expand Down
1 change: 1 addition & 0 deletions sycl-jit/passes/target/TargetFusionInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -458,6 +458,7 @@ class NVPTXAMDGCNTargetFusionInfoBase : public TargetFusionInfoImpl {
SmallPtrSet<Constant *, 8> DeletedFuncs{Funcs.begin(), Funcs.end()};
SmallVector<MDNode *> ValidKernels;
auto *OldAnnotations = LLVMMod->getNamedMetadata(MDName);
assert(OldAnnotations && "Failed to retrieve old annotations");
for (auto *Op : OldAnnotations->operands()) {
if (auto *TOp = dyn_cast<MDTuple>(Op)) {
if (auto *COp = dyn_cast_if_present<ConstantAsMetadata>(
Expand Down
Loading