From f88f4492076e51dcd335c59bb274301207cc8263 Mon Sep 17 00:00:00 2001 From: Pavel Samolysov Date: Fri, 11 Feb 2022 15:03:06 +0300 Subject: [PATCH 1/3] [sycl-post-link][NFC] Small changes in the sycl-post-link code The patch fixes some issues from clang-tidy related to the code-style and missed auto-stars (auto*) when a local variable is a pointer. --- llvm/tools/sycl-post-link/SpecConstants.cpp | 12 ++++++------ llvm/tools/sycl-post-link/sycl-post-link.cpp | 14 +++++++------- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/llvm/tools/sycl-post-link/SpecConstants.cpp b/llvm/tools/sycl-post-link/SpecConstants.cpp index fea47cf1b5239..38ef09dd375f6 100644 --- a/llvm/tools/sycl-post-link/SpecConstants.cpp +++ b/llvm/tools/sycl-post-link/SpecConstants.cpp @@ -369,11 +369,11 @@ void collectCompositeElementsDefaultValuesRecursive( // Assume that we encountered some scalar element size_t NumBytes = M.getDataLayout().getTypeStoreSize(C->getType()); - if (auto IntConst = dyn_cast(C)) { + if (auto* IntConst = dyn_cast(C)) { auto Val = IntConst->getValue().getZExtValue(); std::copy_n(reinterpret_cast(&Val), NumBytes, std::back_inserter(DefaultValues)); - } else if (auto FPConst = dyn_cast(C)) { + } else if (auto* FPConst = dyn_cast(C)) { auto Val = FPConst->getValue(); if (NumBytes == 2) { @@ -383,12 +383,12 @@ void collectCompositeElementsDefaultValuesRecursive( std::copy_n(reinterpret_cast(&Storage), NumBytes, std::back_inserter(DefaultValues)); } else if (NumBytes == 4) { - float v = Val.convertToFloat(); - std::copy_n(reinterpret_cast(&v), NumBytes, + float V = Val.convertToFloat(); + std::copy_n(reinterpret_cast(&V), NumBytes, std::back_inserter(DefaultValues)); } else if (NumBytes == 8) { - double v = Val.convertToDouble(); - std::copy_n(reinterpret_cast(&v), NumBytes, + double V = Val.convertToDouble(); + std::copy_n(reinterpret_cast(&V), NumBytes, std::back_inserter(DefaultValues)); } else { llvm_unreachable("Unexpected constant floating point type"); diff --git a/llvm/tools/sycl-post-link/sycl-post-link.cpp b/llvm/tools/sycl-post-link/sycl-post-link.cpp index c375da0121ea5..c1e2104a4424b 100644 --- a/llvm/tools/sycl-post-link/sycl-post-link.cpp +++ b/llvm/tools/sycl-post-link/sycl-post-link.cpp @@ -368,14 +368,14 @@ void groupEntryPoints(const Module &M, EntryPointGroupMap &EntryPointsGroups, // This function traverses over reversed call graph by BFS algorithm. // It means that an edge links some function @func with functions // which contain call of function @func. It starts from -// @StartingFunction and lifts up until it reach all reachable functions +// @StartingFunction and lifts up until it reach all reachable functions, // or it reaches some function containing "referenced-indirectly" attribute. // If it reaches "referenced-indirectly" attribute than it returns an empty // Optional. // Otherwise, it returns an Optional containing a list of reached // SPIR kernel function's names. Optional> -TraverseCGToFindSPIRKernels(const Function *StartingFunction) { +traverseCGToFindSPIRKernels(const Function *StartingFunction) { std::queue FunctionsToVisit; std::unordered_set VisitedFunctions; FunctionsToVisit.push(StartingFunction); @@ -411,19 +411,19 @@ TraverseCGToFindSPIRKernels(const Function *StartingFunction) { } } - return std::move(KernelNames); + return {std::move(KernelNames)}; } std::vector getKernelNamesUsingAssert(const Module &M) { - auto DevicelibAssertFailFunction = M.getFunction("__devicelib_assert_fail"); + auto *DevicelibAssertFailFunction = M.getFunction("__devicelib_assert_fail"); if (!DevicelibAssertFailFunction) return {}; auto TraverseResult = - TraverseCGToFindSPIRKernels(DevicelibAssertFailFunction); + traverseCGToFindSPIRKernels(DevicelibAssertFailFunction); if (TraverseResult.hasValue()) - return std::move(*TraverseResult); + return std::move(*TraverseResult); // TODO remove std::move after C++17 // Here we reached "referenced-indirectly", so we need to find all kernels and // return them. @@ -438,7 +438,7 @@ std::vector getKernelNamesUsingAssert(const Module &M) { // Gets reqd_work_group_size information for function Func. std::vector getKernelReqdWorkGroupSizeMetadata(const Function &Func) { - auto ReqdWorkGroupSizeMD = Func.getMetadata("reqd_work_group_size"); + auto *ReqdWorkGroupSizeMD = Func.getMetadata("reqd_work_group_size"); if (!ReqdWorkGroupSizeMD) return {}; // TODO: Remove 3-operand assumption when it is relaxed. From e233c1dc0fecc09161e3f8569214d8549e586a89 Mon Sep 17 00:00:00 2001 From: Pavel Samolysov Date: Fri, 11 Feb 2022 16:36:47 +0300 Subject: [PATCH 2/3] [sycl-post-link][NFC] Fix formatting issues --- llvm/tools/sycl-post-link/SpecConstants.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/llvm/tools/sycl-post-link/SpecConstants.cpp b/llvm/tools/sycl-post-link/SpecConstants.cpp index 38ef09dd375f6..695809f1272af 100644 --- a/llvm/tools/sycl-post-link/SpecConstants.cpp +++ b/llvm/tools/sycl-post-link/SpecConstants.cpp @@ -369,11 +369,11 @@ void collectCompositeElementsDefaultValuesRecursive( // Assume that we encountered some scalar element size_t NumBytes = M.getDataLayout().getTypeStoreSize(C->getType()); - if (auto* IntConst = dyn_cast(C)) { + if (auto *IntConst = dyn_cast(C)) { auto Val = IntConst->getValue().getZExtValue(); std::copy_n(reinterpret_cast(&Val), NumBytes, std::back_inserter(DefaultValues)); - } else if (auto* FPConst = dyn_cast(C)) { + } else if (auto *FPConst = dyn_cast(C)) { auto Val = FPConst->getValue(); if (NumBytes == 2) { From d5cb13eb3b4b6bbcb03ac4f75773571dd300a9ff Mon Sep 17 00:00:00 2001 From: Pavel Samolysov Date: Fri, 11 Feb 2022 18:53:12 +0300 Subject: [PATCH 3/3] [NFC] Remove the TODO about replacing moving with pass by value --- llvm/tools/sycl-post-link/sycl-post-link.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/llvm/tools/sycl-post-link/sycl-post-link.cpp b/llvm/tools/sycl-post-link/sycl-post-link.cpp index c1e2104a4424b..b89ed206533f0 100644 --- a/llvm/tools/sycl-post-link/sycl-post-link.cpp +++ b/llvm/tools/sycl-post-link/sycl-post-link.cpp @@ -423,7 +423,7 @@ std::vector getKernelNamesUsingAssert(const Module &M) { traverseCGToFindSPIRKernels(DevicelibAssertFailFunction); if (TraverseResult.hasValue()) - return std::move(*TraverseResult); // TODO remove std::move after C++17 + return std::move(*TraverseResult); // Here we reached "referenced-indirectly", so we need to find all kernels and // return them.