Skip to content

[SYCL][NFC] Fixed static analysis warnings in LowerESIMD.cpp #2415

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 1 commit into from
Sep 4, 2020
Merged
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
9 changes: 7 additions & 2 deletions llvm/lib/SYCLLowerIR/LowerESIMD.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -579,6 +579,7 @@ template <typename Ty = llvm::Value> Ty *getVal(llvm::Metadata *M) {
static llvm::MDNode *getSLMSizeMDNode(llvm::Function *F) {
llvm::NamedMDNode *Nodes =
F->getParent()->getNamedMetadata(GENX_KERNEL_METADATA);
assert(Nodes && "invalid genx.kernels metadata");
for (auto Node : Nodes->operands()) {
if (Node->getNumOperands() >= 4 && getVal(Node->getOperand(0)) == F)
return Node;
Expand Down Expand Up @@ -626,6 +627,8 @@ static void translateSLMInit(CallInst &CI) {
static void translatePackMask(CallInst &CI) {
using Demangler = id::ManglingParser<SimpleAllocator>;
Function *F = CI.getCalledFunction();
assert(F && "function to translate is invalid");

StringRef MnglName = F->getName();
Demangler Parser(MnglName.begin(), MnglName.end());
id::Node *AST = Parser.parse();
Expand Down Expand Up @@ -665,6 +668,7 @@ static void translatePackMask(CallInst &CI) {
static void translateUnPackMask(CallInst &CI) {
using Demangler = id::ManglingParser<SimpleAllocator>;
Function *F = CI.getCalledFunction();
assert(F && "function to translate is invalid");
StringRef MnglName = F->getName();
Demangler Parser(MnglName.begin(), MnglName.end());
id::Node *AST = Parser.parse();
Expand Down Expand Up @@ -729,7 +733,7 @@ static void translateGetValue(CallInst &CI) {
IRBuilder<> Builder(&CI);
auto SV =
Builder.CreatePtrToInt(opnd, IntegerType::getInt32Ty(CI.getContext()));
auto *SI = dyn_cast<CastInst>(SV);
auto *SI = cast<CastInst>(SV);
SI->setDebugLoc(CI.getDebugLoc());
CI.replaceAllUsesWith(SI);
}
Expand Down Expand Up @@ -1018,6 +1022,7 @@ static void createESIMDIntrinsicArgs(const ESIMDIntrinDesc &Desc,
static void translateESIMDIntrinsicCall(CallInst &CI) {
using Demangler = id::ManglingParser<SimpleAllocator>;
Function *F = CI.getCalledFunction();
assert(F && "function to translate is invalid");
StringRef MnglName = F->getName();
Demangler Parser(MnglName.begin(), MnglName.end());
id::Node *AST = Parser.parse();
Expand All @@ -1039,7 +1044,7 @@ static void translateESIMDIntrinsicCall(CallInst &CI) {
if (!Desc.isValid()) // TODO remove this once all intrinsics are supported
return;

auto *FTy = CI.getCalledFunction()->getFunctionType();
auto *FTy = F->getFunctionType();
std::string Suffix = getESIMDIntrinSuffix(FE, FTy, Desc.SuffixRule);
auto ID = GenXIntrinsic::lookupGenXIntrinsicID(
GenXIntrinsic::getGenXIntrinsicPrefix() + Desc.GenXSpelling + Suffix);
Expand Down