[llvm-branch-commits] [clang] 13e4d9e - [SPIR-V] Disable opaque pointers in relese 15

Tobias Hieta via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Wed Aug 10 01:59:27 PDT 2022


Author: Tom Stellard
Date: 2022-08-10T10:58:31+02:00
New Revision: 13e4d9eab61ee985bf25cdf53b29bc7db55333a2

URL: https://github.com/llvm/llvm-project/commit/13e4d9eab61ee985bf25cdf53b29bc7db55333a2
DIFF: https://github.com/llvm/llvm-project/commit/13e4d9eab61ee985bf25cdf53b29bc7db55333a2.diff

LOG: [SPIR-V] Disable opaque pointers in relese 15

As discussed on RFC mapping into SPIR-V requires pointer being preserved in some cases: https://discourse.llvm.org/t/rfc-better-support-for-typed-pointers-in-an-opaque-pointer-world/63339/23?u=anastasiastulova

As the work is still unfinished the best approach is to continue using pointer types.

Note that this change is only planned to be committed in release 15 branch.

This fixing PR56660.

Reviewed By: jcranmer-intel

Differential Revision: https://reviews.llvm.org/D130766

Added: 
    

Modified: 
    clang/lib/Driver/ToolChains/Clang.cpp
    clang/test/Driver/spirv-toolchain.cl

Removed: 
    


################################################################################
diff  --git a/clang/lib/Driver/ToolChains/Clang.cpp b/clang/lib/Driver/ToolChains/Clang.cpp
index 3587326e0e58..3704ed858668 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -4622,8 +4622,13 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
   TC.addClangWarningOptions(CmdArgs);
 
   // FIXME: Subclass ToolChain for SPIR and move this to addClangWarningOptions.
-  if (Triple.isSPIR() || Triple.isSPIRV())
+  if (Triple.isSPIR() || Triple.isSPIRV()) {
     CmdArgs.push_back("-Wspir-compat");
+    // SPIR-V support still needs pointer types in some cases as recovering
+    // type from pointer uses is not always possible e.g. for extern functions
+    // (see PR56660).
+    CmdArgs.push_back("-no-opaque-pointers");
+  }
 
   // Select the appropriate action.
   RewriteKind rewriteKind = RK_None;

diff  --git a/clang/test/Driver/spirv-toolchain.cl b/clang/test/Driver/spirv-toolchain.cl
index db3ee4d3fe02..8bec46b44044 100644
--- a/clang/test/Driver/spirv-toolchain.cl
+++ b/clang/test/Driver/spirv-toolchain.cl
@@ -6,6 +6,7 @@
 // RUN: %clang -### --target=spirv64 -x c -c %s 2>&1 | FileCheck --check-prefix=SPV64 %s
 
 // SPV64: "-cc1" "-triple" "spirv64"
+// SPV64-SAME: "-no-opaque-pointers"
 // SPV64-SAME: "-o" [[BC:".*bc"]]
 // SPV64: {{llvm-spirv.*"}} [[BC]] "-o" {{".*o"}}
 
@@ -16,6 +17,7 @@
 // RUN: %clang -### --target=spirv32 -x c -c %s 2>&1 | FileCheck --check-prefix=SPV32 %s
 
 // SPV32: "-cc1" "-triple" "spirv32"
+// SPV32-SAME: "-no-opaque-pointers"
 // SPV32-SAME: "-o" [[BC:".*bc"]]
 // SPV32: {{llvm-spirv.*"}} [[BC]] "-o" {{".*o"}}
 


        


More information about the llvm-branch-commits mailing list