diff options
Diffstat (limited to 'dynamic-layers/clang-layer/recipes-opencl/igc/files/c707d1e2244aec988bdd5d2a7473ef3a32a5bac7.patch')
-rw-r--r-- | dynamic-layers/clang-layer/recipes-opencl/igc/files/c707d1e2244aec988bdd5d2a7473ef3a32a5bac7.patch | 144 |
1 files changed, 0 insertions, 144 deletions
diff --git a/dynamic-layers/clang-layer/recipes-opencl/igc/files/c707d1e2244aec988bdd5d2a7473ef3a32a5bac7.patch b/dynamic-layers/clang-layer/recipes-opencl/igc/files/c707d1e2244aec988bdd5d2a7473ef3a32a5bac7.patch deleted file mode 100644 index 5f9527b3..00000000 --- a/dynamic-layers/clang-layer/recipes-opencl/igc/files/c707d1e2244aec988bdd5d2a7473ef3a32a5bac7.patch +++ /dev/null | |||
@@ -1,144 +0,0 @@ | |||
1 | From cce0d22ebba79075792e6f30c597d8d29d946e8c Mon Sep 17 00:00:00 2001 | ||
2 | From: Artem Gindinson <artem.gindinson@intel.com> | ||
3 | Date: Thu, 17 Nov 2022 18:51:03 +0000 | ||
4 | Subject: [PATCH] Disable opaque pointers in IGC stack for LLVM 15+ | ||
5 | |||
6 | While IGC is a long way from supporting opaque pointers, LLVM 15 has them | ||
7 | enabled by default. Enforce typed pointers explicitly within all LLVM | ||
8 | pipelines employed by our stack (unless CMake instructs otherwise). | ||
9 | |||
10 | Upstream-Status: Backport | ||
11 | Signed-off-by: Anuj Mittal <anuj.mittal@intel.com> | ||
12 | |||
13 | --- | ||
14 | IGC/BiFModule/CMakeLists.txt | 4 ++-- | ||
15 | IGC/CMakeLists.txt | 4 ++++ | ||
16 | IGC/Compiler/CodeGenContext.cpp | 3 +++ | ||
17 | IGC/OCLFE/igd_fcl_mcl/source/clang_tb.cpp | 4 ++++ | ||
18 | IGC/VectorCompiler/lib/BiF/CMakeLists.txt | 4 ++-- | ||
19 | IGC/cmake/igc_llvm.cmake | 24 +++++++++++++++++++++++ | ||
20 | 6 files changed, 39 insertions(+), 4 deletions(-) | ||
21 | |||
22 | diff --git a/IGC/BiFModule/CMakeLists.txt b/IGC/BiFModule/CMakeLists.txt | ||
23 | index 60fc5cf8d..e87288ca6 100644 | ||
24 | --- a/IGC/BiFModule/CMakeLists.txt | ||
25 | +++ b/IGC/BiFModule/CMakeLists.txt | ||
26 | @@ -251,7 +251,7 @@ function(igc_bif_build_bc) | ||
27 | add_custom_command( | ||
28 | OUTPUT "${_bcTempFilePath}" | ||
29 | COMMAND "${CMAKE_COMMAND}" -E compare_files ${BiFModule_PREBUILD_SHA_PATH} ${BiFModule_SRC_SHA_PATH} || "${CMAKE_COMMAND}" -E make_directory "${_outBcFileDir}" | ||
30 | - COMMAND "${CMAKE_COMMAND}" -E compare_files ${BiFModule_PREBUILD_SHA_PATH} ${BiFModule_SRC_SHA_PATH} || "$<TARGET_FILE:clang-tool>" -cc1 -x cl -fblocks -fpreserve-vec3-type -opencl-builtins "-triple=${_archTriple}" -w -emit-llvm-bc -o "${_bcTempFilePath}" ${_pchFlags} ${_incFileFlags} ${_includeDirsFlags} ${_defineFlags} ${_options_DEFAULT} ${_options_CL} "${_srcFilePath}" | ||
31 | + COMMAND "${CMAKE_COMMAND}" -E compare_files ${BiFModule_PREBUILD_SHA_PATH} ${BiFModule_SRC_SHA_PATH} || "$<TARGET_FILE:clang-tool>" -cc1 ${IGC_LLVM_DEPENDENT_CLANG_FLAGS} -x cl -fblocks -fpreserve-vec3-type -opencl-builtins "-triple=${_archTriple}" -w -emit-llvm-bc -o "${_bcTempFilePath}" ${_pchFlags} ${_incFileFlags} ${_includeDirsFlags} ${_defineFlags} ${_options_DEFAULT} ${_options_CL} "${_srcFilePath}" | ||
32 | DEPENDS clang-tool ${_pchFilePath} ${_incFilePaths} "${_srcFilePath}" ${_dependencies} | ||
33 | COMMENT "BiF: \"${_outBcFileName}\": Compiling OpenCL source: \"${_srcFileName}\"" | ||
34 | ) | ||
35 | @@ -351,7 +351,7 @@ function(igc_bif_build_bc) | ||
36 | add_custom_command( | ||
37 | OUTPUT "${_bcTempFilePath}" | ||
38 | COMMAND "${CMAKE_COMMAND}" -E compare_files ${BiFModule_PREBUILD_SHA_PATH} ${BiFModule_SRC_SHA_PATH} || "${CMAKE_COMMAND}" -E make_directory "${_outBcFileDir}" | ||
39 | - COMMAND "${CMAKE_COMMAND}" -E compare_files ${BiFModule_PREBUILD_SHA_PATH} ${BiFModule_SRC_SHA_PATH} || "${bif-llvm-opt_exe}" -O2 -o "${_bcTempFilePath}" ${_options_DEFAULT} ${_options_OPT} ${_bcFiles} | ||
40 | + COMMAND "${CMAKE_COMMAND}" -E compare_files ${BiFModule_PREBUILD_SHA_PATH} ${BiFModule_SRC_SHA_PATH} || "${bif-llvm-opt_exe}" -O2 -o "${_bcTempFilePath}" ${IGC_LLVM_DEPENDENT_OPT_ARGS} ${_options_DEFAULT} ${_options_OPT} ${_bcFiles} | ||
41 | DEPENDS ${_bcFiles} ${_dependencies} | ||
42 | COMMENT "BiF: \"${_outBcFileName}\": Optmizing output .bc." | ||
43 | ) | ||
44 | diff --git a/IGC/CMakeLists.txt b/IGC/CMakeLists.txt | ||
45 | index 930a55212..66ea2a3b5 100644 | ||
46 | --- a/IGC/CMakeLists.txt | ||
47 | +++ b/IGC/CMakeLists.txt | ||
48 | @@ -275,6 +275,10 @@ endif() | ||
49 | # Remove this condition after transition period is over | ||
50 | option(IGC_OPTION__USE_KHRONOS_SPIRV_TRANSLATOR_IN_SC "[Experimental] Enable usage of Khronos SPIRV-LLVM-Translator in Scalar Compiler" OFF) | ||
51 | |||
52 | +# TODO: Change this flag to opt-out or remove completely once | ||
53 | +# opaque pointers are fully supported within the IGC stack. | ||
54 | +option(IGC_OPTION__LLVM_OPAQUE_POINTERS_ENABLED "[Experimental] Allow usage of opaque pointers within LLVM transformations" OFF) | ||
55 | + | ||
56 | option(IGC_OPTION__ENABLE_LIT_TESTS "Enable lit testing for IGC compiler. May require additional tools like llvm lit and opt" OFF) | ||
57 | |||
58 | set(IGC_OPTION__BIF_SRC_OCL_DIR "${IGC_SOURCE_DIR}/BiFModule" | ||
59 | diff --git a/IGC/Compiler/CodeGenContext.cpp b/IGC/Compiler/CodeGenContext.cpp | ||
60 | index fc04b5d84..fe1773b85 100644 | ||
61 | --- a/IGC/Compiler/CodeGenContext.cpp | ||
62 | +++ b/IGC/Compiler/CodeGenContext.cpp | ||
63 | @@ -232,6 +232,9 @@ namespace IGC | ||
64 | { | ||
65 | CreateResourceDimensionTypes(*this); | ||
66 | } | ||
67 | +#ifdef __IGC_OPAQUE_POINTERS_FORCE_DISABLED__ | ||
68 | + this->setOpaquePointers(false); | ||
69 | +#endif | ||
70 | } | ||
71 | |||
72 | void LLVMContextWrapper::AddRef() | ||
73 | diff --git a/IGC/OCLFE/igd_fcl_mcl/source/clang_tb.cpp b/IGC/OCLFE/igd_fcl_mcl/source/clang_tb.cpp | ||
74 | index 4a6fb40dd..f9b308503 100644 | ||
75 | --- a/IGC/OCLFE/igd_fcl_mcl/source/clang_tb.cpp | ||
76 | +++ b/IGC/OCLFE/igd_fcl_mcl/source/clang_tb.cpp | ||
77 | @@ -1494,6 +1494,10 @@ namespace TC | ||
78 | optionsEx += " -debug-info-kind=line-tables-only -dwarf-version=4"; | ||
79 | } | ||
80 | |||
81 | +#ifdef __IGC_OPAQUE_POINTERS_FORCE_DISABLED__ | ||
82 | + optionsEx += " -no-opaque-pointers"; | ||
83 | +#endif | ||
84 | + | ||
85 | std::string extensionsFromInternalOptions = GetSubstring(pInternalOptions, "-cl-ext="); | ||
86 | |||
87 | std::string extensions; | ||
88 | diff --git a/IGC/VectorCompiler/lib/BiF/CMakeLists.txt b/IGC/VectorCompiler/lib/BiF/CMakeLists.txt | ||
89 | index b2e56e091..77f397f79 100644 | ||
90 | --- a/IGC/VectorCompiler/lib/BiF/CMakeLists.txt | ||
91 | +++ b/IGC/VectorCompiler/lib/BiF/CMakeLists.txt | ||
92 | @@ -90,7 +90,7 @@ function(vc_build_bif RES_FILE CMCL_SRC_PATH BIF_NAME PTR_BIT_SIZE) | ||
93 | |||
94 | add_custom_command(OUTPUT "${BIF_CLANG_BC_PATH}" | ||
95 | COMMAND clang-tool -cc1 ${CMCL_INCLUDES} ${VC_INCLUDES} ${UTILS_HEADERS} | ||
96 | - ${EXTRA_CLANG_INCLUDES} ${EXTRA_CLANG_FLAGS} | ||
97 | + ${EXTRA_CLANG_INCLUDES} ${IGC_LLVM_DEPENDENT_CLANG_FLAGS} ${EXTRA_CLANG_FLAGS} | ||
98 | -x cl -cl-std=clc++ -triple=${SPIR_TARGET} | ||
99 | -O2 -disable-llvm-passes -emit-llvm-bc -o "${BIF_CLANG_BC_NAME}" ${CMCL_SRC} | ||
100 | COMMENT "vc_build_bif: Compiling CMCL source ${CMCL_SRC} to BC ${BIF_CLANG_BC_NAME}" | ||
101 | @@ -110,7 +110,7 @@ function(vc_build_bif RES_FILE CMCL_SRC_PATH BIF_NAME PTR_BIT_SIZE) | ||
102 | COMMENT "vc_build_bif: Translating CMCL builtins: ${BIF_CLANG_BC_NAME_FINAL} -> ${BIF_CMCL_BC_NAME}" | ||
103 | DEPENDS CMCLTranslatorTool ${BIF_CLANG_BC_PATH_FINAL}) | ||
104 | add_custom_command(OUTPUT ${BIF_OPT_BC_PATH} | ||
105 | - COMMAND ${LLVM_OPT_EXE} --O2 -o ${BIF_OPT_BC_NAME} ${BIF_CMCL_BC_NAME} | ||
106 | + COMMAND ${LLVM_OPT_EXE} ${IGC_LLVM_DEPENDENT_OPT_FLAGS} --O2 -o ${BIF_OPT_BC_NAME} ${BIF_CMCL_BC_NAME} | ||
107 | COMMENT "vc_build_bif: running opt with O2: ${BIF_CMCL_BC_NAME} -> ${BIF_OPT_BC_NAME}" | ||
108 | DEPENDS ${BIF_CMCL_BC_PATH}) | ||
109 | set(${RES_FILE} ${BIF_OPT_BC_NAME} PARENT_SCOPE) | ||
110 | diff --git a/IGC/cmake/igc_llvm.cmake b/IGC/cmake/igc_llvm.cmake | ||
111 | index c0f74dcea..96e3b0d11 100644 | ||
112 | --- a/IGC/cmake/igc_llvm.cmake | ||
113 | +++ b/IGC/cmake/igc_llvm.cmake | ||
114 | @@ -69,6 +69,30 @@ list(TRANSFORM LLVM_INCLUDE_DIRS PREPEND "-I=" OUTPUT_VARIABLE LLVM_TABLEGEN_FLA | ||
115 | # Add major version definition for llvm wrapper. | ||
116 | add_compile_definitions(LLVM_VERSION_MAJOR=${LLVM_VERSION_MAJOR}) | ||
117 | |||
118 | +set(IGC_LLVM_DEPENDENT_CLANG_FLAGS "") | ||
119 | +set(IGC_LLVM_DEPENDENT_OPT_FLAGS "") | ||
120 | + | ||
121 | +# Disable the opaque pointers' usage explicitly, unless the block below deems that unnecessary | ||
122 | +set(IGC_OPAQUE_POINTERS_FORCE_DISABLED ON) | ||
123 | +if(IGC_OPTION__LLVM_OPAQUE_POINTERS_ENABLED) | ||
124 | + if(LLVM_VERSION_MAJOR LESS 14) | ||
125 | + message(WARNING "IGC_OPTION__LLVM_OPAQUE_POINTERS_ENABLED ignored: opaque pointers are not available prior to LLVM 14") | ||
126 | + endif() | ||
127 | + set(IGC_OPAQUE_POINTERS_FORCE_DISABLED OFF) | ||
128 | +elseif(LLVM_VERSION_MAJOR LESS 15) | ||
129 | + # Opaque pointers are either absent (LLVM <14) or disabled by default. No need to force-disable | ||
130 | + set(IGC_OPAQUE_POINTERS_FORCE_DISABLED OFF) | ||
131 | +endif(IGC_OPTION__LLVM_OPAQUE_POINTERS_ENABLED) | ||
132 | + | ||
133 | +if(IGC_OPAQUE_POINTERS_FORCE_DISABLED) | ||
134 | + # Once we've figured out that explicit disabling is needed, propagate | ||
135 | + # corresponding options to all the in-tree calls of clang/opt tools. | ||
136 | + list(APPEND IGC_LLVM_DEPENDENT_CLANG_FLAGS "-no-opaque-pointers") | ||
137 | + list(APPEND IGC_LLVM_DEPENDENT_OPT_FLAGS "-opaque-pointers=0") | ||
138 | + # Also inform the preprocessor. | ||
139 | + add_compile_definitions(__IGC_OPAQUE_POINTERS_FORCE_DISABLED__) | ||
140 | +endif() | ||
141 | + | ||
142 | # Include LLVM headers as system ones. | ||
143 | # This will disable warnings on linux. | ||
144 | include_directories(SYSTEM ${LLVM_INCLUDE_DIRS}) | ||