[llvm] [SPIRV] Change how to detect OpenCL/Vulkan Env and update tests accordingly. (PR #129689)

via llvm-commits llvm-commits at lists.llvm.org
Wed Apr 2 08:02:54 PDT 2025


github-actions[bot] wrote:

<!--LLVM CODE FORMAT COMMENT: {clang-format}-->


:warning: C/C++ code formatter, clang-format found issues in your code. :warning:

<details>
<summary>
You can test this locally with the following command:
</summary>

``````````bash
git-clang-format --diff HEAD~1 HEAD --extensions h,cpp -- llvm/lib/Target/SPIRV/SPIRVBuiltins.cpp llvm/lib/Target/SPIRV/SPIRVCallLowering.cpp llvm/lib/Target/SPIRV/SPIRVSubtarget.h llvm/unittests/TargetParser/TripleTest.cpp
``````````

</details>

<details>
<summary>
View the diff from clang-format here.
</summary>

``````````diff
diff --git a/llvm/lib/Target/SPIRV/SPIRVBuiltins.cpp b/llvm/lib/Target/SPIRV/SPIRVBuiltins.cpp
index 084bf17c7..c3daeb1bb 100644
--- a/llvm/lib/Target/SPIRV/SPIRVBuiltins.cpp
+++ b/llvm/lib/Target/SPIRV/SPIRVBuiltins.cpp
@@ -1019,7 +1019,8 @@ static bool buildExtendedBitOpsInst(const SPIRV::IncomingCall *Call,
   if ((Opcode == SPIRV::OpBitFieldInsert ||
        Opcode == SPIRV::OpBitFieldSExtract ||
        Opcode == SPIRV::OpBitFieldUExtract || Opcode == SPIRV::OpBitReverse) &&
-      (!ST->canUseExtension(SPIRV::Extension::SPV_KHR_bit_instructions) && (ST->isOpenCLEnv()))) {
+      (!ST->canUseExtension(SPIRV::Extension::SPV_KHR_bit_instructions) &&
+       (ST->isOpenCLEnv()))) {
     std::string DiagMsg = std::string(Builtin->Name) +
                           ": the builtin requires the following SPIR-V "
                           "extension: SPV_KHR_bit_instructions";
diff --git a/llvm/lib/Target/SPIRV/SPIRVCallLowering.cpp b/llvm/lib/Target/SPIRV/SPIRVCallLowering.cpp
index 77bac3b20..e530f4a7b 100644
--- a/llvm/lib/Target/SPIRV/SPIRVCallLowering.cpp
+++ b/llvm/lib/Target/SPIRV/SPIRVCallLowering.cpp
@@ -288,7 +288,8 @@ getExecutionModel(const SPIRVSubtarget &STI, const Function &F) {
   if (value == "compute")
     return SPIRV::ExecutionModel::GLCompute;
 
-  report_fatal_error("This HLSL entry point is not supported by this backend.", false);
+  report_fatal_error("This HLSL entry point is not supported by this backend.",
+                     false);
 }
 
 bool SPIRVCallLowering::lowerFormalArguments(MachineIRBuilder &MIRBuilder,
diff --git a/llvm/lib/Target/SPIRV/SPIRVSubtarget.h b/llvm/lib/Target/SPIRV/SPIRVSubtarget.h
index 726c69ada..9ccbcfec4 100644
--- a/llvm/lib/Target/SPIRV/SPIRVSubtarget.h
+++ b/llvm/lib/Target/SPIRV/SPIRVSubtarget.h
@@ -79,7 +79,7 @@ public:
   unsigned getBound() const { return GR->getBound(); }
   bool canDirectlyComparePointers() const;
   bool isOpenCLEnv() const {
-   return TargetTriple.getEnvironment() == Triple::OpenCL;
+    return TargetTriple.getEnvironment() == Triple::OpenCL;
   }
   bool isVulkanEnv() const { return !isOpenCLEnv(); }
   const std::string &getTargetTripleAsStr() const { return TargetTriple.str(); }

``````````

</details>


https://github.com/llvm/llvm-project/pull/129689


More information about the llvm-commits mailing list