summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNaveen Saini <naveen.kumar.saini@intel.com>2021-03-26 18:39:15 +0800
committerAnuj Mittal <anuj.mittal@intel.com>2021-04-01 13:30:35 +0800
commita766df8081f6ffaae9a0d028f99ff3faa1313aec (patch)
tree0827d2ec042112a355e28eaf32b4e61528374900
parent39457fee8ec61a0c0be02f964f89b2775a6a5d28 (diff)
downloadmeta-intel-a766df8081f6ffaae9a0d028f99ff3faa1313aec.tar.gz
intel-graphics-compiler: upgrade 1.0.6083 -> 1.0.6410
Patches applied from Open PR#171, in order to build with llvm-12. https://github.com/intel/intel-graphics-compiler/pull/171 Error logs: (1) | /build/tmp/work/corei7-64-poky-linux/intel-graphics-compiler/1.0.6410-r0/git/IGC/Compiler/CISACodeGen/VariableReuseAnalysis.hpp:83:56: error: 'unsigned int llvm::VectorType::getNumElements() const' is deprecated: Calling this function via a base VectorType is deprecated. Either call getElementCount() and handle the case where Scalable is true or cast to FixedVectorType. [-Werror=deprecated-declarations] | 83 | NumElts = VTy ? (short)VTy->getNumElements() : 1; Ref:https://github.com/llvm/llvm-project/commit/867de151a52b6d0750485ac1cf9b3bc012ee51fd (2) | /build/tmp/work/corei7-64-poky-linux/intel-graphics-compiler/1.0.6410-r0/git/IGC/common/igc_resourceDimTypes.h:69:23: error: 'const class llvm::Module' has no member named 'getTypeByName' | 69 | return module.getTypeByName(ResourceDimensionTypeName[resourceDimTypeId]); Ref: https://github.com/llvm/llvm-project/commit/fe431683484a3041e024ab2373bb707b1ca8d1cf Update copyright year in headers in IGC Compiler and some format updates. Signed-off-by: Naveen Saini <naveen.kumar.saini@intel.com> Signed-off-by: Anuj Mittal <anuj.mittal@intel.com>
-rw-r--r--dynamic-layers/clang-layer/recipes-opencl/igc/files/0001-Fix-build-with-LLVM-12.patch2433
-rw-r--r--dynamic-layers/clang-layer/recipes-opencl/igc/files/0002-Review-fixes-for-LLVM-12-phase-1.patch318
-rw-r--r--dynamic-layers/clang-layer/recipes-opencl/igc/files/0003-Review-fixes-for-LLVM-12-phase-2.patch123
-rw-r--r--dynamic-layers/clang-layer/recipes-opencl/igc/intel-graphics-compiler_1.0.6646.bb (renamed from dynamic-layers/clang-layer/recipes-opencl/igc/intel-graphics-compiler_1.0.6083.bb)10
4 files changed, 2880 insertions, 4 deletions
diff --git a/dynamic-layers/clang-layer/recipes-opencl/igc/files/0001-Fix-build-with-LLVM-12.patch b/dynamic-layers/clang-layer/recipes-opencl/igc/files/0001-Fix-build-with-LLVM-12.patch
new file mode 100644
index 00000000..1d2c5767
--- /dev/null
+++ b/dynamic-layers/clang-layer/recipes-opencl/igc/files/0001-Fix-build-with-LLVM-12.patch
@@ -0,0 +1,2433 @@
1From 869cdb784aa062bd08bd26465bf0b5651e8f112e Mon Sep 17 00:00:00 2001
2From: =?UTF-8?q?Zolt=C3=A1n=20B=C3=B6sz=C3=B6rm=C3=A9nyi?= <zboszor@pr.hu>
3Date: Thu, 25 Feb 2021 10:39:27 +0100
4Subject: [PATCH 1/3] Fix build with LLVM 12
5MIME-Version: 1.0
6Content-Type: text/plain; charset=UTF-8
7Content-Transfer-Encoding: 8bit
8
9Upstream-Status: Pending
10
11Signed-off-by: Zoltán Böszörményi <zboszor@gmail.com>
12Signed-off-by: Naveen Saini <naveen.kumar.saini@intel.com>
13---
14 .../LegalizeFunctionSignatures.cpp | 2 +-
15 IGC/AdaptorOCL/SPIRV/SPIRVReader.cpp | 26 +++++++++-----
16 IGC/AdaptorOCL/SPIRV/SPIRVUtil.cpp | 6 +++-
17 IGC/Compiler/CISACodeGen/AdvMemOpt.cpp | 4 +++
18 IGC/Compiler/CISACodeGen/CShader.cpp | 14 ++++----
19 .../CISACodeGen/ConstantCoalescing.cpp | 14 ++++----
20 IGC/Compiler/CISACodeGen/DeSSA.cpp | 3 +-
21 IGC/Compiler/CISACodeGen/EmitVISAPass.cpp | 35 +++++++++---------
22 IGC/Compiler/CISACodeGen/Emu64OpsPass.cpp | 4 +--
23 IGC/Compiler/CISACodeGen/GenIRLowering.cpp | 4 +--
24 .../CISACodeGen/GenSimplification.cpp | 5 +--
25 .../CISACodeGen/GeometryShaderLowering.cpp | 3 +-
26 IGC/Compiler/CISACodeGen/LdShrink.cpp | 10 ++++--
27 .../CISACodeGen/LowerGEPForPrivMem.cpp | 8 ++---
28 IGC/Compiler/CISACodeGen/MemOpt.cpp | 8 ++---
29 IGC/Compiler/CISACodeGen/MemOpt2.cpp | 5 +--
30 .../CISACodeGen/OpenCLKernelCodeGen.cpp | 2 +-
31 IGC/Compiler/CISACodeGen/PatternMatchPass.cpp | 4 +--
32 IGC/Compiler/CISACodeGen/PushAnalysis.cpp | 4 +--
33 .../CISACodeGen/RegisterEstimator.cpp | 3 +-
34 .../CISACodeGen/RegisterPressureEstimate.hpp | 3 +-
35 IGC/Compiler/CISACodeGen/SLMConstProp.cpp | 3 +-
36 .../CISACodeGen/ScalarizerCodeGen.cpp | 4 +--
37 IGC/Compiler/CISACodeGen/ShaderCodeGen.cpp | 4 +++
38 .../CISACodeGen/Simd32Profitability.cpp | 11 ++++--
39 IGC/Compiler/CISACodeGen/SimplifyConstant.cpp | 12 +++----
40 IGC/Compiler/CISACodeGen/TypeDemote.cpp | 3 +-
41 .../CISACodeGen/VariableReuseAnalysis.cpp | 5 +--
42 .../CISACodeGen/VariableReuseAnalysis.hpp | 3 +-
43 IGC/Compiler/CISACodeGen/VectorPreProcess.cpp | 24 ++++++-------
44 IGC/Compiler/CISACodeGen/VectorProcess.cpp | 4 +--
45 IGC/Compiler/CISACodeGen/helper.cpp | 10 +++---
46 IGC/Compiler/ConvertMSAAPayloadTo16Bit.cpp | 15 ++++++--
47 IGC/Compiler/CustomSafeOptPass.cpp | 26 +++++++-------
48 IGC/Compiler/DebugInfo/ScalarVISAModule.cpp | 3 +-
49 IGC/Compiler/GenTTI.cpp | 8 ++++-
50 IGC/Compiler/GenUpdateCB.cpp | 3 +-
51 IGC/Compiler/HandleFRemInstructions.cpp | 3 +-
52 IGC/Compiler/HandleLoadStoreInstructions.cpp | 4 +--
53 IGC/Compiler/LegalizationPass.cpp | 28 +++++++--------
54 IGC/Compiler/Legalizer/InstPromoter.cpp | 11 ++++--
55 IGC/Compiler/Legalizer/InstScalarizer.cpp | 6 ++--
56 .../Legalizer/PeepholeTypeLegalizer.cpp | 6 ++--
57 IGC/Compiler/Legalizer/TypeLegalizer.cpp | 3 +-
58 IGC/Compiler/Legalizer/TypeLegalizer.h | 3 +-
59 IGC/Compiler/LowPrecisionOptPass.cpp | 2 +-
60 .../AddressSpaceAliasAnalysis.cpp | 9 ++---
61 .../AggregateArguments/AggregateArguments.cpp | 3 +-
62 .../CorrectlyRoundedDivSqrt.cpp | 3 +-
63 .../DeviceEnqueueFuncs/TransformBlocks.cpp | 6 +++-
64 .../Optimizer/OpenCLPasses/KernelArgs.cpp | 3 +-
65 .../OpenCLPrintf/OpenCLPrintfResolution.cpp | 4 +--
66 .../PrivateMemory/PrivateMemoryResolution.cpp | 11 ++++--
67 .../ReplaceUnsupportedIntrinsics.cpp | 4 +--
68 .../OpenCLPasses/WIFuncs/WIFuncResolution.cpp | 4 +++
69 .../Optimizer/PreCompiledFuncImport.cpp | 4 +--
70 IGC/Compiler/Optimizer/Scalarizer.cpp | 36 +++++++++----------
71 IGC/Compiler/Optimizer/ValueTracker.cpp | 2 +-
72 IGC/Compiler/VerificationPass.cpp | 2 +-
73 IGC/DebugInfo/DebugInfoUtils.hpp | 4 +++
74 IGC/DebugInfo/DwarfDebug.cpp | 8 +++++
75 IGC/GenISAIntrinsics/GenIntrinsics.cpp | 6 ++--
76 .../BuiltinsFrontendDefinitions.hpp | 2 +-
77 .../include/llvmWrapper/Support/TypeSize.h | 8 ++++-
78 .../include/llvmWrapper/Transforms/Scalar.h | 4 +--
79 IGC/common/igc_resourceDimTypes.h | 5 +++
80 66 files changed, 303 insertions(+), 196 deletions(-)
81
82diff --git a/IGC/AdaptorCommon/LegalizeFunctionSignatures.cpp b/IGC/AdaptorCommon/LegalizeFunctionSignatures.cpp
83index 4046b4a6..8ed36089 100644
84--- a/IGC/AdaptorCommon/LegalizeFunctionSignatures.cpp
85+++ b/IGC/AdaptorCommon/LegalizeFunctionSignatures.cpp
86@@ -156,7 +156,7 @@ inline Type* LegalizedIntVectorType(Module& M, const Type* const oldTy)
87 else if (size <= 64) newSize = 64;
88 else IGC_ASSERT_MESSAGE(0, "Currently don't support upscaling int sizes > 64 bits");
89
90- return IGCLLVM::FixedVectorType::get(IntegerType::get(M.getContext(), newSize), (unsigned)cast<VectorType>(oldTy)->getNumElements());
91+ return IGCLLVM::FixedVectorType::get(IntegerType::get(M.getContext(), newSize), (unsigned)cast<IGCLLVM::FixedVectorType>(oldTy)->getNumElements());
92 }
93
94 void LegalizeFunctionSignatures::FixFunctionSignatures()
95diff --git a/IGC/AdaptorOCL/SPIRV/SPIRVReader.cpp b/IGC/AdaptorOCL/SPIRV/SPIRVReader.cpp
96index 41d1f2ea..725a1512 100644
97--- a/IGC/AdaptorOCL/SPIRV/SPIRVReader.cpp
98+++ b/IGC/AdaptorOCL/SPIRV/SPIRVReader.cpp
99@@ -1576,7 +1576,11 @@ void SPIRVToLLVMDbgTran::transDbgInfo(SPIRVValue *SV, Value *V) {
100 Line->getColumn(), scope, iat);
101
102 if(scope && !isa<DIFile>(scope))
103+#if LLVM_VERSION_MAJOR >= 12
104+ I->setDebugLoc(DILocation::get(scope->getContext(), Line->getLine(), Line->getColumn(),
105+#else
106 I->setDebugLoc(DebugLoc::get(Line->getLine(), Line->getColumn(),
107+#endif
108 scope, iat));
109 }
110 }
111@@ -1925,7 +1929,11 @@ SPIRVToLLVM::transType(SPIRVType *T) {
112 auto name = isSubgroupAvcINTELTypeOpCode(OC) ?
113 OCLSubgroupINTELTypeOpCodeMap::rmap(OC) :
114 BuiltinOpaqueGenericTypeOpCodeMap::rmap(OC);
115+#if LLVM_VERSION_MAJOR >= 12
116+ auto *pST = llvm::StructType::getTypeByName(M->getContext(), name);
117+#else
118 auto *pST = M->getTypeByName(name);
119+#endif
120 pST = pST ? pST : StructType::create(*Context, name);
121
122 return mapType(T, PointerType::get(pST, getOCLOpaqueTypeAddrSpace(OC)));
123@@ -2403,7 +2411,7 @@ Value *SPIRVToLLVM::promoteBool(Value *pVal, BasicBlock *BB)
124
125 auto *PromoType = isa<VectorType>(pVal->getType()) ?
126 cast<Type>(IGCLLVM::FixedVectorType::get(Type::getInt8Ty(pVal->getContext()),
127- (unsigned)cast<VectorType>(pVal->getType())->getNumElements())) :
128+ (unsigned)cast<IGCLLVM::FixedVectorType>(pVal->getType())->getNumElements())) :
129 Type::getInt8Ty(pVal->getContext());
130
131 if (auto *C = dyn_cast<Constant>(pVal))
132@@ -2445,7 +2453,7 @@ Value *SPIRVToLLVM::truncBool(Value *pVal, BasicBlock *BB)
133
134 auto *TruncType = isa<VectorType>(pVal->getType()) ?
135 cast<Type>(IGCLLVM::FixedVectorType::get(Type::getInt1Ty(pVal->getContext()),
136- (unsigned)cast<VectorType>(pVal->getType())->getNumElements())) :
137+ (unsigned)cast<IGCLLVM::FixedVectorType>(pVal->getType())->getNumElements())) :
138 Type::getInt1Ty(pVal->getContext());
139
140 if (auto *C = dyn_cast<Constant>(pVal))
141@@ -2491,7 +2499,7 @@ Type *SPIRVToLLVM::truncBoolType(SPIRVType *SPVType, Type *LLType)
142
143 return isa<VectorType>(LLType) ?
144 cast<Type>(IGCLLVM::FixedVectorType::get(Type::getInt1Ty(LLType->getContext()),
145- (unsigned)cast<VectorType>(LLType)->getNumElements())) :
146+ (unsigned)cast<IGCLLVM::FixedVectorType>(LLType)->getNumElements())) :
147 Type::getInt1Ty(LLType->getContext());
148 }
149
150@@ -2648,7 +2656,7 @@ SPIRVToLLVM::transValueWithoutDecoration(SPIRVValue *BV, Function *F,
151 {
152 if(CV[i]->getType()->isVectorTy())
153 {
154- for(uint32_t j = 0; j < cast<VectorType>(CV[i]->getType())->getNumElements(); j++)
155+ for(uint32_t j = 0; j < cast<IGCLLVM::FixedVectorType>(CV[i]->getType())->getNumElements(); j++)
156 {
157 Value *v = ExtractElementInst::Create( CV[i],ConstantInt::get( *Context,APInt( 32,j ) ),BCC->getName(),BB );
158 elm1 = CreateCompositeConstruct( elm1,v,pos++ );
159@@ -3336,7 +3344,7 @@ SPIRVToLLVM::transValueWithoutDecoration(SPIRVValue *BV, Function *F,
160 auto Vector = transValue(BI->getOperand(0), F, BB);
161 auto Scalar = transValue(BI->getOperand(1), F, BB);
162
163- auto VecType = cast<VectorType>(Vector->getType());
164+ auto VecType = cast<IGCLLVM::FixedVectorType>(Vector->getType());
165 auto Undef = UndefValue::get(VecType);
166
167 auto ScalarVec = InsertElementInst::Create(Undef, Scalar,
168@@ -3361,7 +3369,7 @@ SPIRVToLLVM::transValueWithoutDecoration(SPIRVValue *BV, Function *F,
169 a->getType()->getScalarSizeInBits() - 1);
170 auto *ShiftOp = isa<VectorType>(a->getType()) ?
171 ConstantVector::getSplat(
172- IGCLLVM::getElementCount((unsigned)cast<VectorType>(a->getType())->getNumElements()), ShiftAmt) :
173+ IGCLLVM::getElementCount((unsigned)cast<IGCLLVM::FixedVectorType>(a->getType())->getNumElements()), ShiftAmt) :
174 ShiftAmt;
175
176 // OCL C:
177@@ -3705,15 +3713,15 @@ SPIRVToLLVM::transSPIRVBuiltinFromInst(SPIRVInstruction *BI, BasicBlock *BB) {
178 "",
179 BB);
180 }
181- else if (cast<VectorType>(coordType)->getNumElements() != 4)
182+ else if (cast<IGCLLVM::FixedVectorType>(coordType)->getNumElements() != 4)
183 {
184 Value *undef = UndefValue::get(coordType);
185
186 SmallVector<Constant*, 4> shuffleIdx;
187- for (unsigned i = 0; i < cast<VectorType>(coordType)->getNumElements(); i++)
188+ for (unsigned i = 0; i < cast<IGCLLVM::FixedVectorType>(coordType)->getNumElements(); i++)
189 shuffleIdx.push_back(ConstantInt::get(Type::getInt32Ty(*Context), i));
190
191- for (uint64_t i = (unsigned)cast<VectorType>(coordType)->getNumElements(); i < 4; i++)
192+ for (uint64_t i = (unsigned)cast<IGCLLVM::FixedVectorType>(coordType)->getNumElements(); i < 4; i++)
193 shuffleIdx.push_back(ConstantInt::get(Type::getInt32Ty(*Context), 0));
194
195 imageCoordinateWiden = new ShuffleVectorInst(
196diff --git a/IGC/AdaptorOCL/SPIRV/SPIRVUtil.cpp b/IGC/AdaptorOCL/SPIRV/SPIRVUtil.cpp
197index 57821556..91b4623c 100644
198--- a/IGC/AdaptorOCL/SPIRV/SPIRVUtil.cpp
199+++ b/IGC/AdaptorOCL/SPIRV/SPIRVUtil.cpp
200@@ -93,7 +93,11 @@ saveLLVMModule(Module *M, const std::string &OutputFile) {
201 PointerType*
202 getOrCreateOpaquePtrType(Module *M, const std::string &Name,
203 unsigned AddrSpace) {
204+#if LLVM_VERSION_MAJOR >= 12
205+ auto OpaqueType = llvm::StructType::getTypeByName(M->getContext(), Name);
206+#else
207 auto OpaqueType = M->getTypeByName(Name);
208+#endif
209 if (!OpaqueType)
210 OpaqueType = StructType::create(M->getContext(), Name);
211 return PointerType::get(OpaqueType, AddrSpace);
212@@ -159,7 +163,7 @@ std::string recursive_mangle(const Type* pType)
213 return "i" + utostr(pType->getIntegerBitWidth());
214 case IGCLLVM::VectorTyID:
215 {
216- unsigned vecLen = (unsigned)cast<VectorType>(pType)->getNumElements();
217+ unsigned vecLen = (unsigned)cast<IGCLLVM::FixedVectorType>(pType)->getNumElements();
218 Type* pEltType = cast<VectorType>(pType)->getElementType();
219 return "v" + utostr(vecLen) + recursive_mangle(pEltType);
220 }
221diff --git a/IGC/Compiler/CISACodeGen/AdvMemOpt.cpp b/IGC/Compiler/CISACodeGen/AdvMemOpt.cpp
222index 81acc6ce..fc45a510 100644
223--- a/IGC/Compiler/CISACodeGen/AdvMemOpt.cpp
224+++ b/IGC/Compiler/CISACodeGen/AdvMemOpt.cpp
225@@ -134,7 +134,11 @@ bool AdvMemOpt::runOnFunction(Function& F) {
226 for (auto I = LI->begin(), E = LI->end(); I != E; ++I)
227 for (auto DFI = df_begin(*I), DFE = df_end(*I); DFI != DFE; ++DFI) {
228 Loop* L = *DFI;
229+#if LLVM_VERSION_MAJOR >= 12
230+ if (L->isInnermost())
231+#else
232 if (L->empty())
233+#endif
234 InnermostLoops.push_back(L);
235 }
236
237diff --git a/IGC/Compiler/CISACodeGen/CShader.cpp b/IGC/Compiler/CISACodeGen/CShader.cpp
238index e3cb8153..ebc99615 100644
239--- a/IGC/Compiler/CISACodeGen/CShader.cpp
240+++ b/IGC/Compiler/CISACodeGen/CShader.cpp
241@@ -430,7 +430,7 @@ void CShader::CreateAliasVars()
242 continue;
243
244 Type* Ty = V->getType();
245- VectorType* VTy = dyn_cast<VectorType>(Ty);
246+ IGCLLVM::FixedVectorType* VTy = dyn_cast<IGCLLVM::FixedVectorType>(Ty);
247 Type* BTy = VTy ? VTy->getElementType() : Ty;
248 int nelts = (VTy ? (int)VTy->getNumElements() : 1);
249
250@@ -961,7 +961,7 @@ bool CShader::InsideDivergentCF(llvm::Instruction* inst)
251 uint CShader::GetNbVectorElementAndMask(llvm::Value* val, uint32_t& mask)
252 {
253 llvm::Type* type = val->getType();
254- uint nbElement = int_cast<uint>(cast<VectorType>(type)->getNumElements());
255+ uint nbElement = int_cast<uint>(cast<IGCLLVM::FixedVectorType>(type)->getNumElements());
256 mask = 0;
257 // we don't process vector bigger than 31 elements as the mask has only 32bits
258 // If we want to support longer vectors we need to extend the mask size
259@@ -1166,7 +1166,7 @@ uint32_t CShader::GetExtractMask(llvm::Value* vecVal)
260 {
261 return it->second;
262 }
263- const unsigned int numChannels = vecVal->getType()->isVectorTy() ? (unsigned)cast<VectorType>(vecVal->getType())->getNumElements() : 1;
264+ const unsigned int numChannels = vecVal->getType()->isVectorTy() ? (unsigned)cast<IGCLLVM::FixedVectorType>(vecVal->getType())->getNumElements() : 1;
265 IGC_ASSERT_MESSAGE(numChannels <= 32, "Mask has 32 bits maximally!");
266 return (1ULL << numChannels) - 1;
267 }
268@@ -1174,7 +1174,7 @@ uint32_t CShader::GetExtractMask(llvm::Value* vecVal)
269 uint16_t CShader::AdjustExtractIndex(llvm::Value* vecVal, uint16_t index)
270 {
271 uint16_t result = index;
272- if (cast<VectorType>(vecVal->getType())->getNumElements() < 32)
273+ if (cast<IGCLLVM::FixedVectorType>(vecVal->getType())->getNumElements() < 32)
274 {
275 uint32_t mask = GetExtractMask(vecVal);
276 for (uint i = 0; i < index; ++i)
277@@ -1591,7 +1591,7 @@ auto sizeToSIMDMode = [](uint32_t size)
278
279 CVariable* CShader::GetConstant(llvm::Constant* C, CVariable* dstVar)
280 {
281- llvm::VectorType* VTy = llvm::dyn_cast<llvm::VectorType>(C->getType());
282+ IGCLLVM::FixedVectorType* VTy = llvm::dyn_cast<IGCLLVM::FixedVectorType>(C->getType());
283 if (C && VTy)
284 { // Vector constant
285 llvm::Type* eTy = VTy->getElementType();
286@@ -1816,7 +1816,7 @@ uint32_t CShader::GetNumElts(llvm::Type* type, bool isUniform)
287 {
288 IGC_ASSERT(type->getContainedType(0)->isIntegerTy() || type->getContainedType(0)->isFloatingPointTy());
289
290- auto VT = cast<VectorType>(type);
291+ auto VT = cast<IGCLLVM::FixedVectorType>(type);
292 numElts *= (uint16_t)VT->getNumElements();
293 }
294 return numElts;
295@@ -2516,7 +2516,7 @@ CVariable* CShader::GetSymbol(llvm::Value* value, bool fromConstantPool)
296 if (isVecType)
297 {
298 // Map the entire vector value to the CVar
299- unsigned numElements = (unsigned)cast<VectorType>(value->getType())->getNumElements();
300+ unsigned numElements = (unsigned)cast<IGCLLVM::FixedVectorType>(value->getType())->getNumElements();
301 var = GetNewVariable(numElements, ISA_TYPE_UQ, (GetContext()->platform.getGRFSize() == 64) ? EALIGN_32WORD : EALIGN_HWORD, true, 1, valName);
302 symbolMapping.insert(std::pair<llvm::Value*, CVariable*>(value, var));
303
304diff --git a/IGC/Compiler/CISACodeGen/ConstantCoalescing.cpp b/IGC/Compiler/CISACodeGen/ConstantCoalescing.cpp
305index 1efe116f..47b7c6c0 100644
306--- a/IGC/Compiler/CISACodeGen/ConstantCoalescing.cpp
307+++ b/IGC/Compiler/CISACodeGen/ConstantCoalescing.cpp
308@@ -224,7 +224,7 @@ static void checkInsertExtractMatch(InsertElementInst* insertInst, Value* base,
309
310 static bool canReplaceInsert(InsertElementInst* insertElt)
311 {
312- VectorType* VTy = cast<VectorType>(insertElt->getOperand(0)->getType());
313+ IGCLLVM::FixedVectorType* VTy = cast<IGCLLVM::FixedVectorType>(insertElt->getOperand(0)->getType());
314 ConstantInt* index = dyn_cast<ConstantInt>(insertElt->getOperand(2));
315 if (!index || index->getZExtValue() != VTy->getNumElements() - 1)
316 {
317@@ -312,7 +312,7 @@ void ConstantCoalescing::VectorizePrep(llvm::BasicBlock* bb)
318 {
319 if (load->getType()->isVectorTy() && wiAns->isUniform(load))
320 {
321- srcNElts = (uint32_t)cast<VectorType>(load->getType())->getNumElements();
322+ srcNElts = (uint32_t)cast<IGCLLVM::FixedVectorType>(load->getType())->getNumElements();
323 DenseMap<uint64_t, Instruction*> extractElementMap;
324
325 for (auto iter = load->user_begin(); iter != load->user_end(); iter++)
326@@ -396,7 +396,7 @@ bool ConstantCoalescing::isProfitableLoad(
327 (isa<LoadInst>(I) && wiAns->isUniform(I)) ?
328 16 : 4;
329
330- if (cast<VectorType>(LoadTy)->getNumElements() > MaxVectorInput)
331+ if (cast<IGCLLVM::FixedVectorType>(LoadTy)->getNumElements() > MaxVectorInput)
332 return false;
333
334 MaxEltPlus = CheckVectorElementUses(I);
335@@ -1787,7 +1787,7 @@ void ConstantCoalescing::AdjustChunk(BufChunk* cov_chunk, uint start_adj, uint s
336 WIAnalysis::WIDependancy loadDep = wiAns->whichDepend(cov_chunk->chunkIO);
337 irBuilder->SetInsertPoint(cov_chunk->chunkIO->getNextNode());
338 Value* vec = UndefValue::get(originalType);
339- for (unsigned i = 0; i < cast<VectorType>(originalType)->getNumElements(); i++)
340+ for (unsigned i = 0; i < cast<IGCLLVM::FixedVectorType>(originalType)->getNumElements(); i++)
341 {
342 Value* channel = irBuilder->CreateExtractElement(
343 cov_chunk->chunkIO, irBuilder->getInt32(i + start_adj));
344@@ -1851,7 +1851,7 @@ void ConstantCoalescing::MoveExtracts(BufChunk* cov_chunk, Instruction* load, ui
345 irBuilder->SetInsertPoint(load->getNextNode());
346 Type* vecType = load->getType();
347 Value* vec = UndefValue::get(vecType);
348- for (unsigned i = 0; i < cast<VectorType>(vecType)->getNumElements(); i++)
349+ for (unsigned i = 0; i < cast<IGCLLVM::FixedVectorType>(vecType)->getNumElements(); i++)
350 {
351 Value* channel = irBuilder->CreateExtractElement(
352 cov_chunk->chunkIO, irBuilder->getInt32(i + start_adj));
353@@ -1915,7 +1915,7 @@ void ConstantCoalescing::EnlargeChunk(BufChunk* cov_chunk, uint size_adj)
354 WIAnalysis::WIDependancy loadDep = wiAns->whichDepend(cov_chunk->chunkIO);
355 irBuilder->SetInsertPoint(cov_chunk->chunkIO->getNextNode());
356 Value* vec = UndefValue::get(originalType);
357- for (unsigned i = 0; i < cast<VectorType>(originalType)->getNumElements(); i++)
358+ for (unsigned i = 0; i < cast<IGCLLVM::FixedVectorType>(originalType)->getNumElements(); i++)
359 {
360 Value* channel = irBuilder->CreateExtractElement(
361 cov_chunk->chunkIO, irBuilder->getInt32(i));
362@@ -2343,7 +2343,7 @@ void ConstantCoalescing::ReplaceLoadWithSamplerLoad(
363 if (dstTy->isVectorTy())
364 {
365 result = UndefValue::get(dstTy);
366- for (uint i = 0; i < cast<VectorType>(dstTy)->getNumElements(); i++)
367+ for (uint i = 0; i < cast<IGCLLVM::FixedVectorType>(dstTy)->getNumElements(); i++)
368 {
369 Value* tmpData = ExtractFromSamplerData(cast<VectorType>(dstTy)->getElementType(), i);
370 result = irBuilder->CreateInsertElement(result, tmpData, irBuilder->getInt32(i));
371diff --git a/IGC/Compiler/CISACodeGen/DeSSA.cpp b/IGC/Compiler/CISACodeGen/DeSSA.cpp
372index f540dc11..6fab0246 100644
373--- a/IGC/Compiler/CISACodeGen/DeSSA.cpp
374+++ b/IGC/Compiler/CISACodeGen/DeSSA.cpp
375@@ -83,6 +83,7 @@ IN THE SOFTWARE.
376 #include "Compiler/IGCPassSupport.h"
377 #include "common/LLVMWarningsPush.hpp"
378 #include <llvm/IR/InstIterator.h>
379+#include <llvmWrapper/IR/DerivedTypes.h>
380 #include "common/LLVMWarningsPop.hpp"
381 #include <algorithm>
382 #include "Probe/Assertion.h"
383@@ -1284,7 +1285,7 @@ int DeSSA::checkInsertElementAlias(
384 //
385 // If found, return the actual vector size;
386 // otherwise, return 0.
387- VectorType* VTy = cast<VectorType>(IEI->getType());
388+ IGCLLVM::FixedVectorType* VTy = cast<IGCLLVM::FixedVectorType>(IEI->getType());
389 IGC_ASSERT(nullptr != VTy);
390 int nelts = (int)VTy->getNumElements();
391 AllIEIs.resize(nelts, nullptr);
392diff --git a/IGC/Compiler/CISACodeGen/EmitVISAPass.cpp b/IGC/Compiler/CISACodeGen/EmitVISAPass.cpp
393index 3ab1cc5f..4502ef62 100644
394--- a/IGC/Compiler/CISACodeGen/EmitVISAPass.cpp
395+++ b/IGC/Compiler/CISACodeGen/EmitVISAPass.cpp
396@@ -53,6 +53,7 @@ IN THE SOFTWARE.
397 #include "Compiler/IGCPassSupport.h"
398 #include "common/LLVMWarningsPush.hpp"
399 #include "llvmWrapper/IR/Instructions.h"
400+#include "llvmWrapper/IR/DerivedTypes.h"
401 #include "llvm/Support/Path.h"
402 #include "llvmWrapper/IR/Intrinsics.h"
403 #include "common/LLVMWarningsPop.hpp"
404@@ -1165,7 +1166,7 @@ bool EmitPass::canRelocatePhiMov(
405 if (dst != src)
406 {
407 int numElt = 1;
408- if (VectorType * vTy = dyn_cast<VectorType>(PN->getType()))
409+ if (IGCLLVM::FixedVectorType * vTy = dyn_cast<IGCLLVM::FixedVectorType>(PN->getType()))
410 {
411 numElt = int_cast<int>(vTy->getNumElements());
412 }
413@@ -1302,7 +1303,7 @@ void EmitPass::MovPhiSources(llvm::BasicBlock* aBB)
414 phiSrcDstList.push_back(phiInfo);
415
416 int numElt = 0;
417- if (VectorType * vTy = dyn_cast<VectorType>(PN->getType()))
418+ if (IGCLLVM::FixedVectorType * vTy = dyn_cast<IGCLLVM::FixedVectorType>(PN->getType()))
419 {
420 numElt = int_cast<int>(vTy->getNumElements());
421 }
422@@ -5375,7 +5376,7 @@ void EmitPass::emitLegacySimdBlockWrite(llvm::Instruction* inst, llvm::Value* pt
423 bool useA64 = isA64Ptr(ptrType, m_currShader->GetContext());
424
425 Type* Ty = dataPtr->getType();
426- VectorType* VTy = dyn_cast<VectorType>(Ty);
427+ IGCLLVM::FixedVectorType* VTy = dyn_cast<IGCLLVM::FixedVectorType>(Ty);
428 uint32_t nbElements = VTy ? int_cast<uint32_t>(VTy->getNumElements()) : 1;
429
430 uint32_t typeSizeInBytes = Ty->getScalarSizeInBits() / 8;
431@@ -5621,7 +5622,7 @@ void EmitPass::emitLegacySimdBlockRead(llvm::Instruction* inst, llvm::Value* ptr
432 bool useA64 = isA64Ptr(ptrType, m_currShader->GetContext());
433
434 Type* Ty = inst->getType();
435- VectorType* VTy = dyn_cast<VectorType>(Ty);
436+ IGCLLVM::FixedVectorType* VTy = dyn_cast<IGCLLVM::FixedVectorType>(Ty);
437 uint32_t nbElements = VTy ? int_cast<uint32_t>(VTy->getNumElements()) : 1;
438
439 uint32_t typeSizeInBytes = Ty->getScalarSizeInBits() / 8;
440@@ -5913,7 +5914,7 @@ void EmitPass::emitMediaBlockIO(const llvm::GenIntrinsicInst* inst, bool isRead)
441 };
442
443 uint nElts = isa<VectorType>(pDataType) ?
444- (uint)cast<VectorType>(pDataType)->getNumElements() :
445+ (uint)cast<IGCLLVM::FixedVectorType>(pDataType)->getNumElements() :
446 1;
447
448 // Now, do the copies.
449@@ -6003,7 +6004,7 @@ void EmitPass::emitSimdMediaBlockRead(llvm::Instruction* inst)
450 uint32_t nbElements = 1;
451 if (inst->getType()->isVectorTy())
452 {
453- nbElements = (uint32_t)cast<VectorType>(inst->getType())->getNumElements();
454+ nbElements = (uint32_t)cast<IGCLLVM::FixedVectorType>(inst->getType())->getNumElements();
455 }
456 IGC_ASSERT_MESSAGE(nbElements <= 8, "InValid Vector Size");
457
458@@ -6247,7 +6248,7 @@ void EmitPass::emitSimdMediaBlockWrite(llvm::Instruction* inst)
459 uint32_t nbElements = 1;
460 if (dataPtr->getType()->isVectorTy())
461 {
462- nbElements = (uint32_t)cast<VectorType>(dataPtr->getType())->getNumElements();
463+ nbElements = (uint32_t)cast<IGCLLVM::FixedVectorType>(dataPtr->getType())->getNumElements();
464 }
465 IGC_ASSERT_MESSAGE(nbElements <= 8, "InValid Vector Size");
466
467@@ -8993,8 +8994,8 @@ void EmitPass::emitBitCast(llvm::BitCastInst* btCst)
468 {
469 Type* srcType = btCst->getOperand(0)->getType();
470 Type* dstType = btCst->getType();
471- unsigned int numSrcElement = srcType->isVectorTy() ? (unsigned)cast<VectorType>(srcType)->getNumElements() : 1;
472- unsigned int numDstElement = dstType->isVectorTy() ? (unsigned)cast<VectorType>(dstType)->getNumElements() : 1;
473+ unsigned int numSrcElement = srcType->isVectorTy() ? (unsigned)cast<IGCLLVM::FixedVectorType>(srcType)->getNumElements() : 1;
474+ unsigned int numDstElement = dstType->isVectorTy() ? (unsigned)cast<IGCLLVM::FixedVectorType>(dstType)->getNumElements() : 1;
475
476 if (srcType->isPointerTy())
477 {
478@@ -9468,7 +9469,7 @@ void EmitPass::emitLoad3DInner(LdRawIntrinsic* inst, ResourceDescriptor& resourc
479 {
480 IGC_ASSERT_MESSAGE(predDefSurface != ESURFACE_STATELESS, "scratch cannot be uniform");
481 Type* loadType = inst->getType();
482- uint numElement = loadType->isVectorTy() ? (uint)cast<VectorType>(loadType)->getNumElements() : 1;
483+ uint numElement = loadType->isVectorTy() ? (uint)cast<IGCLLVM::FixedVectorType>(loadType)->getNumElements() : 1;
484 if (predDefSurface == ESURFACE_SLM)
485 {
486 IGC_ASSERT(numElement <= 4);
487@@ -10795,7 +10796,7 @@ void EmitPass::emitInsert(llvm::Instruction* inst)
488 pVecVar = GetSymbol(pVec);
489 if (pVecVar != pInstVar)
490 {
491- emitVectorCopy(pInstVar, pVecVar, int_cast<unsigned>(dyn_cast<VectorType>(pVecType)->getNumElements()));
492+ emitVectorCopy(pInstVar, pVecVar, int_cast<unsigned>(dyn_cast<IGCLLVM::FixedVectorType>(pVecType)->getNumElements()));
493 }
494 }
495 }
496@@ -14596,7 +14597,7 @@ bool EmitPass::isUniformStoreOCL(llvm::StoreInst* SI)
497
498 Value* storeVal = SI->getValueOperand();
499 Type* Ty = storeVal->getType();
500- VectorType* VTy = dyn_cast<VectorType>(Ty);
501+ IGCLLVM::FixedVectorType* VTy = dyn_cast<IGCLLVM::FixedVectorType>(Ty);
502 uint32_t elts = VTy ? int_cast<uint32_t>(VTy->getNumElements()) : 1;
503 Type* eltTy = VTy ? VTy->getElementType() : Ty;
504
505@@ -14626,7 +14627,7 @@ void EmitPass::emitVectorBitCast(llvm::BitCastInst* BCI)
506 if (srcTy->isVectorTy())
507 {
508 srcEltTy = cast<VectorType>(srcTy)->getElementType();
509- srcNElts = (uint32_t)cast<VectorType>(srcTy)->getNumElements();
510+ srcNElts = (uint32_t)cast<IGCLLVM::FixedVectorType>(srcTy)->getNumElements();
511 }
512 else
513 {
514@@ -14636,7 +14637,7 @@ void EmitPass::emitVectorBitCast(llvm::BitCastInst* BCI)
515 if (dstTy->isVectorTy())
516 {
517 dstEltTy = cast<VectorType>(dstTy)->getElementType();
518- dstNElts = (uint32_t)cast<VectorType>(dstTy)->getNumElements();
519+ dstNElts = (uint32_t)cast<IGCLLVM::FixedVectorType>(dstTy)->getNumElements();
520 }
521 else
522 {
523@@ -15215,7 +15216,7 @@ void EmitPass::emitVectorLoad(LoadInst* inst, Value* offset, ConstantInt* immOff
524 }
525
526 Type* Ty = inst->getType();
527- VectorType* VTy = dyn_cast<VectorType>(Ty);
528+ IGCLLVM::FixedVectorType* VTy = dyn_cast<IGCLLVM::FixedVectorType>(Ty);
529 Type* eltTy = VTy ? VTy->getElementType() : Ty;
530 uint32_t eltBytes = GetScalarTypeSizeInRegister(eltTy);
531 IGC_ASSERT_MESSAGE((eltBytes == 1) || (eltBytes == 2) || (eltBytes == 4) || (eltBytes == 8),
532@@ -15667,7 +15668,7 @@ void EmitPass::emitVectorStore(StoreInst* inst, Value* offset, ConstantInt* immO
533
534 Value* storedVal = inst->getValueOperand();
535 Type* Ty = storedVal->getType();
536- VectorType* VTy = dyn_cast<VectorType>(Ty);
537+ IGCLLVM::FixedVectorType* VTy = dyn_cast<IGCLLVM::FixedVectorType>(Ty);
538 Type* eltTy = VTy ? VTy->getElementType() : Ty;
539 uint32_t eltBytes = GetScalarTypeSizeInRegister(eltTy);
540
541@@ -16471,7 +16472,7 @@ void EmitPass::emitCopyAll(CVariable* Dst, CVariable* Src, llvm::Type* Ty)
542 }
543 else if (Ty->isVectorTy())
544 {
545- unsigned NElts = (unsigned)cast<VectorType>(Ty)->getNumElements();
546+ unsigned NElts = (unsigned)cast<IGCLLVM::FixedVectorType>(Ty)->getNumElements();
547 emitVectorCopy(Dst, Src, NElts);
548 }
549 else
550diff --git a/IGC/Compiler/CISACodeGen/Emu64OpsPass.cpp b/IGC/Compiler/CISACodeGen/Emu64OpsPass.cpp
551index 28248f30..767b477a 100644
552--- a/IGC/Compiler/CISACodeGen/Emu64OpsPass.cpp
553+++ b/IGC/Compiler/CISACodeGen/Emu64OpsPass.cpp
554@@ -1961,7 +1961,7 @@ bool InstExpander::visitExtractElement(ExtractElementInst& EEI) {
555 // later.
556
557 Value* V = EEI.getVectorOperand();
558- unsigned NumElts = (unsigned)cast<VectorType>(V->getType())->getNumElements();
559+ unsigned NumElts = (unsigned)cast<IGCLLVM::FixedVectorType>(V->getType())->getNumElements();
560 V = IRB->CreateBitCast(V, Emu->getV2Int32Ty(NumElts));
561 // Re-calculate indices to Lo and Hi parts.
562 Value* Idx = EEI.getIndexOperand();
563@@ -1998,7 +1998,7 @@ bool InstExpander::visitInsertElement(InsertElementInst& IEI) {
564
565 // Create the emulated vector.
566 Value* NewVal = IEI.getOperand(0);
567- unsigned NumElts = (unsigned)cast<VectorType>(NewVal->getType())->getNumElements();
568+ unsigned NumElts = (unsigned)cast<IGCLLVM::FixedVectorType>(NewVal->getType())->getNumElements();
569 NewVal = IRB->CreateBitCast(NewVal, Emu->getV2Int32Ty(NumElts));
570 // Re-calculate indices to Lo and Hi parts.
571 Value* Idx = IEI.getOperand(2);
572diff --git a/IGC/Compiler/CISACodeGen/GenIRLowering.cpp b/IGC/Compiler/CISACodeGen/GenIRLowering.cpp
573index c74a2ac6..78e8a4aa 100644
574--- a/IGC/Compiler/CISACodeGen/GenIRLowering.cpp
575+++ b/IGC/Compiler/CISACodeGen/GenIRLowering.cpp
576@@ -453,7 +453,7 @@ Value* GEPLowering::getSExtOrTrunc(Value* Val, Type* NewTy) const {
577
578 IGC_ASSERT_MESSAGE(OldTy->isIntOrIntVectorTy(), "Index should be Integer or vector of Integer!");
579
580- if (auto OldVecTy = dyn_cast<VectorType>(OldTy)) {
581+ if (auto OldVecTy = dyn_cast<IGCLLVM::FixedVectorType>(OldTy)) {
582 OldWidth = (unsigned)OldVecTy->getNumElements() * OldVecTy->getElementType()->getIntegerBitWidth();
583 NewWidth = (unsigned)OldVecTy->getNumElements() * NewTy->getIntegerBitWidth();
584 }
585@@ -805,7 +805,7 @@ bool GEPLowering::lowerGetElementPtrInst(GetElementPtrInst* GEP) const
586 }
587 else
588 {
589- if (auto NewIdxVT = dyn_cast<VectorType>(NewIdx->getType())) {
590+ if (auto NewIdxVT = dyn_cast<IGCLLVM::FixedVectorType>(NewIdx->getType())) {
591 Value* result = llvm::UndefValue::get(FixedVectorType::get(PtrMathTy, (unsigned)NewIdxVT->getNumElements()));
592 for (uint32_t j = 0; j < (uint32_t)NewIdxVT->getNumElements(); j++) {
593 result = Builder->CreateInsertElement(result, PointerValue, Builder->getInt32(j));
594diff --git a/IGC/Compiler/CISACodeGen/GenSimplification.cpp b/IGC/Compiler/CISACodeGen/GenSimplification.cpp
595index 8c38f229..f432061e 100644
596--- a/IGC/Compiler/CISACodeGen/GenSimplification.cpp
597+++ b/IGC/Compiler/CISACodeGen/GenSimplification.cpp
598@@ -35,6 +35,7 @@ IN THE SOFTWARE.
599 #include <llvm/IR/InstVisitor.h>
600 #include <llvm/IR/Instruction.h>
601 #include <llvm/Support/raw_ostream.h>
602+#include <llvmWrapper/IR/DerivedTypes.h>
603 #include "common/LLVMWarningsPop.hpp"
604 #include "Probe/Assertion.h"
605
606@@ -164,7 +165,7 @@ bool GenSimplification::simplifyVectorPHINodeCase2(PHINode& PN) const {
607
608 Type* Ty = PN.getType();
609 Type* EltTy = Ty->getScalarType();
610- unsigned NumElts = (unsigned)cast<VectorType>(Ty)->getNumElements();
611+ unsigned NumElts = (unsigned)cast<IGCLLVM::FixedVectorType>(Ty)->getNumElements();
612
613 SmallVector<Value*, 8> Lanes;
614 SmallVector<SmallVector<Value*, 8>, 4> Values;
615@@ -238,7 +239,7 @@ void GenSimplification::visitPHINode(PHINode& PN) {
616 void GenSimplification::visitExtractElement(ExtractElementInst& EEI) {
617 // Skip non-2-element vector.
618 Value* Vec = EEI.getVectorOperand();
619- VectorType* VTy = cast<VectorType>(Vec->getType());
620+ IGCLLVM::FixedVectorType* VTy = cast<IGCLLVM::FixedVectorType>(Vec->getType());
621 if (VTy->getNumElements() != 2)
622 return;
623
624diff --git a/IGC/Compiler/CISACodeGen/GeometryShaderLowering.cpp b/IGC/Compiler/CISACodeGen/GeometryShaderLowering.cpp
625index e00e8469..a60b9892 100644
626--- a/IGC/Compiler/CISACodeGen/GeometryShaderLowering.cpp
627+++ b/IGC/Compiler/CISACodeGen/GeometryShaderLowering.cpp
628@@ -33,6 +33,7 @@ IN THE SOFTWARE.
629 #include <llvm/IR/PassManager.h>
630 #include <llvm/IR/IRBuilder.h>
631 #include <llvm/IR/Verifier.h>
632+#include <llvmWrapper/IR/DerivedTypes.h>
633 #include "common/LLVMWarningsPop.hpp"
634 #include "Compiler/InitializePasses.h"
635 #include "Probe/Assertion.h"
636@@ -507,7 +508,7 @@ void GeometryShaderLowering::AddURBRead(
637 {
638 Value* vec = UndefValue::get(inst->getType());
639 IRBuilder<> builder(inst);
640- for (unsigned int i = 0; i < cast<VectorType>(inst->getType())->getNumElements(); i++)
641+ for (unsigned int i = 0; i < cast<IGCLLVM::FixedVectorType>(inst->getType())->getNumElements(); i++)
642 {
643 Value* vecElement = builder.CreateExtractElement(urbRead, builder.getInt32(i));
644 vec = builder.CreateInsertElement(vec, vecElement, builder.getInt32(i));
645diff --git a/IGC/Compiler/CISACodeGen/LdShrink.cpp b/IGC/Compiler/CISACodeGen/LdShrink.cpp
646index d89fbd0e..2df06df2 100644
647--- a/IGC/Compiler/CISACodeGen/LdShrink.cpp
648+++ b/IGC/Compiler/CISACodeGen/LdShrink.cpp
649@@ -30,6 +30,7 @@ IN THE SOFTWARE.
650 #include <llvm/Support/Debug.h>
651 #include <llvm/Support/MathExtras.h>
652 #include <llvm/Support/raw_ostream.h>
653+#include <llvmWrapper/IR/DerivedTypes.h>
654 #include "common/LLVMWarningsPop.hpp"
655 #include "Compiler/CISACodeGen/ShaderCodeGen.hpp"
656 #include "Compiler/IGCPassSupport.h"
657@@ -79,7 +80,7 @@ IGC_INITIALIZE_PASS_BEGIN(LdShrink, PASS_FLAG, PASS_DESC, PASS_CFG_ONLY, PASS_AN
658 IGC_INITIALIZE_PASS_END(LdShrink, PASS_FLAG, PASS_DESC, PASS_CFG_ONLY, PASS_ANALYSIS)
659
660 unsigned LdShrink::getExtractIndexMask(LoadInst* LI) const {
661- VectorType* VTy = dyn_cast<VectorType>(LI->getType());
662+ IGCLLVM::FixedVectorType* VTy = dyn_cast<IGCLLVM::FixedVectorType>(LI->getType());
663 // Skip non-vector loads.
664 if (!VTy)
665 return 0;
666@@ -91,9 +92,12 @@ unsigned LdShrink::getExtractIndexMask(LoadInst* LI) const {
667 Type* Ty = VTy->getScalarType();
668 // Skip non-BYTE addressable data types. So far, check integer types
669 // only.
670- if (IntegerType * ITy = dyn_cast<IntegerType>(Ty))
671- if (!ITy->isPowerOf2ByteWidth())
672+ if (IntegerType * ITy = dyn_cast<IntegerType>(Ty)) {
673+ // Unroll isPowerOf2ByteWidth, it was removed in LLVM 12.
674+ unsigned BitWidth = ITy->getBitWidth();
675+ if (!((BitWidth > 7) && isPowerOf2_32(BitWidth)))
676 return 0;
677+ }
678
679 unsigned Mask = 0; // Maxmimally 32 elements.
680
681diff --git a/IGC/Compiler/CISACodeGen/LowerGEPForPrivMem.cpp b/IGC/Compiler/CISACodeGen/LowerGEPForPrivMem.cpp
682index c12b20d5..5245117d 100644
683--- a/IGC/Compiler/CISACodeGen/LowerGEPForPrivMem.cpp
684+++ b/IGC/Compiler/CISACodeGen/LowerGEPForPrivMem.cpp
685@@ -634,7 +634,7 @@ void TransposeHelper::handleGEPInst(
686 }
687 else
688 {
689- arr_sz = (unsigned)cast<VectorType>(T)->getNumElements();
690+ arr_sz = (unsigned)cast<IGCLLVM::FixedVectorType>(T)->getNumElements();
691 }
692 T = cast<VectorType>(T)->getElementType();
693 }
694@@ -656,7 +656,7 @@ void TransposeHelper::handleGEPInst(
695 }
696 else if (T->isVectorTy())
697 {
698- arr_sz = (unsigned)cast<VectorType>(T)->getNumElements();
699+ arr_sz = (unsigned)cast<IGCLLVM::FixedVectorType>(T)->getNumElements();
700 T = cast<VectorType>(T)->getElementType();
701 }
702 else
703@@ -716,7 +716,7 @@ void TransposeHelperPromote::handleLoadInst(
704 IRBuilder<> IRB(pLoad);
705 IGC_ASSERT(nullptr != pLoad->getType());
706 unsigned N = pLoad->getType()->isVectorTy()
707- ? (unsigned)cast<VectorType>(pLoad->getType())->getNumElements()
708+ ? (unsigned)cast<IGCLLVM::FixedVectorType>(pLoad->getType())->getNumElements()
709 : 1;
710 Value* Val = loadEltsFromVecAlloca(N, pVecAlloca, pScalarizedIdx, IRB, pLoad->getType()->getScalarType());
711 pLoad->replaceAllUsesWith(Val);
712@@ -748,7 +748,7 @@ void TransposeHelperPromote::handleStoreInst(
713 // %v1 = extractelement <2 x float> %v, i32 1
714 // %w1 = insertelement <32 x float> %w0, float %v1, i32 %idx+1
715 // store <32 x float> %w1, <32 x float>* %ptr1
716- for (unsigned i = 0, e = (unsigned)cast<VectorType>(pStoreVal->getType())->getNumElements(); i < e; ++i)
717+ for (unsigned i = 0, e = (unsigned)cast<IGCLLVM::FixedVectorType>(pStoreVal->getType())->getNumElements(); i < e; ++i)
718 {
719 Value* VectorIdx = ConstantInt::get(pScalarizedIdx->getType(), i);
720 auto Val = IRB.CreateExtractElement(pStoreVal, VectorIdx);
721diff --git a/IGC/Compiler/CISACodeGen/MemOpt.cpp b/IGC/Compiler/CISACodeGen/MemOpt.cpp
722index e4279cca..aa788b11 100644
723--- a/IGC/Compiler/CISACodeGen/MemOpt.cpp
724+++ b/IGC/Compiler/CISACodeGen/MemOpt.cpp
725@@ -125,7 +125,7 @@ namespace {
726 MemRefListTy& MemRefs, TrivialMemRefListTy& ToOpt);
727
728 unsigned getNumElements(Type* Ty) const {
729- return Ty->isVectorTy() ? (unsigned)cast<VectorType>(Ty)->getNumElements() : 1;
730+ return Ty->isVectorTy() ? (unsigned)cast<IGCLLVM::FixedVectorType>(Ty)->getNumElements() : 1;
731 }
732
733 MemoryLocation getLocation(Instruction* I) const {
734@@ -797,7 +797,7 @@ bool MemOpt::mergeLoad(LoadInst* LeadingLoad,
735 Pos = unsigned((std::get<1>(I) - FirstOffset) / LdScalarSize);
736
737 if (Ty->isVectorTy()) {
738- if (Pos + cast<VectorType>(Ty)->getNumElements() > NumElts) {
739+ if (Pos + cast<IGCLLVM::FixedVectorType>(Ty)->getNumElements() > NumElts) {
740 // This implies we're trying to extract an element from our new load
741 // with an index > the size of the new load. If this happens,
742 // we'll generate correct code if it does since we don't remove the
743@@ -805,7 +805,7 @@ bool MemOpt::mergeLoad(LoadInst* LeadingLoad,
744 continue;
745 }
746 Value* Val = UndefValue::get(Ty);
747- for (unsigned i = 0, e = (unsigned)cast<VectorType>(Ty)->getNumElements(); i != e; ++i) {
748+ for (unsigned i = 0, e = (unsigned)cast<IGCLLVM::FixedVectorType>(Ty)->getNumElements(); i != e; ++i) {
749 Value* Ex = Builder.CreateExtractElement(NewLoad, Builder.getInt32(Pos + i));
750 Ex = createBitOrPointerCast(Ex, ScalarTy, Builder);
751 Val = Builder.CreateInsertElement(Val, Ex, Builder.getInt32(i));
752@@ -1083,7 +1083,7 @@ bool MemOpt::mergeStore(StoreInst* LeadingStore,
753 IGC_ASSERT(hasSameSize(ScalarTy, LeadingStoreScalarType));
754
755 if (Ty->isVectorTy()) {
756- for (unsigned i = 0, e = (unsigned)cast<VectorType>(Ty)->getNumElements(); i != e; ++i) {
757+ for (unsigned i = 0, e = (unsigned)cast<IGCLLVM::FixedVectorType>(Ty)->getNumElements(); i != e; ++i) {
758 Value* Ex = Builder.CreateExtractElement(Val, Builder.getInt32(i));
759 Ex = createBitOrPointerCast(Ex, LeadingStoreScalarType, Builder);
760 NewStoreVal = Builder.CreateInsertElement(NewStoreVal, Ex,
761diff --git a/IGC/Compiler/CISACodeGen/MemOpt2.cpp b/IGC/Compiler/CISACodeGen/MemOpt2.cpp
762index 4b2628d2..20115c73 100644
763--- a/IGC/Compiler/CISACodeGen/MemOpt2.cpp
764+++ b/IGC/Compiler/CISACodeGen/MemOpt2.cpp
765@@ -32,6 +32,7 @@ IN THE SOFTWARE.
766 #include <llvm/Support/Debug.h>
767 #include <llvm/Support/raw_ostream.h>
768 #include <llvm/Transforms/Utils/Local.h>
769+#include <llvmWrapper/IR/DerivedTypes.h>
770 #include "common/LLVMWarningsPop.hpp"
771 #include "GenISAIntrinsics/GenIntrinsics.h"
772
773@@ -124,7 +125,7 @@ namespace {
774 if (!Ty->isSingleValueType())
775 return UINT_MAX;
776 // Simply return 1 so far for scalar types.
777- VectorType* VecTy = dyn_cast<VectorType>(Ty);
778+ IGCLLVM::FixedVectorType* VecTy = dyn_cast<IGCLLVM::FixedVectorType>(Ty);
779 if (!VecTy)
780 return 1;
781 // Check how that vector is used.
782@@ -153,7 +154,7 @@ namespace {
783 return UINT_MAX;
784 unsigned EltByte = (Ty->getScalarSizeInBits() + 7) / 8;
785 // Simply return 1 so far for scalar types.
786- VectorType* VecTy = dyn_cast<VectorType>(Ty);
787+ IGCLLVM::FixedVectorType* VecTy = dyn_cast<IGCLLVM::FixedVectorType>(Ty);
788 if (!VecTy)
789 return EltByte;
790 // Check how that vector is used.
791diff --git a/IGC/Compiler/CISACodeGen/OpenCLKernelCodeGen.cpp b/IGC/Compiler/CISACodeGen/OpenCLKernelCodeGen.cpp
792index 5baff64f..032d127a 100644
793--- a/IGC/Compiler/CISACodeGen/OpenCLKernelCodeGen.cpp
794+++ b/IGC/Compiler/CISACodeGen/OpenCLKernelCodeGen.cpp
795@@ -410,7 +410,7 @@ namespace IGC
796 unsigned int numElements = 1;
797 if (baseType->isVectorTy())
798 {
799- numElements = (unsigned)cast<VectorType>(baseType)->getNumElements();
800+ numElements = (unsigned)cast<IGCLLVM::FixedVectorType>(baseType)->getNumElements();
801 baseType = cast<VectorType>(baseType)->getElementType();
802 }
803
804diff --git a/IGC/Compiler/CISACodeGen/PatternMatchPass.cpp b/IGC/Compiler/CISACodeGen/PatternMatchPass.cpp
805index 356f1141..52396304 100644
806--- a/IGC/Compiler/CISACodeGen/PatternMatchPass.cpp
807+++ b/IGC/Compiler/CISACodeGen/PatternMatchPass.cpp
808@@ -2916,8 +2916,8 @@ namespace IGC
809 llvm::Type* srcTy = bTInst->getOperand(0)->getType();
810 llvm::Type* dstTy = bTInst->getType();
811
812- srcNElts = (srcTy->isVectorTy()) ? (uint32_t)cast<VectorType>(srcTy)->getNumElements() : 1;
813- dstNElts = (dstTy->isVectorTy()) ? (uint32_t)cast<VectorType>(dstTy)->getNumElements() : 1;
814+ srcNElts = (srcTy->isVectorTy()) ? (uint32_t)cast<IGCLLVM::FixedVectorType>(srcTy)->getNumElements() : 1;
815+ dstNElts = (dstTy->isVectorTy()) ? (uint32_t)cast<IGCLLVM::FixedVectorType>(dstTy)->getNumElements() : 1;
816
817 if (srcNElts < dstNElts && srcTy->getScalarSizeInBits() < 64)
818 {
819diff --git a/IGC/Compiler/CISACodeGen/PushAnalysis.cpp b/IGC/Compiler/CISACodeGen/PushAnalysis.cpp
820index ba8c2770..8da82db0 100644
821--- a/IGC/Compiler/CISACodeGen/PushAnalysis.cpp
822+++ b/IGC/Compiler/CISACodeGen/PushAnalysis.cpp
823@@ -899,7 +899,7 @@ namespace IGC
824
825 if (pTypeToPush->isVectorTy())
826 {
827- num_elms = (unsigned)cast<VectorType>(pTypeToPush)->getNumElements();
828+ num_elms = (unsigned)cast<IGCLLVM::FixedVectorType>(pTypeToPush)->getNumElements();
829 pTypeToPush = cast<VectorType>(pTypeToPush)->getElementType();
830 llvm::Type* pVecTy = IGCLLVM::FixedVectorType::get(pTypeToPush, num_elms);
831 pReplacedInst = llvm::UndefValue::get(pVecTy);
832@@ -1102,7 +1102,7 @@ namespace IGC
833 }
834
835 unsigned num_elms =
836- inst->getType()->isVectorTy() ? (unsigned)cast<VectorType>(inst->getType())->getNumElements() : 1;
837+ inst->getType()->isVectorTy() ? (unsigned)cast<IGCLLVM::FixedVectorType>(inst->getType())->getNumElements() : 1;
838 llvm::Type* pTypeToPush = inst->getType();
839 llvm::Value* replaceVector = nullptr;
840 unsigned int numberChannelReplaced = 0;
841diff --git a/IGC/Compiler/CISACodeGen/RegisterEstimator.cpp b/IGC/Compiler/CISACodeGen/RegisterEstimator.cpp
842index 95b937e7..1c6544a4 100644
843--- a/IGC/Compiler/CISACodeGen/RegisterEstimator.cpp
844+++ b/IGC/Compiler/CISACodeGen/RegisterEstimator.cpp
845@@ -41,6 +41,7 @@ IN THE SOFTWARE.
846 #include <llvm/IR/IRBuilder.h>
847 #include <llvm/IR/InstIterator.h>
848 #include <llvm/Support/MathExtras.h>
849+#include <llvmWrapper/IR/DerivedTypes.h>
850 #include "common/LLVMWarningsPop.hpp"
851 #include "Probe/Assertion.h"
852
853@@ -146,7 +147,7 @@ RegUse RegisterEstimator::estimateNumOfRegs(Value* V) const
854 Type* Ty = V->getType();
855 if (!Ty->isVoidTy())
856 {
857- VectorType* VTy = dyn_cast<VectorType>(Ty);
858+ IGCLLVM::FixedVectorType* VTy = dyn_cast<IGCLLVM::FixedVectorType>(Ty);
859 Type* eltTy = VTy ? VTy->getElementType() : Ty;
860 uint32_t nelts = VTy ? int_cast<uint32_t>(VTy->getNumElements()) : 1;
861 uint32_t eltBits = (uint32_t)m_DL->getTypeSizeInBits(eltTy);
862diff --git a/IGC/Compiler/CISACodeGen/RegisterPressureEstimate.hpp b/IGC/Compiler/CISACodeGen/RegisterPressureEstimate.hpp
863index beac138d..ceeafa48 100644
864--- a/IGC/Compiler/CISACodeGen/RegisterPressureEstimate.hpp
865+++ b/IGC/Compiler/CISACodeGen/RegisterPressureEstimate.hpp
866@@ -42,6 +42,7 @@ See LRCENSE.TXT for details.
867 #include "llvm/Pass.h"
868 #include <llvm/IR/InstVisitor.h>
869 #include "llvm/Analysis/LoopInfo.h"
870+#include <llvmWrapper/IR/DerivedTypes.h>
871 #include "common/LLVMWarningsPop.hpp"
872 #include "Compiler/IGCPassSupport.h"
873 #include "Compiler/CISACodeGen/WIAnalysis.hpp"
874@@ -240,7 +241,7 @@ namespace IGC
875 auto Ty = V->getType();
876 if (Ty->isVoidTy())
877 return 0;
878- auto VTy = llvm::dyn_cast<llvm::VectorType>(Ty);
879+ auto VTy = llvm::dyn_cast<IGCLLVM::FixedVectorType>(Ty);
880 auto eltTy = VTy ? VTy->getElementType() : Ty;
881 uint32_t nelts = VTy ? int_cast<uint32_t>(VTy->getNumElements()) : 1;
882 uint32_t eltBits = (uint32_t)m_DL->getTypeSizeInBits(eltTy);
883diff --git a/IGC/Compiler/CISACodeGen/SLMConstProp.cpp b/IGC/Compiler/CISACodeGen/SLMConstProp.cpp
884index 962083f4..26a7b8be 100644
885--- a/IGC/Compiler/CISACodeGen/SLMConstProp.cpp
886+++ b/IGC/Compiler/CISACodeGen/SLMConstProp.cpp
887@@ -39,6 +39,7 @@ IN THE SOFTWARE.
888 #include <llvm/IR/InstIterator.h>
889 #include <llvm/Support/Debug.h>
890 #include <llvm/Support/MathExtras.h>
891+#include "llvmWrapper/IR/DerivedTypes.h"
892 #include "common/LLVMWarningsPop.hpp"
893 #include <vector>
894 #include "Probe/Assertion.h"
895@@ -629,7 +630,7 @@ bool SLMConstProp::isEqual(Constant* C0, Constant* C1)
896
897 bool SLMConstProp::isFloatType(Type* Ty)
898 {
899- if (VectorType * vTy = dyn_cast<VectorType>(Ty))
900+ if (IGCLLVM::FixedVectorType * vTy = dyn_cast<IGCLLVM::FixedVectorType>(Ty))
901 {
902 if (vTy->getNumElements() > 1)
903 {
904diff --git a/IGC/Compiler/CISACodeGen/ScalarizerCodeGen.cpp b/IGC/Compiler/CISACodeGen/ScalarizerCodeGen.cpp
905index ce816416..32ab79c1 100644
906--- a/IGC/Compiler/CISACodeGen/ScalarizerCodeGen.cpp
907+++ b/IGC/Compiler/CISACodeGen/ScalarizerCodeGen.cpp
908@@ -66,7 +66,7 @@ void ScalarizerCodeGen::visitBinaryOperator(llvm::BinaryOperator& I)
909 {
910 bool isNewTypeVector = false;
911
912- VectorType* instType = cast<VectorType>(I.getType());
913+ IGCLLVM::FixedVectorType* instType = cast<IGCLLVM::FixedVectorType>(I.getType());
914 unsigned numElements = int_cast<unsigned>(instType->getNumElements());
915 unsigned scalarSize = instType->getScalarSizeInBits();
916 unsigned newScalarBits = numElements * scalarSize;
917@@ -111,7 +111,7 @@ void ScalarizerCodeGen::visitBinaryOperator(llvm::BinaryOperator& I)
918 }
919 else
920 {
921- VectorType* newVecType = cast<VectorType>(newType);
922+ IGCLLVM::FixedVectorType* newVecType = cast<IGCLLVM::FixedVectorType>(newType);
923 unsigned newVecTypeNumEle = int_cast<unsigned>(newVecType->getNumElements());
924 Value* ieLogicOp = UndefValue::get(newType);
925 for (unsigned i = 0; i < newVecTypeNumEle; i++)
926diff --git a/IGC/Compiler/CISACodeGen/ShaderCodeGen.cpp b/IGC/Compiler/CISACodeGen/ShaderCodeGen.cpp
927index d7baf806..e6fbdf23 100644
928--- a/IGC/Compiler/CISACodeGen/ShaderCodeGen.cpp
929+++ b/IGC/Compiler/CISACodeGen/ShaderCodeGen.cpp
930@@ -589,12 +589,14 @@ static void AddLegalizationPasses(CodeGenContext& ctx, IGCPassManager& mpm, PSSi
931 {
932 mpm.add(createPruneUnusedArgumentsPass());
933
934+#if LLVM_VERSION_MAJOR < 12
935 if (IGC_GET_FLAG_VALUE(FunctionControl) == FLAG_FCALL_DEFAULT)
936 {
937 // Don't run IPConstantProp when debugging function calls, to avoid folding function arg/ret constants
938 mpm.add(createIPConstantPropagationPass());
939 }
940 mpm.add(createConstantPropagationPass());
941+#endif
942 mpm.add(createDeadCodeEliminationPass());
943 mpm.add(createCFGSimplificationPass());
944 }
945@@ -1475,8 +1477,10 @@ void OptimizeIR(CodeGenContext* const pContext)
946 // possible which potentially allows late stage code sinking of
947 // those calls by the instruction combiner.
948 mpm.add(createPostOrderFunctionAttrsLegacyPass());
949+#if LLVM_VERSION_MAJOR < 12
950 mpm.add(createConstantPropagationPass());
951 mpm.add(createIPConstantPropagationPass());
952+#endif
953 }
954
955 // enable this only when Pooled EU is not supported
956diff --git a/IGC/Compiler/CISACodeGen/Simd32Profitability.cpp b/IGC/Compiler/CISACodeGen/Simd32Profitability.cpp
957index 87ba2751..c1f4a419 100644
958--- a/IGC/Compiler/CISACodeGen/Simd32Profitability.cpp
959+++ b/IGC/Compiler/CISACodeGen/Simd32Profitability.cpp
960@@ -30,6 +30,7 @@ IN THE SOFTWARE.
961 #include <llvmWrapper/IR/DerivedTypes.h>
962 #include <llvm/IR/InstIterator.h>
963 #include <llvm/IR/Operator.h>
964+#include <llvmWrapper/IR/DerivedTypes.h>
965 #include "common/LLVMWarningsPop.hpp"
966 #include "GenISAIntrinsics/GenIntrinsics.h"
967 #include "GenISAIntrinsics/GenIntrinsicInst.h"
968@@ -577,7 +578,7 @@ static bool isPayloadHeader(Value* V) {
969 Argument* Arg = dyn_cast<Argument>(V);
970 if (!Arg || !Arg->hasName())
971 return false;
972- VectorType* VTy = dyn_cast<VectorType>(Arg->getType());
973+ IGCLLVM::FixedVectorType* VTy = dyn_cast<IGCLLVM::FixedVectorType>(Arg->getType());
974 if (!VTy || VTy->getNumElements() != 8 ||
975 !VTy->getElementType()->isIntegerTy(32))
976 return false;
977@@ -588,7 +589,7 @@ static bool isR0(Value* V) {
978 Argument* Arg = dyn_cast<Argument>(V);
979 if (!Arg || !Arg->hasName())
980 return false;
981- VectorType* VTy = dyn_cast<VectorType>(Arg->getType());
982+ IGCLLVM::FixedVectorType* VTy = dyn_cast<IGCLLVM::FixedVectorType>(Arg->getType());
983 if (!VTy || VTy->getNumElements() != 8 ||
984 !VTy->getElementType()->isIntegerTy(32))
985 return false;
986@@ -599,7 +600,7 @@ static bool isEnqueuedLocalSize(Value* V) {
987 Argument* Arg = dyn_cast<Argument>(V);
988 if (!Arg || !Arg->hasName())
989 return false;
990- VectorType* VTy = dyn_cast<VectorType>(Arg->getType());
991+ IGCLLVM::FixedVectorType* VTy = dyn_cast<IGCLLVM::FixedVectorType>(Arg->getType());
992 if (!VTy || VTy->getNumElements() != 3 ||
993 !VTy->getElementType()->isIntegerTy(32))
994 return false;
995@@ -994,7 +995,11 @@ static bool hasLongStridedLdStInLoop(Function* F, LoopInfo* LI, WIAnalysis* WI)
996 // Collect innermost simple loop.
997 for (auto I = LI->begin(), E = LI->end(); I != E; ++I) {
998 auto L = *I;
999+#if LLVM_VERSION_MAJOR >= 12
1000+ if (!L->isInnermost())
1001+#else
1002 if (!L->empty())
1003+#endif
1004 continue;
1005 if (L->getNumBlocks() != 2)
1006 continue;
1007diff --git a/IGC/Compiler/CISACodeGen/SimplifyConstant.cpp b/IGC/Compiler/CISACodeGen/SimplifyConstant.cpp
1008index 73f472b5..0069c4b1 100644
1009--- a/IGC/Compiler/CISACodeGen/SimplifyConstant.cpp
1010+++ b/IGC/Compiler/CISACodeGen/SimplifyConstant.cpp
1011@@ -352,7 +352,7 @@ static unsigned getLegalVectorSize(unsigned N) {
1012 // Check vector size. We may demote the data type if all values can fit into
1013 // smaller data type.
1014 //
1015-static bool checkSize(GlobalVariable* GV, VectorType*& DataType,
1016+static bool checkSize(GlobalVariable* GV, IGCLLVM::FixedVectorType*& DataType,
1017 bool& IsSigned) {
1018 Constant* Init = GV->getInitializer();
1019 IGC_ASSERT(isa<ArrayType>(Init->getType()));
1020@@ -360,7 +360,7 @@ static bool checkSize(GlobalVariable* GV, VectorType*& DataType,
1021 unsigned N = (unsigned)ArrayTy->getArrayNumElements();
1022 Type* BaseTy = ArrayTy->getArrayElementType();
1023 unsigned VectorSize = 1;
1024- if (auto VT = dyn_cast<VectorType>(BaseTy)) {
1025+ if (auto VT = dyn_cast<IGCLLVM::FixedVectorType>(BaseTy)) {
1026 BaseTy = VT->getElementType();
1027 VectorSize = int_cast<unsigned>(VT->getNumElements());
1028 N *= VectorSize;
1029@@ -483,7 +483,7 @@ static Constant* getConstantVal(Type* VEltTy, Constant* V, bool IsSigned) {
1030 return ConstantInt::get(VEltTy, IVal, IsSigned);
1031 }
1032
1033-static void promote(GlobalVariable* GV, VectorType* AllocaType, bool IsSigned,
1034+static void promote(GlobalVariable* GV, IGCLLVM::FixedVectorType* AllocaType, bool IsSigned,
1035 Function* F) {
1036 // Build the constant vector from constant array.
1037 unsigned VS = int_cast<unsigned>(AllocaType->getNumElements());
1038@@ -507,7 +507,7 @@ static void promote(GlobalVariable* GV, VectorType* AllocaType, bool IsSigned,
1039 Constant* const Elt = CA->getAggregateElement(i);
1040 IGC_ASSERT_MESSAGE(nullptr != Elt, "Null AggregateElement");
1041 if (auto EltTy = dyn_cast<VectorType>(Elt->getType())) {
1042- unsigned VectorSize = (unsigned)cast<VectorType>(EltTy)->getNumElements();
1043+ unsigned VectorSize = (unsigned)cast<IGCLLVM::FixedVectorType>(EltTy)->getNumElements();
1044 for (unsigned j = 0; j < VectorSize; ++j) {
1045 Constant* V = Elt->getAggregateElement(j);
1046 Vals[i * VectorSize + j] = getConstantVal(VEltTy, V, IsSigned);
1047@@ -549,7 +549,7 @@ static void promote(GlobalVariable* GV, VectorType* AllocaType, bool IsSigned,
1048 unsigned N = 1;
1049 Value* Offset = Index;
1050 if (Ty->isVectorTy()) {
1051- N = (unsigned)cast<VectorType>(Ty)->getNumElements();
1052+ N = (unsigned)cast<IGCLLVM::FixedVectorType>(Ty)->getNumElements();
1053 Offset = Builder.CreateMul(Offset, ConstantInt::get(Offset->getType(), N));
1054 }
1055 Value* Val = extractNElts(N, VectorData, Offset, Builder);
1056@@ -684,7 +684,7 @@ bool PromoteConstant::runOnFunction(Function& F) {
1057
1058 // If possible demote the data into smaller type. Uses of value will be
1059 // promoted back with ZExt or SExt.
1060- VectorType* AllocaType = nullptr;
1061+ IGCLLVM::FixedVectorType* AllocaType = nullptr;
1062 bool IsSigned = false;
1063 if (!checkSize(GV, AllocaType, IsSigned))
1064 continue;
1065diff --git a/IGC/Compiler/CISACodeGen/TypeDemote.cpp b/IGC/Compiler/CISACodeGen/TypeDemote.cpp
1066index eb7a7b64..b04a0f6e 100644
1067--- a/IGC/Compiler/CISACodeGen/TypeDemote.cpp
1068+++ b/IGC/Compiler/CISACodeGen/TypeDemote.cpp
1069@@ -32,6 +32,7 @@ IN THE SOFTWARE.
1070 #include <llvm/ADT/PostOrderIterator.h>
1071 #include <llvm/IR/IRBuilder.h>
1072 #include <llvm/Pass.h>
1073+#include <llvmWrapper/IR/DerivedTypes.h>
1074 #include "common/LLVMWarningsPop.hpp"
1075 #include "GenISAIntrinsics/GenIntrinsics.h"
1076 #include "Probe/Assertion.h"
1077@@ -288,7 +289,7 @@ bool TypeDemote::demoteOnBasicBlock(BasicBlock* BB) const {
1078 CastInst* CI = dyn_cast<CastInst>(Index);
1079 if (CI && (CI->getOpcode() == Instruction::ZExt ||
1080 CI->getOpcode() == Instruction::SExt)) {
1081- unsigned VS = (unsigned)cast<VectorType>(EEI->getVectorOperandType())->getNumElements();
1082+ unsigned VS = (unsigned)cast<IGCLLVM::FixedVectorType>(EEI->getVectorOperandType())->getNumElements();
1083 unsigned N = (unsigned int)CI->getSrcTy()->getPrimitiveSizeInBits();
1084 unsigned Bound = (N < 32) ? (1U << N) : UINT32_MAX;
1085 if (VS <= Bound) {
1086diff --git a/IGC/Compiler/CISACodeGen/VariableReuseAnalysis.cpp b/IGC/Compiler/CISACodeGen/VariableReuseAnalysis.cpp
1087index 1cac7b12..12c4734e 100644
1088--- a/IGC/Compiler/CISACodeGen/VariableReuseAnalysis.cpp
1089+++ b/IGC/Compiler/CISACodeGen/VariableReuseAnalysis.cpp
1090@@ -28,6 +28,7 @@ IN THE SOFTWARE.
1091 #include "Compiler/CodeGenPublic.h"
1092 #include "common/LLVMWarningsPush.hpp"
1093 #include <llvm/Support/Debug.h>
1094+#include "llvmWrapper/IR/DerivedTypes.h"
1095 #include "common/LLVMWarningsPop.hpp"
1096 #include <algorithm>
1097 #include "Probe/Assertion.h"
1098@@ -40,13 +41,13 @@ namespace
1099 // If V is scalar, return 1.
1100 // if V is vector, return the number of elements.
1101 inline int getNumElts(Value* V) {
1102- VectorType* VTy = dyn_cast<VectorType>(V->getType());
1103+ IGCLLVM::FixedVectorType* VTy = dyn_cast<IGCLLVM::FixedVectorType>(V->getType());
1104 return VTy ? (int)VTy->getNumElements() : 1;
1105 }
1106
1107 inline int getTypeSizeInBits(Type* Ty) {
1108 int scalarBits = Ty->getScalarSizeInBits();
1109- VectorType* VTy = dyn_cast<VectorType>(Ty);
1110+ IGCLLVM::FixedVectorType* VTy = dyn_cast<IGCLLVM::FixedVectorType>(Ty);
1111 return scalarBits * (VTy ? (int)VTy->getNumElements() : 1);
1112 }
1113 }
1114diff --git a/IGC/Compiler/CISACodeGen/VariableReuseAnalysis.hpp b/IGC/Compiler/CISACodeGen/VariableReuseAnalysis.hpp
1115index 56dac17e..42081dca 100644
1116--- a/IGC/Compiler/CISACodeGen/VariableReuseAnalysis.hpp
1117+++ b/IGC/Compiler/CISACodeGen/VariableReuseAnalysis.hpp
1118@@ -37,6 +37,7 @@ IN THE SOFTWARE.
1119 #include <llvm/IR/InstIterator.h>
1120 #include <llvm/IR/InstVisitor.h>
1121 #include "llvm/Pass.h"
1122+#include "llvmWrapper/IR/DerivedTypes.h"
1123 #include "llvm/Support/raw_ostream.h"
1124 #include "common/LLVMWarningsPop.hpp"
1125 #include "Compiler/CISACodeGen/RegisterEstimator.hpp"
1126@@ -79,7 +80,7 @@ namespace IGC {
1127 SSubVecDesc(llvm::Value* V)
1128 : Aliaser(V), BaseVector(V), StartElementOffset(0)
1129 {
1130- llvm::VectorType* VTy = llvm::dyn_cast<llvm::VectorType>(V->getType());
1131+ IGCLLVM::FixedVectorType* VTy = llvm::dyn_cast<IGCLLVM::FixedVectorType>(V->getType());
1132 NumElts = VTy ? (short)VTy->getNumElements() : 1;
1133 }
1134
1135diff --git a/IGC/Compiler/CISACodeGen/VectorPreProcess.cpp b/IGC/Compiler/CISACodeGen/VectorPreProcess.cpp
1136index 4c2b0644..4cd6a2db 100644
1137--- a/IGC/Compiler/CISACodeGen/VectorPreProcess.cpp
1138+++ b/IGC/Compiler/CISACodeGen/VectorPreProcess.cpp
1139@@ -500,7 +500,7 @@ void VectorPreProcess::replaceAllVectorUsesWithScalars(Instruction* VI, ValVecto
1140 I = VI->getParent()->getFirstNonPHI();
1141 }
1142 IRBuilder<> Builder(I);
1143- VectorType* VTy = cast<VectorType>(VI->getType());
1144+ IGCLLVM::FixedVectorType* VTy = cast<IGCLLVM::FixedVectorType>(VI->getType());
1145 Value* newVec = UndefValue::get(VTy);
1146 for (uint32_t i = 0, e = int_cast<uint32_t>(VTy->getNumElements()); i < e; ++i)
1147 {
1148@@ -619,7 +619,7 @@ bool VectorPreProcess::splitStore(
1149 {
1150 Instruction* SI = ASI.getInst();
1151 Value* StoredVal = ASI.getValueOperand();
1152- VectorType* VTy = cast<VectorType>(StoredVal->getType());
1153+ IGCLLVM::FixedVectorType* VTy = cast<IGCLLVM::FixedVectorType>(StoredVal->getType());
1154 Type* ETy = VTy->getElementType();
1155 uint32_t nelts = int_cast<uint32_t>(VTy->getNumElements());
1156
1157@@ -705,7 +705,7 @@ bool VectorPreProcess::splitStore(
1158 {
1159 Type* Ty1 = splitInfo[i].first;
1160 uint32_t len1 = splitInfo[i].second;
1161- VectorType* VTy1 = dyn_cast<VectorType>(Ty1);
1162+ IGCLLVM::FixedVectorType* VTy1 = dyn_cast<IGCLLVM::FixedVectorType>(Ty1);
1163 for (uint32_t j = 0; j < len1; ++j)
1164 {
1165 Value* subVec;
1166@@ -742,7 +742,7 @@ bool VectorPreProcess::splitStore(
1167 {
1168 Type* Ty1 = splitInfo[i].first;
1169 uint32_t len1 = splitInfo[i].second;
1170- VectorType* VTy1 = dyn_cast<VectorType>(Ty1);
1171+ IGCLLVM::FixedVectorType* VTy1 = dyn_cast<IGCLLVM::FixedVectorType>(Ty1);
1172 for (uint32_t j = 0; j < len1; ++j)
1173 {
1174 uint32_t vAlign = (uint32_t)MinAlign(Align, (uint32_t)eOffset * EBytes);
1175@@ -786,7 +786,7 @@ bool VectorPreProcess::splitLoad(
1176 {
1177 Instruction* LI = ALI.getInst();
1178 bool isLdRaw = isa<LdRawIntrinsic>(LI);
1179- VectorType* VTy = cast<VectorType>(LI->getType());
1180+ IGCLLVM::FixedVectorType* VTy = cast<IGCLLVM::FixedVectorType>(LI->getType());
1181 Type* ETy = VTy->getElementType();
1182 uint32_t nelts = int_cast<uint32_t>(VTy->getNumElements());
1183
1184@@ -848,7 +848,7 @@ bool VectorPreProcess::splitLoad(
1185 {
1186 Type* Ty1 = splitInfo[i].first;
1187 uint32_t len1 = splitInfo[i].second;
1188- VectorType* VTy1 = dyn_cast<VectorType>(Ty1);
1189+ IGCLLVM::FixedVectorType* VTy1 = dyn_cast<IGCLLVM::FixedVectorType>(Ty1);
1190 for (uint32_t j = 0; j < len1; ++j)
1191 {
1192 uint32_t vAlign = (uint32_t)MinAlign(Align, eOffset * EBytes);
1193@@ -916,7 +916,7 @@ bool VectorPreProcess::splitLoadStore(
1194 Optional<AbstractStoreInst> ASI = AbstractStoreInst::get(Inst);
1195 IGC_ASSERT_MESSAGE((ALI || ASI), "Inst should be either load or store");
1196 Type* Ty = ALI ? ALI->getInst()->getType() : ASI->getValueOperand()->getType();
1197- VectorType* VTy = dyn_cast<VectorType>(Ty);
1198+ IGCLLVM::FixedVectorType* VTy = dyn_cast<IGCLLVM::FixedVectorType>(Ty);
1199 if (!VTy)
1200 {
1201 return false;
1202@@ -1147,7 +1147,7 @@ void VectorPreProcess::getOrGenScalarValues(
1203 {
1204 availBeforeInst = nullptr;
1205
1206- VectorType* VTy = cast<VectorType>(VecVal->getType());
1207+ IGCLLVM::FixedVectorType* VTy = cast<IGCLLVM::FixedVectorType>(VecVal->getType());
1208 if (!VTy)
1209 {
1210 scalars[0] = VecVal;
1211@@ -1298,7 +1298,7 @@ Instruction* VectorPreProcess::simplifyLoadStore(Instruction* Inst)
1212 //
1213 // TODO: further optimize this load into a message with channel masks
1214 // for cases in which use indices are sparse like {0, 2}.
1215- unsigned N = (unsigned)cast<VectorType>(Inst->getType())->getNumElements();
1216+ unsigned N = (unsigned)cast<IGCLLVM::FixedVectorType>(Inst->getType())->getNumElements();
1217 if (N == MaxIndex + 1)
1218 return Inst;
1219
1220@@ -1355,7 +1355,7 @@ Instruction* VectorPreProcess::simplifyLoadStore(Instruction* Inst)
1221 if (NBits < 32)
1222 return Inst;
1223
1224- unsigned N = (unsigned)cast<VectorType>(Val->getType())->getNumElements();
1225+ unsigned N = (unsigned)cast<IGCLLVM::FixedVectorType>(Val->getType())->getNumElements();
1226 if (auto CV = dyn_cast<ConstantVector>(Val))
1227 {
1228 unsigned MaxIndex = 0;
1229@@ -1524,7 +1524,7 @@ bool VectorPreProcess::runOnFunction(Function& F)
1230 for (uint32_t j = 0; j < svals.size(); ++j)
1231 {
1232 Type* Ty1 = svals[j]->getType();
1233- VectorType* VTy1 = dyn_cast<VectorType>(Ty1);
1234+ IGCLLVM::FixedVectorType* VTy1 = dyn_cast<IGCLLVM::FixedVectorType>(Ty1);
1235 if (VTy1) {
1236 for (uint32_t k = 0; k < VTy1->getNumElements(); ++k)
1237 {
1238@@ -1573,7 +1573,7 @@ bool VectorPreProcess::runOnFunction(Function& F)
1239 // If this is a 3-element vector load, remove it
1240 // from m_Vector3List as well.
1241 if (isAbstractLoadInst(tInst) && tInst->getType()->isVectorTy() &&
1242- cast<VectorType>(tInst->getType())->getNumElements() == 3)
1243+ cast<IGCLLVM::FixedVectorType>(tInst->getType())->getNumElements() == 3)
1244 {
1245 InstWorkVector::iterator
1246 tI = m_Vector3List.begin(),
1247diff --git a/IGC/Compiler/CISACodeGen/VectorProcess.cpp b/IGC/Compiler/CISACodeGen/VectorProcess.cpp
1248index 9f39cdc0..cfe45321 100644
1249--- a/IGC/Compiler/CISACodeGen/VectorProcess.cpp
1250+++ b/IGC/Compiler/CISACodeGen/VectorProcess.cpp
1251@@ -240,7 +240,7 @@ bool VectorProcess::reLayoutLoadStore(Instruction* Inst)
1252 IGC_ASSERT(nullptr != Ptr);
1253 IGC_ASSERT(nullptr != Ty);
1254
1255- VectorType* const VTy = dyn_cast<VectorType>(Ty);
1256+ IGCLLVM::FixedVectorType* const VTy = dyn_cast<IGCLLVM::FixedVectorType>(Ty);
1257
1258 // Treat a scalar as 1-element vector
1259 uint32_t nelts = VTy ? int_cast<uint32_t>(VTy->getNumElements()) : 1;
1260@@ -654,7 +654,7 @@ void VectorMessage::getInfo(Type* Ty, uint32_t Align, bool useA32,
1261 VectorType* VTy = dyn_cast<VectorType>(Ty);
1262 Type* eTy = VTy ? cast<VectorType>(VTy)->getElementType() : Ty;
1263 unsigned eltSize = m_emitter->GetScalarTypeSizeInRegister(eTy);
1264- unsigned nElts = VTy ? (unsigned)cast<VectorType>(VTy)->getNumElements() : 1;
1265+ unsigned nElts = VTy ? (unsigned)cast<IGCLLVM::FixedVectorType>(VTy)->getNumElements() : 1;
1266 // total bytes
1267 const unsigned TBytes = nElts * eltSize;
1268
1269diff --git a/IGC/Compiler/CISACodeGen/helper.cpp b/IGC/Compiler/CISACodeGen/helper.cpp
1270index 784affaa..e5507283 100644
1271--- a/IGC/Compiler/CISACodeGen/helper.cpp
1272+++ b/IGC/Compiler/CISACodeGen/helper.cpp
1273@@ -1634,7 +1634,7 @@ namespace IGC
1274 {
1275 instList[i] = builder.CreateExtractElement(val, static_cast<uint64_t>(0));
1276 size_t iOld = i;
1277- for (unsigned j = 1; j < cast<VectorType>(val->getType())->getNumElements(); j++)
1278+ for (unsigned j = 1; j < cast<IGCLLVM::FixedVectorType>(val->getType())->getNumElements(); j++)
1279 {
1280 instList.insert(instList.begin()+ iOld +j, builder.CreateExtractElement(val, j));
1281 i++;
1282@@ -1667,7 +1667,7 @@ namespace IGC
1283 }
1284 break;
1285 case IGCLLVM::VectorTyID:
1286- num = (unsigned)cast<VectorType>(type)->getNumElements();
1287+ num = (unsigned)cast<IGCLLVM::FixedVectorType>(type)->getNumElements();
1288 for (unsigned i = 0; i < num; i++)
1289 {
1290 ScalarizeAggregateMembers(builder, builder.CreateExtractElement(val, i), instList);
1291@@ -1707,7 +1707,7 @@ namespace IGC
1292 }
1293 break;
1294 case IGCLLVM::VectorTyID:
1295- num = (unsigned)cast<VectorType>(type)->getNumElements();
1296+ num = (unsigned)cast<IGCLLVM::FixedVectorType>(type)->getNumElements();
1297 for (unsigned i = 0; i < num; i++)
1298 {
1299 indices.push_back(builder.getInt32(i));
1300@@ -1972,8 +1972,8 @@ namespace IGC
1301 return false;
1302 }
1303
1304- VectorType* dVTy = dyn_cast<VectorType>(dTy);
1305- VectorType* sVTy = dyn_cast<VectorType>(sTy);
1306+ IGCLLVM::FixedVectorType* dVTy = dyn_cast<IGCLLVM::FixedVectorType>(dTy);
1307+ IGCLLVM::FixedVectorType* sVTy = dyn_cast<IGCLLVM::FixedVectorType>(sTy);
1308 int d_nelts = dVTy ? (int)dVTy->getNumElements() : 1;
1309 int s_nelts = sVTy ? (int)sVTy->getNumElements() : 1;
1310 if (d_nelts != s_nelts) {
1311diff --git a/IGC/Compiler/ConvertMSAAPayloadTo16Bit.cpp b/IGC/Compiler/ConvertMSAAPayloadTo16Bit.cpp
1312index cd7fc66e..adf992cb 100644
1313--- a/IGC/Compiler/ConvertMSAAPayloadTo16Bit.cpp
1314+++ b/IGC/Compiler/ConvertMSAAPayloadTo16Bit.cpp
1315@@ -153,15 +153,24 @@ void ConvertMSAAPayloadTo16Bit::visitCallInst(CallInst& I)
1316 // In OGL there are uses of ldmcs other then ldms, using vec4float type.
1317 // Fix them to use newly created 16bit ldmcs.
1318 if (ldmcs->getType()->isVectorTy() &&
1319+#if LLVM_VERSION_MAJOR >= 12
1320+ ldmcs->getType()->getScalarType()->isFloatTy())
1321+#else
1322 ldmcs->getType()->getVectorElementType()->isFloatTy())
1323+#endif
1324 {
1325 m_builder->SetInsertPoint(ldmcs);
1326
1327+#if LLVM_VERSION_MAJOR >= 12
1328+ uint ldmcsNumOfElements = cast<IGCLLVM::FixedVectorType>(ldmcs->getType())->getNumElements();
1329+ uint new_mcs_callNumOfElements = cast<IGCLLVM::FixedVectorType>(new_mcs_call->getType())->getNumElements();
1330+#else
1331 uint ldmcsNumOfElements = ldmcs->getType()->getVectorNumElements();
1332 uint new_mcs_callNumOfElements = new_mcs_call->getType()->getVectorNumElements();
1333+#endif
1334
1335 // vec of 16bit ints to vec of 32bit ints
1336- Type* new_mcs_callVecType = VectorType::get(m_builder->getInt32Ty(), new_mcs_callNumOfElements);
1337+ Type* new_mcs_callVecType = IGCLLVM::FixedVectorType::get(m_builder->getInt32Ty(), new_mcs_callNumOfElements);
1338 Value* ldmcsExtendedToInt32 = m_builder->CreateSExt(new_mcs_call, new_mcs_callVecType);
1339
1340 // if new ldmcs has fewer elements than ldmcs, extend vector
1341@@ -175,7 +184,7 @@ void ConvertMSAAPayloadTo16Bit::visitCallInst(CallInst& I)
1342 }
1343 auto* pMask = ConstantDataVector::get(I.getContext(), maskVals);
1344
1345- newLdmcsSizedVector = m_builder->CreateShuffleVector(ldmcsExtendedToInt32, UndefValue::get(VectorType::get(m_builder->getInt32Ty(), ldmcsNumOfElements)), pMask);
1346+ newLdmcsSizedVector = m_builder->CreateShuffleVector(ldmcsExtendedToInt32, UndefValue::get(IGCLLVM::FixedVectorType::get(m_builder->getInt32Ty(), ldmcsNumOfElements)), pMask);
1347 }
1348 else
1349 {
1350@@ -183,7 +192,7 @@ void ConvertMSAAPayloadTo16Bit::visitCallInst(CallInst& I)
1351 }
1352 IGC_ASSERT(newLdmcsSizedVector);
1353
1354- Type* ldmcsFloatVecType = VectorType::get(m_builder->getFloatTy(), ldmcsNumOfElements);
1355+ Type* ldmcsFloatVecType = IGCLLVM::FixedVectorType::get(m_builder->getFloatTy(), ldmcsNumOfElements);
1356 Value* ldmcsBitcastedToFloat = m_builder->CreateBitCast(ldmcsExtendedToInt32, ldmcsFloatVecType);
1357 ldmcs->replaceAllUsesWith(ldmcsBitcastedToFloat);
1358 }
1359diff --git a/IGC/Compiler/CustomSafeOptPass.cpp b/IGC/Compiler/CustomSafeOptPass.cpp
1360index 707bbfbe..72859a91 100644
1361--- a/IGC/Compiler/CustomSafeOptPass.cpp
1362+++ b/IGC/Compiler/CustomSafeOptPass.cpp
1363@@ -1372,7 +1372,7 @@ void IGC::CustomSafeOptPass::visitSampleBptr(llvm::SampleIntrinsic* sampleInst)
1364 bool CustomSafeOptPass::isIdentityMatrix(ExtractElementInst& I)
1365 {
1366 bool found = false;
1367- auto extractType = cast<VectorType>(I.getVectorOperandType());
1368+ auto extractType = cast<IGCLLVM::FixedVectorType>(I.getVectorOperandType());
1369 auto extractTypeVecSize = (uint32_t)extractType->getNumElements();
1370 if (extractTypeVecSize == 20 ||
1371 extractTypeVecSize == 16)
1372@@ -1601,7 +1601,7 @@ void CustomSafeOptPass::visitExtractElementInst(ExtractElementInst& I)
1373 int elOffset = (int)(bitShift / eltSize);
1374 elOffset = rightShift ? elOffset : -elOffset;
1375 unsigned int newIndex = (unsigned int)((int)cstIndex->getZExtValue() + elOffset);
1376- if (newIndex < cast<VectorType>(vecType)->getNumElements())
1377+ if (newIndex < cast<IGCLLVM::FixedVectorType>(vecType)->getNumElements())
1378 {
1379 IRBuilder<> builder(&I);
1380 Value* newBitCast = builder.CreateBitCast(binOp->getOperand(0), vecType);
1381@@ -2001,7 +2001,7 @@ void GenSpecificPattern::createBitcastExtractInsertPattern(BinaryOperator& I, Va
1382 else if (auto IEIInst = dyn_cast<InsertElementInst>(Op))
1383 {
1384 auto opType = IEIInst->getType();
1385- if (opType->isVectorTy() && cast<VectorType>(opType)->getElementType()->isIntegerTy(32) && cast<VectorType>(opType)->getNumElements() == 2)
1386+ if (opType->isVectorTy() && cast<VectorType>(opType)->getElementType()->isIntegerTy(32) && cast<IGCLLVM::FixedVectorType>(opType)->getNumElements() == 2)
1387 {
1388 elem = IEIInst->getOperand(1);
1389 }
1390@@ -2064,7 +2064,7 @@ void GenSpecificPattern::visitBinaryOperator(BinaryOperator& I)
1391 else if (match(&I, pattern2) && AndOp2->getType()->isIntegerTy(64))
1392 {
1393 ConstantVector* cVec = dyn_cast<ConstantVector>(VecOp);
1394- VectorType* vector_type = dyn_cast<VectorType>(VecOp->getType());
1395+ IGCLLVM::FixedVectorType* vector_type = dyn_cast<IGCLLVM::FixedVectorType>(VecOp->getType());
1396 if (cVec && vector_type &&
1397 isa<ConstantInt>(cVec->getOperand(0)) &&
1398 cast<ConstantInt>(cVec->getOperand(0))->isZero() &&
1399@@ -2210,7 +2210,7 @@ void GenSpecificPattern::visitBinaryOperator(BinaryOperator& I)
1400 BitCastInst* opBC = cast<BitCastInst>(op);
1401
1402 auto opType = opBC->getType();
1403- if (!(opType->isVectorTy() && cast<VectorType>(opType)->getElementType()->isIntegerTy(32) && cast<VectorType>(opType)->getNumElements() == 2))
1404+ if (!(opType->isVectorTy() && cast<VectorType>(opType)->getElementType()->isIntegerTy(32) && cast<IGCLLVM::FixedVectorType>(opType)->getNumElements() == 2))
1405 return nullptr;
1406
1407 if (opBC->getSrcTy()->isDoubleTy())
1408@@ -2630,8 +2630,8 @@ void GenSpecificPattern::visitBitCastInst(BitCastInst& I)
1409 if (zExtInst->getOperand(0)->getType()->isIntegerTy(32) &&
1410 isa<InsertElementInst>(bitCastInst->getOperand(0)) &&
1411 bitCastInst->getOperand(0)->getType()->isVectorTy() &&
1412- cast<VectorType>(bitCastInst->getOperand(0)->getType())->getElementType()->isIntegerTy(32) &&
1413- cast<VectorType>(bitCastInst->getOperand(0)->getType())->getNumElements() == 2)
1414+ cast<IGCLLVM::FixedVectorType>(bitCastInst->getOperand(0)->getType())->getElementType()->isIntegerTy(32) &&
1415+ cast<IGCLLVM::FixedVectorType>(bitCastInst->getOperand(0)->getType())->getNumElements() == 2)
1416 {
1417 InsertElementInst* insertElementInst = cast<InsertElementInst>(bitCastInst->getOperand(0));
1418
1419@@ -2731,7 +2731,7 @@ void GenSpecificPattern::visitFNeg(llvm::UnaryOperator& I)
1420 }
1421 else
1422 {
1423- uint32_t vectorSize = cast<VectorType>(I.getType())->getNumElements();
1424+ uint32_t vectorSize = cast<IGCLLVM::FixedVectorType>(I.getType())->getNumElements();
1425 fsub = llvm::UndefValue::get(I.getType());
1426
1427 for (uint32_t i = 0; i < vectorSize; ++i)
1428@@ -2845,7 +2845,7 @@ Constant* IGCConstProp::replaceShaderConstant(LoadInst* inst)
1429 if (inst->getType()->isVectorTy())
1430 {
1431 Type* srcEltTy = cast<VectorType>(inst->getType())->getElementType();
1432- uint32_t srcNElts = (uint32_t)cast<VectorType>(inst->getType())->getNumElements();
1433+ uint32_t srcNElts = (uint32_t)cast<IGCLLVM::FixedVectorType>(inst->getType())->getNumElements();
1434 uint32_t eltSize_in_bytes = (unsigned int)srcEltTy->getPrimitiveSizeInBits() / 8;
1435 IRBuilder<> builder(inst);
1436 Value* vectorValue = UndefValue::get(inst->getType());
1437@@ -3122,7 +3122,7 @@ Constant* IGCConstProp::ConstantFoldCmpInst(CmpInst* CI)
1438 {
1439 bool AllTrue = true, AllFalse = true;
1440 auto VecOpnd = cast<Constant>(EEI->getVectorOperand());
1441- unsigned N = (unsigned)cast<VectorType>(VecOpnd->getType())->getNumElements();
1442+ unsigned N = (unsigned)cast<IGCLLVM::FixedVectorType>(VecOpnd->getType())->getNumElements();
1443 for (unsigned i = 0; i < N; ++i)
1444 {
1445 Constant* const Opnd = VecOpnd->getAggregateElement(i);
1446@@ -3918,8 +3918,8 @@ namespace IGC
1447 BitCastInst* BC = dyn_cast<BitCastInst>(&*BI++);
1448 if (!BC) continue;
1449 // Skip non-element-wise bitcast.
1450- VectorType* DstVTy = dyn_cast<VectorType>(BC->getType());
1451- VectorType* SrcVTy = dyn_cast<VectorType>(BC->getOperand(0)->getType());
1452+ IGCLLVM::FixedVectorType* DstVTy = dyn_cast<IGCLLVM::FixedVectorType>(BC->getType());
1453+ IGCLLVM::FixedVectorType* SrcVTy = dyn_cast<IGCLLVM::FixedVectorType>(BC->getOperand(0)->getType());
1454 if (!DstVTy || !SrcVTy || DstVTy->getNumElements() != SrcVTy->getNumElements())
1455 continue;
1456 // Skip if it's not used only all extractelement.
1457@@ -4689,7 +4689,7 @@ void SplitIndirectEEtoSel::visitExtractElementInst(llvm::ExtractElementInst& I)
1458 {
1459 using namespace llvm::PatternMatch;
1460
1461- VectorType* vecTy = I.getVectorOperandType();
1462+ IGCLLVM::FixedVectorType* vecTy = dyn_cast<IGCLLVM::FixedVectorType>(I.getVectorOperandType());
1463 uint64_t num = vecTy->getNumElements();
1464 Type* eleType = vecTy->getElementType();
1465
1466diff --git a/IGC/Compiler/DebugInfo/ScalarVISAModule.cpp b/IGC/Compiler/DebugInfo/ScalarVISAModule.cpp
1467index 885ad65a..923f296e 100644
1468--- a/IGC/Compiler/DebugInfo/ScalarVISAModule.cpp
1469+++ b/IGC/Compiler/DebugInfo/ScalarVISAModule.cpp
1470@@ -32,6 +32,7 @@ IN THE SOFTWARE.
1471 #include "DebugInfo/DebugInfoUtils.hpp"
1472
1473 #include "common/LLVMWarningsPush.hpp"
1474+#include "llvmWrapper/IR/DerivedTypes.h"
1475 #include "llvm/IR/Function.h"
1476 #include "llvm/IR/Module.h"
1477 #include "common/LLVMWarningsPop.hpp"
1478@@ -581,7 +582,7 @@ ScalarVisaModule::GetVariableLocation(const llvm::Instruction* pInst) const
1479
1480 if (pType->isVectorTy())
1481 {
1482- vectorNumElements = (unsigned)cast<VectorType>(pType)->getNumElements();
1483+ vectorNumElements = (unsigned)cast<IGCLLVM::FixedVectorType>(pType)->getNumElements();
1484 }
1485 else if (!pVar->IsUniform())
1486 {
1487diff --git a/IGC/Compiler/GenTTI.cpp b/IGC/Compiler/GenTTI.cpp
1488index 34b21c73..9e4d2f26 100644
1489--- a/IGC/Compiler/GenTTI.cpp
1490+++ b/IGC/Compiler/GenTTI.cpp
1491@@ -216,7 +216,13 @@ namespace llvm {
1492
1493 // Skip non-simple loop.
1494 if (L->getNumBlocks() != 1) {
1495- if (IGC_IS_FLAG_ENABLED(EnableAdvRuntimeUnroll) && L->empty()) {
1496+ if (IGC_IS_FLAG_ENABLED(EnableAdvRuntimeUnroll) &&
1497+#if LLVM_VERSION_MAJOR >= 12
1498+ L->isInnermost()
1499+#else
1500+ L->empty()
1501+#endif
1502+ ) {
1503 auto countNonPHI = [](BasicBlock* BB) {
1504 unsigned Total = BB->size();
1505 unsigned PHIs = 0;
1506diff --git a/IGC/Compiler/GenUpdateCB.cpp b/IGC/Compiler/GenUpdateCB.cpp
1507index 89b414b6..9034066c 100644
1508--- a/IGC/Compiler/GenUpdateCB.cpp
1509+++ b/IGC/Compiler/GenUpdateCB.cpp
1510@@ -24,6 +24,7 @@ IN THE SOFTWARE.
1511
1512 #include "common/LLVMWarningsPush.hpp"
1513 #include "llvmWrapper/Bitcode/BitcodeWriter.h"
1514+#include "llvmWrapper/IR/DerivedTypes.h"
1515 #include <llvm/Support/ScaledNumber.h>
1516 #include <llvm/Bitcode/BitcodeReader.h>
1517 #include "llvm/IR/DebugInfo.h"
1518@@ -384,7 +385,7 @@ bool GenUpdateCB::runOnFunction(Function& F)
1519 isResInfo(dyn_cast<GenIntrinsicInst>(inst,
1520 GenISAIntrinsic::GenISA_resinfoptr), texId, lod, isUAV))
1521 {
1522- unsigned nelems = (unsigned)cast<VectorType>(inst->getType())->getNumElements();
1523+ unsigned nelems = (unsigned)cast<IGCLLVM::FixedVectorType>(inst->getType())->getNumElements();
1524 SmallVector< SmallVector<ExtractElementInst*, 1>, 4> extracts(nelems);
1525 if (VectorUsedByConstExtractOnly(inst, extracts))
1526 {
1527diff --git a/IGC/Compiler/HandleFRemInstructions.cpp b/IGC/Compiler/HandleFRemInstructions.cpp
1528index 94995a56..4523f3f0 100644
1529--- a/IGC/Compiler/HandleFRemInstructions.cpp
1530+++ b/IGC/Compiler/HandleFRemInstructions.cpp
1531@@ -28,6 +28,7 @@ IN THE SOFTWARE.
1532 #include <llvm/IR/Instructions.h>
1533 #include <llvm/IR/InstIterator.h>
1534 #include <llvm/Transforms/Utils/BasicBlockUtils.h>
1535+#include "llvmWrapper/IR/DerivedTypes.h"
1536 #include "common/LLVMWarningsPop.hpp"
1537 #include "Compiler/IGCPassSupport.h"
1538 #include "Probe/Assertion.h"
1539@@ -77,7 +78,7 @@ void HandleFRemInstructions::visitFRem(llvm::BinaryOperator& I)
1540
1541 if (ValType->isVectorTy())
1542 {
1543- auto VecCount = cast<VectorType>(ValType)->getNumElements();
1544+ auto VecCount = cast<IGCLLVM::FixedVectorType>(ValType)->getNumElements();
1545 if (VecCount == 2 || VecCount == 3 || VecCount == 4 || VecCount == 8 || VecCount == 16)
1546 {
1547 VecStr = "v" + std::to_string(VecCount);
1548diff --git a/IGC/Compiler/HandleLoadStoreInstructions.cpp b/IGC/Compiler/HandleLoadStoreInstructions.cpp
1549index d18eec73..c5535701 100644
1550--- a/IGC/Compiler/HandleLoadStoreInstructions.cpp
1551+++ b/IGC/Compiler/HandleLoadStoreInstructions.cpp
1552@@ -77,7 +77,7 @@ void HandleLoadStoreInstructions::visitLoadInst(llvm::LoadInst& I)
1553
1554 if (I.getType()->isVectorTy())
1555 {
1556- numVectorElements = (uint32_t)cast<VectorType>(I.getType())->getNumElements();
1557+ numVectorElements = (uint32_t)cast<IGCLLVM::FixedVectorType>(I.getType())->getNumElements();
1558 doubleDstType = IGCLLVM::FixedVectorType::get(builder.getDoubleTy(), numVectorElements);
1559 }
1560 uint as = ptrv->getType()->getPointerAddressSpace();
1561@@ -163,7 +163,7 @@ void HandleLoadStoreInstructions::visitStoreInst(llvm::StoreInst& I)
1562
1563 if (I.getValueOperand()->getType()->isVectorTy())
1564 {
1565- numVectorElements = (uint32_t)cast<VectorType>(I.getValueOperand()->getType())->getNumElements();
1566+ numVectorElements = (uint32_t)cast<IGCLLVM::FixedVectorType>(I.getValueOperand()->getType())->getNumElements();
1567 }
1568
1569
1570diff --git a/IGC/Compiler/LegalizationPass.cpp b/IGC/Compiler/LegalizationPass.cpp
1571index b651350b..9524a495 100644
1572--- a/IGC/Compiler/LegalizationPass.cpp
1573+++ b/IGC/Compiler/LegalizationPass.cpp
1574@@ -670,7 +670,7 @@ void Legalization::visitBitCastInst(llvm::BitCastInst& I)
1575 if (!isa<TruncInst>(pZ->getOperand(0)))
1576 return;
1577
1578- auto* pVecTy = cast<VectorType>(pZ->getDestTy());
1579+ auto* pVecTy = cast<IGCLLVM::FixedVectorType>(pZ->getDestTy());
1580 if (pVecTy->getNumElements() != 3)
1581 return;
1582
1583@@ -765,7 +765,7 @@ void Legalization::visitSelectInst(SelectInst& I)
1584 }
1585 else if (I.getType()->isVectorTy())
1586 {
1587- unsigned int vecSize = (unsigned)cast<VectorType>(I.getType())->getNumElements();
1588+ unsigned int vecSize = (unsigned)cast<IGCLLVM::FixedVectorType>(I.getType())->getNumElements();
1589 Value* newVec = UndefValue::get(I.getType());
1590 m_builder->SetInsertPoint(&I);
1591 for (unsigned int i = 0; i < vecSize; i++)
1592@@ -1147,7 +1147,7 @@ void Legalization::visitStoreInst(StoreInst& I)
1593 if (ConstantDataVector * vec = dyn_cast<ConstantDataVector>(I.getOperand(0)))
1594 {
1595 Value* newVec = UndefValue::get(vec->getType());
1596- unsigned int nbElement = (unsigned)cast<VectorType>(vec->getType())->getNumElements();
1597+ unsigned int nbElement = (unsigned)cast<IGCLLVM::FixedVectorType>(vec->getType())->getNumElements();
1598 for (unsigned int i = 0; i < nbElement; i++)
1599 {
1600 Constant* cst = vec->getElementAsConstant(i);
1601@@ -1168,7 +1168,7 @@ void Legalization::visitStoreInst(StoreInst& I)
1602 else if (ConstantVector * vec = dyn_cast<ConstantVector>(I.getOperand(0)))
1603 {
1604 Value* newVec = UndefValue::get(vec->getType());
1605- unsigned int nbElement = (unsigned)cast<VectorType>(vec->getType())->getNumElements();
1606+ unsigned int nbElement = (unsigned)cast<IGCLLVM::FixedVectorType>(vec->getType())->getNumElements();
1607 for (unsigned int i = 0; i < nbElement; i++)
1608 {
1609 Constant* cst = vec->getOperand(i);
1610@@ -1189,7 +1189,7 @@ void Legalization::visitStoreInst(StoreInst& I)
1611 else if (ConstantAggregateZero * vec = dyn_cast<ConstantAggregateZero>(I.getOperand(0)))
1612 {
1613 Value* newVec = UndefValue::get(vec->getType());
1614- unsigned int nbElement = (unsigned)cast<VectorType>(vec->getType())->getNumElements();
1615+ unsigned int nbElement = (unsigned)cast<IGCLLVM::FixedVectorType>(vec->getType())->getNumElements();
1616 for (unsigned int i = 0; i < nbElement; i++)
1617 {
1618 Constant* cst = vec->getElementValue(i);
1619@@ -1340,7 +1340,7 @@ void Legalization::visitInsertElementInst(InsertElementInst& I)
1620 if (ConstantDataVector * vec = dyn_cast<ConstantDataVector>(I.getOperand(0)))
1621 {
1622 Value* newVec = UndefValue::get(vec->getType());
1623- unsigned int nbElement = (unsigned)cast<VectorType>(vec->getType())->getNumElements();
1624+ unsigned int nbElement = (unsigned)cast<IGCLLVM::FixedVectorType>(vec->getType())->getNumElements();
1625 for (unsigned int i = 0; i < nbElement; i++)
1626 {
1627 Constant* cst = vec->getElementAsConstant(i);
1628@@ -1360,7 +1360,7 @@ void Legalization::visitInsertElementInst(InsertElementInst& I)
1629 else if (ConstantVector * vec = dyn_cast<ConstantVector>(I.getOperand(0)))
1630 {
1631 Value* newVec = UndefValue::get(I.getType());
1632- unsigned int nbElement = (unsigned)cast<VectorType>(vec->getType())->getNumElements();
1633+ unsigned int nbElement = (unsigned)cast<IGCLLVM::FixedVectorType>(vec->getType())->getNumElements();
1634 for (unsigned int i = 0; i < nbElement; i++)
1635 {
1636 Constant* cst = vec->getOperand(i);
1637@@ -1380,7 +1380,7 @@ void Legalization::visitInsertElementInst(InsertElementInst& I)
1638 else if (ConstantAggregateZero * vec = dyn_cast<ConstantAggregateZero>(I.getOperand(0)))
1639 {
1640 Value* newVec = UndefValue::get(I.getType());
1641- unsigned int nbElement = (unsigned)cast<VectorType>(vec->getType())->getNumElements();
1642+ unsigned int nbElement = (unsigned)cast<IGCLLVM::FixedVectorType>(vec->getType())->getNumElements();
1643 for (unsigned int i = 0; i < nbElement; i++)
1644 {
1645 Constant* cst = vec->getElementValue(i);
1646@@ -1397,7 +1397,7 @@ void Legalization::visitInsertElementInst(InsertElementInst& I)
1647 else if (I.getOperand(1)->getType()->isIntegerTy(1))
1648 {
1649 // This promotes i1 insertelement to i32
1650- unsigned int nbElement = (unsigned)cast<VectorType>(I.getOperand(0)->getType())->getNumElements();
1651+ unsigned int nbElement = (unsigned)cast<IGCLLVM::FixedVectorType>(I.getOperand(0)->getType())->getNumElements();
1652 Value* newVec = UndefValue::get(IGCLLVM::FixedVectorType::get(m_builder->getInt32Ty(), nbElement));
1653 PromoteInsertElement(&I, newVec);
1654 }
1655@@ -1410,7 +1410,7 @@ void Legalization::visitShuffleVectorInst(ShuffleVectorInst& I)
1656 // If the original vector is a constant, just use the scalar constant,
1657 // otherwise extract from the original vector.
1658
1659- VectorType* resType = cast<VectorType>(I.getType());
1660+ IGCLLVM::FixedVectorType* resType = cast<IGCLLVM::FixedVectorType>(I.getType());
1661 Value* newVec = UndefValue::get(resType);
1662 Value* src0 = I.getOperand(0);
1663 Value* src1 = I.getOperand(1);
1664@@ -1421,7 +1421,7 @@ void Legalization::visitShuffleVectorInst(ShuffleVectorInst& I)
1665 Constant* mask = I.getShuffleMaskForBitcode();
1666 #endif
1667 // The two inputs are guaranteed to be of the same type
1668- VectorType* inType = cast<VectorType>(src0->getType());
1669+ IGCLLVM::FixedVectorType* inType = cast<IGCLLVM::FixedVectorType>(src0->getType());
1670 int inCount = int_cast<int>(inType->getNumElements());
1671 int inBase = 2; // 2 means using undef
1672 // if inType == resType, use src0/src1 as the input
1673@@ -1637,7 +1637,7 @@ Type* Legalization::LegalAllocaType(Type* type) const
1674 #endif
1675 legalType = IGCLLVM::FixedVectorType::get(
1676 LegalAllocaType(cast<VectorType>(type)->getElementType()),
1677- (unsigned)cast<VectorType>(type)->getNumElements());
1678+ (unsigned)cast<IGCLLVM::FixedVectorType>(type)->getNumElements());
1679 break;
1680 case Type::StructTyID:
1681 return LegalStructAllocaType(type);
1682@@ -1937,7 +1937,7 @@ void Legalization::visitIntrinsicInst(llvm::IntrinsicInst& I)
1683 Value* newValue = nullptr;
1684 if (srcType->isVectorTy())
1685 {
1686- auto sourceVT = cast<VectorType>(srcType);
1687+ auto sourceVT = cast<IGCLLVM::FixedVectorType>(srcType);
1688 const unsigned int numElements = (uint32_t)sourceVT->getNumElements();
1689 Value* dstVec = UndefValue::get(srcType);
1690 for (unsigned int i = 0; i < numElements; ++i)
1691@@ -2081,7 +2081,7 @@ void Legalization::visitTruncInst(llvm::TruncInst& I) {
1692 }
1693
1694 Src = BC->getOperand(0);
1695- VectorType* VTy = dyn_cast<VectorType>(Src->getType());
1696+ IGCLLVM::FixedVectorType* VTy = dyn_cast<IGCLLVM::FixedVectorType>(Src->getType());
1697 // Bail out if it's not bitcasted from <3 x i16>
1698 if (!VTy || VTy->getNumElements() != 3 || !VTy->getElementType()->isIntegerTy(16))
1699 return;
1700diff --git a/IGC/Compiler/Legalizer/InstPromoter.cpp b/IGC/Compiler/Legalizer/InstPromoter.cpp
1701index bba1d96d..8fadf89f 100644
1702--- a/IGC/Compiler/Legalizer/InstPromoter.cpp
1703+++ b/IGC/Compiler/Legalizer/InstPromoter.cpp
1704@@ -25,6 +25,7 @@ IN THE SOFTWARE.
1705 #define DEBUG_TYPE "type-legalizer"
1706 #include "TypeLegalizer.h"
1707 #include "InstPromoter.h"
1708+#include "llvmWrapper/IR/DerivedTypes.h"
1709 #include "common/LLVMWarningsPush.hpp"
1710 #include "llvm/Support/Debug.h"
1711 #include "llvm/Support/MathExtras.h"
1712@@ -394,10 +395,16 @@ bool InstPromoter::visitBitCastInst(BitCastInst& I) {
1713 unsigned N =
1714 Val->getType()->getScalarSizeInBits() / DestTy->getScalarSizeInBits();
1715 Value* BC =
1716- IRB->CreateBitCast(Val, VectorType::get(DestTy->getScalarType(), N));
1717+ IRB->CreateBitCast(Val, IGCLLVM::FixedVectorType::get(DestTy->getScalarType(), N));
1718
1719 std::vector<Constant*> Vals;
1720- for (unsigned i = 0; i < DestTy->getVectorNumElements(); i++)
1721+ for (unsigned i = 0;
1722+#if LLVM_VERSION_MAJOR >= 12
1723+ i < cast<IGCLLVM::FixedVectorType>(DestTy)->getNumElements();
1724+#else
1725+ i < DestTy->getVectorNumElements();
1726+#endif
1727+ i++)
1728 Vals.push_back(IRB->getInt32(i));
1729
1730 Value* Mask = ConstantVector::get(Vals);
1731diff --git a/IGC/Compiler/Legalizer/InstScalarizer.cpp b/IGC/Compiler/Legalizer/InstScalarizer.cpp
1732index 3902f740..c8e18cc5 100644
1733--- a/IGC/Compiler/Legalizer/InstScalarizer.cpp
1734+++ b/IGC/Compiler/Legalizer/InstScalarizer.cpp
1735@@ -130,7 +130,7 @@ bool InstScalarizer::visitLoadInst(LoadInst& I) {
1736 // otherwise, it's broken.
1737 IGC_ASSERT(TL->getTypeSizeInBits(EltTy) == TL->getTypeStoreSizeInBits(EltTy));
1738
1739- unsigned NumElts = (unsigned)cast<VectorType>(OrigTy)->getNumElements();
1740+ unsigned NumElts = (unsigned)cast<IGCLLVM::FixedVectorType>(OrigTy)->getNumElements();
1741 unsigned Elt = 0;
1742
1743 Type* NewPtrTy = PointerType::get(EltTy, AS);
1744@@ -268,7 +268,7 @@ bool InstScalarizer::visitStoreInst(StoreInst& I) {
1745 // otherwise, it's broken.
1746 IGC_ASSERT(TL->getTypeSizeInBits(EltTy) == TL->getTypeStoreSizeInBits(EltTy));
1747
1748- unsigned NumElts = (unsigned)cast<VectorType>(OrigTy)->getNumElements();
1749+ unsigned NumElts = (unsigned)cast<IGCLLVM::FixedVectorType>(OrigTy)->getNumElements();
1750 unsigned Elt = 0;
1751
1752 Type* NewPtrTy = PointerType::get(EltTy, AS);
1753@@ -498,7 +498,7 @@ bool InstScalarizer::visitInsertElementInst(InsertElementInst& I) {
1754 IGC_ASSERT(EltSeq->size());
1755 IGC_ASSERT(VecSeqCopy.size() % EltSeq->size() == 0);
1756
1757- unsigned NumElts = (unsigned)cast<VectorType>(I.getOperand(0)->getType())->getNumElements();
1758+ unsigned NumElts = (unsigned)cast<IGCLLVM::FixedVectorType>(I.getOperand(0)->getType())->getNumElements();
1759 unsigned i = 0;
1760 for (unsigned Elt = 0; Elt != NumElts; ++Elt) {
1761 if (Elt == Idx) {
1762diff --git a/IGC/Compiler/Legalizer/PeepholeTypeLegalizer.cpp b/IGC/Compiler/Legalizer/PeepholeTypeLegalizer.cpp
1763index 28f8ce84..778132c4 100644
1764--- a/IGC/Compiler/Legalizer/PeepholeTypeLegalizer.cpp
1765+++ b/IGC/Compiler/Legalizer/PeepholeTypeLegalizer.cpp
1766@@ -162,7 +162,7 @@ void PeepholeTypeLegalizer::legalizePhiInstruction(Instruction& I)
1767
1768 if (quotient > 1)
1769 {
1770- unsigned numElements = I.getType()->isVectorTy() ? (unsigned)cast<VectorType>(I.getType())->getNumElements() : 1;
1771+ unsigned numElements = I.getType()->isVectorTy() ? (unsigned)cast<IGCLLVM::FixedVectorType>(I.getType())->getNumElements() : 1;
1772 Type* newType = IGCLLVM::FixedVectorType::get(Type::getIntNTy(I.getContext(), promoteToInt), quotient * numElements);
1773
1774 PHINode* newPhi = m_builder->CreatePHI(newType, oldPhi->getNumIncomingValues());
1775@@ -223,7 +223,7 @@ void PeepholeTypeLegalizer::legalizeExtractElement(Instruction& I)
1776 unsigned elementWidth = extract->getType()->getScalarSizeInBits();
1777 if (!isLegalInteger(elementWidth) && extract->getType()->isIntOrIntVectorTy())
1778 {
1779- unsigned numElements = (unsigned)cast<VectorType>(extract->getOperand(0)->getType())->getNumElements();
1780+ unsigned numElements = (unsigned)cast<IGCLLVM::FixedVectorType>(extract->getOperand(0)->getType())->getNumElements();
1781 unsigned quotient, promoteToInt;
1782 promoteInt(elementWidth, quotient, promoteToInt, DL->getLargestLegalIntTypeSizeInBits());
1783
1784@@ -850,7 +850,7 @@ void PeepholeTypeLegalizer::cleanupZExtInst(Instruction& I) {
1785 }
1786
1787 unsigned ipElmtSize = prevInst->getOperand(0)->getType()->getScalarSizeInBits();
1788- unsigned ipVecSize = (unsigned)cast<VectorType>(prevInst->getOperand(0)->getType())->getNumElements();
1789+ unsigned ipVecSize = (unsigned)cast<IGCLLVM::FixedVectorType>(prevInst->getOperand(0)->getType())->getNumElements();
1790 unsigned convFactor = promoteToInt / ipElmtSize;
1791
1792 Value* vecRes = UndefValue::get(IGCLLVM::FixedVectorType::get(llvm::Type::getIntNTy(I.getContext(), promoteToInt), quotient));
1793diff --git a/IGC/Compiler/Legalizer/TypeLegalizer.cpp b/IGC/Compiler/Legalizer/TypeLegalizer.cpp
1794index f8f71d71..a46f42bd 100644
1795--- a/IGC/Compiler/Legalizer/TypeLegalizer.cpp
1796+++ b/IGC/Compiler/Legalizer/TypeLegalizer.cpp
1797@@ -32,6 +32,7 @@ IN THE SOFTWARE.
1798 #include "InstScalarizer.h"
1799 #include "InstElementizer.h"
1800 #include "common/LLVMWarningsPush.hpp"
1801+#include "llvmWrapper/IR/DerivedTypes.h"
1802 #include "llvm/ADT/PostOrderIterator.h"
1803 #include "llvm/IR/CFG.h"
1804 #include "llvm/Support/Debug.h"
1805@@ -290,7 +291,7 @@ TypeSeq* TypeLegalizer::getScalarizedTypeSeq(Type* Ty) {
1806 }
1807
1808 Type* EltTy = cast<VectorType>(Ty)->getElementType();
1809- for (unsigned i = 0, e = (unsigned)cast<VectorType>(Ty)->getNumElements(); i != e; ++i)
1810+ for (unsigned i = 0, e = (unsigned)cast<IGCLLVM::FixedVectorType>(Ty)->getNumElements(); i != e; ++i)
1811 TMI->second.push_back(EltTy);
1812
1813 return &TMI->second;
1814diff --git a/IGC/Compiler/Legalizer/TypeLegalizer.h b/IGC/Compiler/Legalizer/TypeLegalizer.h
1815index f3ce264c..a6910d08 100644
1816--- a/IGC/Compiler/Legalizer/TypeLegalizer.h
1817+++ b/IGC/Compiler/Legalizer/TypeLegalizer.h
1818@@ -28,6 +28,7 @@ IN THE SOFTWARE.
1819 #include "llvmWrapper/IR/Instructions.h"
1820 #include "llvmWrapper/Analysis/InlineCost.h"
1821 #include "llvmWrapper/IR/InstrTypes.h"
1822+#include "llvmWrapper/IR/DerivedTypes.h"
1823 #include "llvmWrapper/Support/Alignment.h"
1824 #include "llvm/ADT/ArrayRef.h"
1825 #include "llvm/ADT/DenseMap.h"
1826@@ -287,7 +288,7 @@ namespace IGC {
1827 if (!Ty->isVectorTy())
1828 return false;
1829
1830- unsigned NumElts = (unsigned)cast<VectorType>(Ty)->getNumElements();
1831+ unsigned NumElts = (unsigned)cast<IGCLLVM::FixedVectorType>(Ty)->getNumElements();
1832 Type* EltTy = cast<VectorType>(Ty)->getElementType();
1833 const auto& ProfitLengths = getProfitLoadVectorLength(EltTy);
1834
1835diff --git a/IGC/Compiler/LowPrecisionOptPass.cpp b/IGC/Compiler/LowPrecisionOptPass.cpp
1836index 64912719..1d1db949 100644
1837--- a/IGC/Compiler/LowPrecisionOptPass.cpp
1838+++ b/IGC/Compiler/LowPrecisionOptPass.cpp
1839@@ -252,7 +252,7 @@ bool LowPrecisionOpt::propagateSamplerType(llvm::GenIntrinsicInst& I)
1840 return false;
1841 }
1842
1843- VectorType* oldTy = cast<VectorType>(I.getType());
1844+ IGCLLVM::FixedVectorType* oldTy = cast<IGCLLVM::FixedVectorType>(I.getType());
1845 llvm::SmallVector<llvm::Type*, 4> overloadTys;
1846 auto retTy = IGCLLVM::FixedVectorType::get(newDstType, int_cast<unsigned int>(oldTy->getNumElements()));
1847 overloadTys.push_back(retTy);
1848diff --git a/IGC/Compiler/Optimizer/OpenCLPasses/AddressSpaceAliasAnalysis/AddressSpaceAliasAnalysis.cpp b/IGC/Compiler/Optimizer/OpenCLPasses/AddressSpaceAliasAnalysis/AddressSpaceAliasAnalysis.cpp
1849index 393b4b0a..e9c07b34 100644
1850--- a/IGC/Compiler/Optimizer/OpenCLPasses/AddressSpaceAliasAnalysis/AddressSpaceAliasAnalysis.cpp
1851+++ b/IGC/Compiler/Optimizer/OpenCLPasses/AddressSpaceAliasAnalysis/AddressSpaceAliasAnalysis.cpp
1852@@ -23,6 +23,8 @@ IN THE SOFTWARE.
1853 ============================= end_copyright_notice ===========================*/
1854
1855 #include "llvm/Config/llvm-config.h"
1856+#include "llvmWrapper/IR/DerivedTypes.h"
1857+#include "llvmWrapper/Analysis/TargetLibraryInfo.h"
1858 #include "Compiler/Optimizer/OpenCLPasses/AddressSpaceAliasAnalysis/AddressSpaceAliasAnalysis.h"
1859 #include "Compiler/CodeGenPublic.h"
1860 #include "Compiler/IGCPassSupport.h"
1861@@ -178,12 +180,11 @@ namespace {
1862 bool doInitialization(Module& M) override {
1863 if(M.size() > 0)
1864 {
1865- Result.reset(new AddressSpaceAAResult(
1866- getAnalysis<TargetLibraryInfoWrapperPass>().getTLI(
1867 #if LLVM_VERSION_MAJOR >= 10
1868- *M.begin()
1869+ Function &F = *M.begin();
1870 #endif
1871- ),
1872+ Result.reset(new AddressSpaceAAResult(
1873+ getAnalysis<TargetLibraryInfoWrapperPass>().getTLI(),
1874 *getAnalysis<CodeGenContextWrapper>().getCodeGenContext()));
1875 }
1876 return false;
1877diff --git a/IGC/Compiler/Optimizer/OpenCLPasses/AggregateArguments/AggregateArguments.cpp b/IGC/Compiler/Optimizer/OpenCLPasses/AggregateArguments/AggregateArguments.cpp
1878index 67535cfc..3cdd2975 100644
1879--- a/IGC/Compiler/Optimizer/OpenCLPasses/AggregateArguments/AggregateArguments.cpp
1880+++ b/IGC/Compiler/Optimizer/OpenCLPasses/AggregateArguments/AggregateArguments.cpp
1881@@ -24,6 +24,7 @@ IN THE SOFTWARE.
1882
1883 #include "Compiler/Optimizer/OpenCLPasses/AggregateArguments/AggregateArguments.hpp"
1884 #include "Compiler/IGCPassSupport.h"
1885+#include "llvmWrapper/IR/DerivedTypes.h"
1886 #include "common/LLVMWarningsPush.hpp"
1887 #include "llvm/IR/Function.h"
1888 #include "common/LLVMWarningsPop.hpp"
1889@@ -130,7 +131,7 @@ static uint64_t getNumElements(Type* type)
1890 {
1891 return arrayType->getNumElements();
1892 }
1893- if (VectorType * vectorType = dyn_cast<VectorType>(type))
1894+ if (IGCLLVM::FixedVectorType * vectorType = dyn_cast<IGCLLVM::FixedVectorType>(type))
1895 {
1896 return vectorType->getNumElements();
1897 }
1898diff --git a/IGC/Compiler/Optimizer/OpenCLPasses/CorrectlyRoundedDivSqrt/CorrectlyRoundedDivSqrt.cpp b/IGC/Compiler/Optimizer/OpenCLPasses/CorrectlyRoundedDivSqrt/CorrectlyRoundedDivSqrt.cpp
1899index 2a9d7499..79ed0948 100644
1900--- a/IGC/Compiler/Optimizer/OpenCLPasses/CorrectlyRoundedDivSqrt/CorrectlyRoundedDivSqrt.cpp
1901+++ b/IGC/Compiler/Optimizer/OpenCLPasses/CorrectlyRoundedDivSqrt/CorrectlyRoundedDivSqrt.cpp
1902@@ -27,6 +27,7 @@ IN THE SOFTWARE.
1903 #include "Compiler/IGCPassSupport.h"
1904 #include "GenISAIntrinsics/GenIntrinsicInst.h"
1905
1906+#include "llvmWrapper/IR/DerivedTypes.h"
1907 #include "common/LLVMWarningsPush.hpp"
1908 #include <llvm/IR/Function.h>
1909 #include <llvm/IR/Instructions.h>
1910@@ -133,7 +134,7 @@ Value* CorrectlyRoundedDivSqrt::emitIEEEDivide(BinaryOperator* I, Value* Op0, Va
1911 }
1912 else
1913 {
1914- auto vType = dyn_cast<VectorType>(Ty);
1915+ auto vType = dyn_cast<IGCLLVM::FixedVectorType>(Ty);
1916 unsigned VecLen = (uint32_t)vType->getNumElements();
1917 Divide = UndefValue::get(Ty);
1918 for (unsigned i = 0; i < VecLen; i++)
1919diff --git a/IGC/Compiler/Optimizer/OpenCLPasses/DeviceEnqueueFuncs/TransformBlocks.cpp b/IGC/Compiler/Optimizer/OpenCLPasses/DeviceEnqueueFuncs/TransformBlocks.cpp
1920index c5ff3ac0..119520ed 100644
1921--- a/IGC/Compiler/Optimizer/OpenCLPasses/DeviceEnqueueFuncs/TransformBlocks.cpp
1922+++ b/IGC/Compiler/Optimizer/OpenCLPasses/DeviceEnqueueFuncs/TransformBlocks.cpp
1923@@ -952,7 +952,11 @@ namespace //Anonymous
1924 {
1925 auto ndrangeStructName = "struct.ndrange_t";
1926 auto module = _deviceExecCall->getModule();
1927+#if LLVM_VERSION_MAJOR >= 12
1928+ auto ndrangeTy = llvm::StructType::getTypeByName(module->getContext(), ndrangeStructName);
1929+#else
1930 auto ndrangeTy = module->getTypeByName(ndrangeStructName);
1931+#endif
1932 if (ndrangeTy == nullptr)
1933 {
1934 //create struct type
1935@@ -1697,7 +1701,7 @@ namespace //Anonymous
1936 // this generates <element_type><num_elements> string. Ie for char2 element_type is char and num_elements is 2
1937 // that is done by callin BaseTypeName on vector element type, this recursive call has only a depth of one since
1938 // there are no compound vectors in OpenCL.
1939- auto vType = llvm::dyn_cast<VectorType>(type);
1940+ auto vType = llvm::dyn_cast<IGCLLVM::FixedVectorType>(type);
1941 return BaseTypeName(type->getContainedType(0), os) << vType->getNumElements();
1942 }
1943 default:
1944diff --git a/IGC/Compiler/Optimizer/OpenCLPasses/KernelArgs.cpp b/IGC/Compiler/Optimizer/OpenCLPasses/KernelArgs.cpp
1945index 6448463d..7df71079 100644
1946--- a/IGC/Compiler/Optimizer/OpenCLPasses/KernelArgs.cpp
1947+++ b/IGC/Compiler/Optimizer/OpenCLPasses/KernelArgs.cpp
1948@@ -24,6 +24,7 @@ IN THE SOFTWARE.
1949
1950 #include "Compiler/Optimizer/OpenCLPasses/KernelArgs.hpp"
1951 #include "AdaptorCommon/ImplicitArgs.hpp"
1952+#include "llvmWrapper/IR/DerivedTypes.h"
1953 #include "common/LLVMWarningsPush.hpp"
1954 #include <llvm/IR/Argument.h>
1955 #include <llvm/IR/DataLayout.h>
1956@@ -388,7 +389,7 @@ unsigned int KernelArg::calcAssociatedArgNo(const ImplicitArg& implicitArg, cons
1957
1958 unsigned int KernelArg::getNumComponents() const
1959 {
1960- if (VectorType * vecType = dyn_cast<VectorType>(m_arg->getType()))
1961+ if (IGCLLVM::FixedVectorType * vecType = dyn_cast<IGCLLVM::FixedVectorType>(m_arg->getType()))
1962 {
1963 // Vector
1964 return int_cast<unsigned int>(vecType->getNumElements());
1965diff --git a/IGC/Compiler/Optimizer/OpenCLPasses/OpenCLPrintf/OpenCLPrintfResolution.cpp b/IGC/Compiler/Optimizer/OpenCLPasses/OpenCLPrintf/OpenCLPrintfResolution.cpp
1966index c7414b8e..74964510 100644
1967--- a/IGC/Compiler/Optimizer/OpenCLPasses/OpenCLPrintf/OpenCLPrintfResolution.cpp
1968+++ b/IGC/Compiler/Optimizer/OpenCLPasses/OpenCLPrintf/OpenCLPrintfResolution.cpp
1969@@ -719,7 +719,7 @@ Value* OpenCLPrintfResolution::fixupPrintfArg(CallInst& printfCall, Value* arg,
1970 }
1971
1972 Type* newType = Type::getFloatTy(arg->getContext());
1973- if (auto argVT = dyn_cast<VectorType>(arg->getType()))
1974+ if (auto argVT = dyn_cast<IGCLLVM::FixedVectorType>(arg->getType()))
1975 {
1976 newType = IGCLLVM::FixedVectorType::get(newType, (unsigned)argVT->getNumElements());
1977 }
1978@@ -749,7 +749,7 @@ void OpenCLPrintfResolution::preprocessPrintfArgs(CallInst& printfCall)
1979 IGC::SHADER_PRINTF_TYPE argDataType = getPrintfArgDataType(arg);
1980 arg = fixupPrintfArg(printfCall, arg, argDataType);
1981 uint vecSize = 0;
1982- if (auto argVType = dyn_cast<VectorType>(argType)) {
1983+ if (auto argVType = dyn_cast<IGCLLVM::FixedVectorType>(argType)) {
1984 vecSize = (uint)argVType->getNumElements();
1985 }
1986 m_argDescriptors.push_back(SPrintfArgDescriptor(argDataType, arg, vecSize));
1987diff --git a/IGC/Compiler/Optimizer/OpenCLPasses/PrivateMemory/PrivateMemoryResolution.cpp b/IGC/Compiler/Optimizer/OpenCLPasses/PrivateMemory/PrivateMemoryResolution.cpp
1988index 2ed5a2b6..07f85f4c 100644
1989--- a/IGC/Compiler/Optimizer/OpenCLPasses/PrivateMemory/PrivateMemoryResolution.cpp
1990+++ b/IGC/Compiler/Optimizer/OpenCLPasses/PrivateMemory/PrivateMemoryResolution.cpp
1991@@ -29,6 +29,7 @@ IN THE SOFTWARE.
1992 #include "Compiler/IGCPassSupport.h"
1993 #include "Compiler/CISACodeGen/GenCodeGenModule.h"
1994 #include "Compiler/CISACodeGen/LowerGEPForPrivMem.hpp"
1995+#include "llvmWrapper/IR/DerivedTypes.h"
1996 #include "common/LLVMWarningsPush.hpp"
1997 #include "llvm/Transforms/Utils/Local.h"
1998 #include "llvm/IR/DataLayout.h"
1999@@ -604,7 +605,7 @@ public:
2000 Type* scalarptrTy = PointerType::get(scalarType, pLoad->getPointerAddressSpace());
2001 IGC_ASSERT(scalarType->getPrimitiveSizeInBits() / 8 == elementSize);
2002 Value* vec = UndefValue::get(pLoad->getType());
2003- auto pLoadVT = cast<VectorType>(pLoad->getType());
2004+ auto pLoadVT = cast<IGCLLVM::FixedVectorType>(pLoad->getType());
2005 for (unsigned i = 0, e = (unsigned)pLoadVT->getNumElements(); i < e; ++i)
2006 {
2007 Value* ptr = IRB.CreateIntToPtr(address, scalarptrTy);
2008@@ -643,7 +644,7 @@ public:
2009 IGC_ASSERT(scalarType->getPrimitiveSizeInBits() / 8 == elementSize);
2010 Value* vec = pStore->getValueOperand();
2011
2012- unsigned vecNumElts = (unsigned)cast<VectorType>(vec->getType())->getNumElements();
2013+ unsigned vecNumElts = (unsigned)cast<IGCLLVM::FixedVectorType>(vec->getType())->getNumElements();
2014 for (unsigned i = 0; i < vecNumElts; ++i)
2015 {
2016 Value* ptr = IRB.CreateIntToPtr(address, scalarptrTy);
2017@@ -707,7 +708,7 @@ bool PrivateMemoryResolution::testTransposedMemory(const Type* pTmpType, const T
2018 }
2019 else if(pTmpType->isVectorTy())
2020 {
2021- auto pTmpVType = cast<VectorType>(pTmpType);
2022+ auto pTmpVType = cast<IGCLLVM::FixedVectorType>(pTmpType);
2023 tmpAllocaSize *= pTmpVType->getNumElements();
2024 pTmpType = pTmpType->getContainedType(0);
2025 ok = (nullptr != pTmpType);
2026@@ -815,7 +816,11 @@ bool PrivateMemoryResolution::resolveAllocaInstructions(bool privateOnStack)
2027 // Construct an empty DebugLoc.
2028 IF_DEBUG_INFO(DebugLoc entryDebugLoc);
2029 // Assign with the function location if available.
2030+#if LLVM_VERSION_MAJOR >= 12
2031+ IF_DEBUG_INFO_IF(DISubprogram *subprogram = m_currFunction->getSubprogram(), entryDebugLoc = DILocation::get(subprogram->getContext(), subprogram->getLine(), 0, subprogram););
2032+#else
2033 IF_DEBUG_INFO_IF(DISubprogram *subprogram = m_currFunction->getSubprogram(), entryDebugLoc = DebugLoc::get(subprogram->getLine(), 0, subprogram););
2034+#endif
2035 IF_DEBUG_INFO(entryBuilder.SetCurrentDebugLocation(entryDebugLoc));
2036
2037 if (privateOnStack)
2038diff --git a/IGC/Compiler/Optimizer/OpenCLPasses/ReplaceUnsupportedIntrinsics/ReplaceUnsupportedIntrinsics.cpp b/IGC/Compiler/Optimizer/OpenCLPasses/ReplaceUnsupportedIntrinsics/ReplaceUnsupportedIntrinsics.cpp
2039index c8414efa..68491d48 100644
2040--- a/IGC/Compiler/Optimizer/OpenCLPasses/ReplaceUnsupportedIntrinsics/ReplaceUnsupportedIntrinsics.cpp
2041+++ b/IGC/Compiler/Optimizer/OpenCLPasses/ReplaceUnsupportedIntrinsics/ReplaceUnsupportedIntrinsics.cpp
2042@@ -254,7 +254,7 @@ Instruction* ReplaceUnsupportedIntrinsics::insertLoop(Instruction* Loc, Value* L
2043 Value* ReplaceUnsupportedIntrinsics::replicateScalar(
2044 Value* ScalarVal, Type* Ty, Instruction* InsertBefore)
2045 {
2046- VectorType* VTy = dyn_cast<VectorType>(Ty);
2047+ IGCLLVM::FixedVectorType* VTy = dyn_cast<IGCLLVM::FixedVectorType>(Ty);
2048 Type* ETy = VTy ? VTy->getElementType() : Ty;
2049 uint32_t sBits = (unsigned int)ScalarVal->getType()->getPrimitiveSizeInBits();
2050 uint32_t nBits = (unsigned int)ETy->getPrimitiveSizeInBits();
2051@@ -868,7 +868,7 @@ void ReplaceUnsupportedIntrinsics::replaceFunnelShift(IntrinsicInst* I) {
2052 }
2053
2054 Value* numBits = Builder.getIntN(sizeInBits, sizeInBits);
2055- if (auto IVT = dyn_cast<VectorType>(I->getType())) {
2056+ if (auto IVT = dyn_cast<IGCLLVM::FixedVectorType>(I->getType())) {
2057 numBits = ConstantVector::getSplat(IGCLLVM::getElementCount((uint32_t)IVT->getNumElements()), cast<Constant>(numBits));
2058 }
2059 auto shiftModulo = Builder.CreateURem(I->getArgOperand(2), numBits);
2060diff --git a/IGC/Compiler/Optimizer/OpenCLPasses/WIFuncs/WIFuncResolution.cpp b/IGC/Compiler/Optimizer/OpenCLPasses/WIFuncs/WIFuncResolution.cpp
2061index 7188cc50..535d6268 100644
2062--- a/IGC/Compiler/Optimizer/OpenCLPasses/WIFuncs/WIFuncResolution.cpp
2063+++ b/IGC/Compiler/Optimizer/OpenCLPasses/WIFuncs/WIFuncResolution.cpp
2064@@ -303,7 +303,11 @@ static Value* BuildLoadInst(CallInst& CI, unsigned int Offset, Type* DataType)
2065 auto Size = ElemByteSize;
2066 if (DataType->isVectorTy())
2067 {
2068+#if LLVM_VERSION_MAJOR >= 12
2069+ Size *= cast<IGCLLVM::FixedVectorType>(DataType)->getNumElements();
2070+#else
2071 Size *= DataType->getVectorNumElements();
2072+#endif
2073 }
2074 unsigned int AlignedOffset = (Offset / ElemByteSize) * ElemByteSize;
2075 unsigned int LoadByteSize = (Offset == AlignedOffset) ? Size : Size * 2;
2076diff --git a/IGC/Compiler/Optimizer/PreCompiledFuncImport.cpp b/IGC/Compiler/Optimizer/PreCompiledFuncImport.cpp
2077index 1fda21d5..63a22864 100644
2078--- a/IGC/Compiler/Optimizer/PreCompiledFuncImport.cpp
2079+++ b/IGC/Compiler/Optimizer/PreCompiledFuncImport.cpp
2080@@ -340,7 +340,7 @@ bool PreCompiledFuncImport::preProcessDouble()
2081 }
2082 else
2083 {
2084- uint32_t vectorSize = cast<VectorType>(Inst->getType())->getNumElements();
2085+ uint32_t vectorSize = cast<IGCLLVM::FixedVectorType>(Inst->getType())->getNumElements();
2086 fsub = llvm::UndefValue::get(Inst->getType());
2087
2088 for (uint32_t i = 0; i < vectorSize; ++i)
2089@@ -936,7 +936,7 @@ void PreCompiledFuncImport::processDivide(BinaryOperator& inst, EmulatedFunction
2090
2091 Type* argumentType = inst.getOperand(0)->getType();
2092
2093- if (auto argumentVType = dyn_cast<VectorType>(argumentType))
2094+ if (auto argumentVType = dyn_cast<IGCLLVM::FixedVectorType>(argumentType))
2095 {
2096 numElements = (unsigned)argumentVType->getNumElements();
2097 }
2098diff --git a/IGC/Compiler/Optimizer/Scalarizer.cpp b/IGC/Compiler/Optimizer/Scalarizer.cpp
2099index 4f59eaf9..a4e73a6d 100644
2100--- a/IGC/Compiler/Optimizer/Scalarizer.cpp
2101+++ b/IGC/Compiler/Optimizer/Scalarizer.cpp
2102@@ -289,7 +289,7 @@ void ScalarizeFunction::scalarizeInstruction(BinaryOperator* BI)
2103 {
2104 V_PRINT(scalarizer, "\t\tBinary instruction\n");
2105 IGC_ASSERT_MESSAGE(BI, "instruction type dynamic cast failed");
2106- VectorType* instType = dyn_cast<VectorType>(BI->getType());
2107+ IGCLLVM::FixedVectorType* instType = dyn_cast<IGCLLVM::FixedVectorType>(BI->getType());
2108 // Only need handling for vector binary ops
2109 if (!instType) return;
2110
2111@@ -349,7 +349,7 @@ void ScalarizeFunction::scalarizeInstruction(CmpInst* CI)
2112 {
2113 V_PRINT(scalarizer, "\t\tCompare instruction\n");
2114 IGC_ASSERT_MESSAGE(CI, "instruction type dynamic cast failed");
2115- VectorType* instType = dyn_cast<VectorType>(CI->getType());
2116+ IGCLLVM::FixedVectorType* instType = dyn_cast<IGCLLVM::FixedVectorType>(CI->getType());
2117 // Only need handling for vector compares
2118 if (!instType) return;
2119
2120@@ -397,13 +397,13 @@ void ScalarizeFunction::scalarizeInstruction(CastInst* CI)
2121 {
2122 V_PRINT(scalarizer, "\t\tCast instruction\n");
2123 IGC_ASSERT_MESSAGE(CI, "instruction type dynamic cast failed");
2124- VectorType* instType = dyn_cast<VectorType>(CI->getType());
2125+ IGCLLVM::FixedVectorType* instType = dyn_cast<IGCLLVM::FixedVectorType>(CI->getType());
2126
2127 // For BitCast - we only scalarize if src and dst types have same vector length
2128 if (isa<BitCastInst>(CI))
2129 {
2130 if (!instType) return recoverNonScalarizableInst(CI);
2131- VectorType* srcType = dyn_cast<VectorType>(CI->getOperand(0)->getType());
2132+ IGCLLVM::FixedVectorType* srcType = dyn_cast<IGCLLVM::FixedVectorType>(CI->getOperand(0)->getType());
2133 if (!srcType || (instType->getNumElements() != srcType->getNumElements()))
2134 {
2135 return recoverNonScalarizableInst(CI);
2136@@ -458,7 +458,7 @@ void ScalarizeFunction::scalarizeInstruction(PHINode* PI)
2137 {
2138 V_PRINT(scalarizer, "\t\tPHI instruction\n");
2139 IGC_ASSERT_MESSAGE(PI, "instruction type dynamic cast failed");
2140- VectorType* instType = dyn_cast<VectorType>(PI->getType());
2141+ IGCLLVM::FixedVectorType* instType = dyn_cast<IGCLLVM::FixedVectorType>(PI->getType());
2142 // Only need handling for vector PHI
2143 if (!instType) return;
2144
2145@@ -569,7 +569,7 @@ void ScalarizeFunction::scalarizeInstruction(SelectInst* SI)
2146 {
2147 V_PRINT(scalarizer, "\t\tSelect instruction\n");
2148 IGC_ASSERT_MESSAGE(SI, "instruction type dynamic cast failed");
2149- VectorType* instType = dyn_cast<VectorType>(SI->getType());
2150+ IGCLLVM::FixedVectorType* instType = dyn_cast<IGCLLVM::FixedVectorType>(SI->getType());
2151 // Only need handling for vector select
2152 if (!instType) return;
2153
2154@@ -651,7 +651,7 @@ void ScalarizeFunction::scalarizeInstruction(ExtractElementInst* EI)
2155
2156 // Connect the "extracted" value to all its consumers
2157 uint64_t scalarIndex = cast<ConstantInt>(scalarIndexVal)->getZExtValue();
2158- auto valueVType = cast<VectorType>(vectorValue->getType());
2159+ auto valueVType = cast<IGCLLVM::FixedVectorType>(vectorValue->getType());
2160 if (static_cast<unsigned int>(scalarIndex) < (unsigned)valueVType->getNumElements())
2161 {
2162 IGC_ASSERT_MESSAGE(NULL != operand[static_cast<unsigned int>(scalarIndex)], "SCM error");
2163@@ -715,7 +715,7 @@ void ScalarizeFunction::scalarizeInstruction(InsertElementInst* II)
2164 if (isa<UndefValue>(sourceVectorValue))
2165 {
2166 // Scalarize the undef value (generate a scalar undef)
2167- VectorType* inputVectorType = dyn_cast<VectorType>(sourceVectorValue->getType());
2168+ IGCLLVM::FixedVectorType* inputVectorType = dyn_cast<IGCLLVM::FixedVectorType>(sourceVectorValue->getType());
2169 IGC_ASSERT_MESSAGE(inputVectorType, "expected vector argument");
2170
2171 UndefValue* undefVal = UndefValue::get(inputVectorType->getElementType());
2172@@ -756,7 +756,7 @@ void ScalarizeFunction::scalarizeInstruction(ShuffleVectorInst* SI)
2173 IGC_ASSERT(nullptr != sourceVector0Value);
2174 Value* sourceVector1Value = SI->getOperand(1);
2175 IGC_ASSERT(nullptr != sourceVector1Value);
2176- VectorType* const inputType = dyn_cast<VectorType>(sourceVector0Value->getType());
2177+ IGCLLVM::FixedVectorType* const inputType = dyn_cast<IGCLLVM::FixedVectorType>(sourceVector0Value->getType());
2178 IGC_ASSERT_MESSAGE(nullptr != inputType, "vector input error");
2179 IGC_ASSERT_MESSAGE(inputType == sourceVector1Value->getType(), "vector input error");
2180 unsigned sourceVectorWidth = int_cast<unsigned>(inputType->getNumElements());
2181@@ -778,7 +778,7 @@ void ScalarizeFunction::scalarizeInstruction(ShuffleVectorInst* SI)
2182
2183 // Generate array for shuffled scalar values
2184 SmallVector<Value*, MAX_INPUT_VECTOR_WIDTH>newVector;
2185- unsigned width = int_cast<unsigned>(SI->getType()->getNumElements());
2186+ unsigned width = int_cast<unsigned>(dyn_cast<IGCLLVM::FixedVectorType>(SI->getType())->getNumElements());
2187
2188 // Generate undef value, which may be needed as some scalar elements
2189 UndefValue* undef = UndefValue::get(inputType->getElementType());
2190@@ -847,7 +847,7 @@ void ScalarizeFunction::scalarizeInstruction(GetElementPtrInst* GI)
2191
2192 if (baseValue->getType()->isVectorTy())
2193 {
2194- width = int_cast<unsigned>(dyn_cast<VectorType>(baseValue->getType())->getNumElements());
2195+ width = int_cast<unsigned>(dyn_cast<IGCLLVM::FixedVectorType>(baseValue->getType())->getNumElements());
2196 // Obtain the scalarized operands
2197 obtainScalarizedValues(operand1, NULL, baseValue, GI);
2198 ptrTy = dyn_cast<VectorType>(baseValue->getType())->getElementType();
2199@@ -858,7 +858,7 @@ void ScalarizeFunction::scalarizeInstruction(GetElementPtrInst* GI)
2200 }
2201 if (indexValue->getType()->isVectorTy())
2202 {
2203- width = int_cast<unsigned>(dyn_cast<VectorType>(indexValue->getType())->getNumElements());
2204+ width = int_cast<unsigned>(dyn_cast<IGCLLVM::FixedVectorType>(indexValue->getType())->getNumElements());
2205 // Obtain the scalarized operands
2206 obtainScalarizedValues(operand2, NULL, indexValue, GI);
2207 }
2208@@ -897,7 +897,7 @@ void ScalarizeFunction::scalarizeInstruction(LoadInst* LI)
2209 V_PRINT(scalarizer, "\t\tLoad instruction\n");
2210 IGC_ASSERT_MESSAGE(LI, "instruction type dynamic cast failed");
2211
2212- VectorType* dataType = dyn_cast<VectorType>(LI->getType());
2213+ IGCLLVM::FixedVectorType* dataType = dyn_cast<IGCLLVM::FixedVectorType>(LI->getType());
2214 if (isScalarizableLoadStoreType(dataType) && m_pDL)
2215 {
2216 // Prepare empty SCM entry for the instruction
2217@@ -969,7 +969,7 @@ void ScalarizeFunction::scalarizeInstruction(StoreInst* SI)
2218
2219 int indexPtr = SI->getPointerOperandIndex();
2220 int indexData = 1 - indexPtr;
2221- VectorType* dataType = dyn_cast<VectorType>(SI->getOperand(indexData)->getType());
2222+ IGCLLVM::FixedVectorType* dataType = dyn_cast<IGCLLVM::FixedVectorType>(SI->getOperand(indexData)->getType());
2223 if (isScalarizableLoadStoreType(dataType) && m_pDL)
2224 {
2225 // Get additional info from instruction
2226@@ -1040,7 +1040,7 @@ void ScalarizeFunction::obtainScalarizedValues(SmallVectorImpl<Value*>& retValue
2227 {
2228 V_PRINT(scalarizer, "\t\t\tObtaining scalar value... " << *origValue << "\n");
2229
2230- VectorType* origType = dyn_cast<VectorType>(origValue->getType());
2231+ IGCLLVM::FixedVectorType* origType = dyn_cast<IGCLLVM::FixedVectorType>(origValue->getType());
2232 IGC_ASSERT_MESSAGE(origType, "Value must have a vector type!");
2233 unsigned width = int_cast<unsigned>(origType->getNumElements());
2234
2235@@ -1202,7 +1202,7 @@ void ScalarizeFunction::obtainVectorValueWhichMightBeScalarizedImpl(Value* vecto
2236 }
2237
2238 Value* assembledVector = UndefValue::get(vectorVal->getType());
2239- unsigned width = int_cast<unsigned>(dyn_cast<VectorType>(vectorVal->getType())->getNumElements());
2240+ unsigned width = int_cast<unsigned>(dyn_cast<IGCLLVM::FixedVectorType>(vectorVal->getType())->getNumElements());
2241 for (unsigned i = 0; i < width; i++)
2242 {
2243 IGC_ASSERT_MESSAGE(NULL != valueEntry->scalarValues[i], "SCM entry has NULL value");
2244@@ -1262,7 +1262,7 @@ void ScalarizeFunction::updateSCMEntryWithValues(ScalarizeFunction::SCMEntry* en
2245 bool matchDbgLoc)
2246 {
2247 IGC_ASSERT_MESSAGE((origValue->getType()->isArrayTy() || origValue->getType()->isVectorTy()), "only Vector values are supported");
2248- unsigned width = int_cast<unsigned>(dyn_cast<VectorType>(origValue->getType())->getNumElements());
2249+ unsigned width = int_cast<unsigned>(dyn_cast<IGCLLVM::FixedVectorType>(origValue->getType())->getNumElements());
2250
2251 entry->isOriginalVectorRemoved = isOrigValueRemoved;
2252
2253@@ -1326,7 +1326,7 @@ void ScalarizeFunction::resolveDeferredInstructions()
2254 Instruction* vectorInst = dyn_cast<Instruction>(current.unresolvedInst);
2255 IGC_ASSERT_MESSAGE(vectorInst, "DRL only handles unresolved instructions");
2256
2257- VectorType* currType = dyn_cast<VectorType>(vectorInst->getType());
2258+ IGCLLVM::FixedVectorType* currType = dyn_cast<IGCLLVM::FixedVectorType>(vectorInst->getType());
2259 IGC_ASSERT_MESSAGE(currType, "Cannot have DRL of non-vector value");
2260 unsigned width = int_cast<unsigned>(currType->getNumElements());
2261
2262diff --git a/IGC/Compiler/Optimizer/ValueTracker.cpp b/IGC/Compiler/Optimizer/ValueTracker.cpp
2263index c06f7312..d8f0d385 100644
2264--- a/IGC/Compiler/Optimizer/ValueTracker.cpp
2265+++ b/IGC/Compiler/Optimizer/ValueTracker.cpp
2266@@ -178,7 +178,7 @@ Value* ValueTracker::handleExtractElement(ExtractElementInst* E)
2267 {
2268 auto mask = I->getShuffleMask();
2269 uint shuffleidx = int_cast<uint>(mask[(uint)idx]);
2270- auto vType = dyn_cast<VectorType>(I->getOperand(0)->getType());
2271+ auto vType = dyn_cast<IGCLLVM::FixedVectorType>(I->getOperand(0)->getType());
2272 baseValue = (shuffleidx < vType->getNumElements()) ?
2273 I->getOperand(0) : I->getOperand(1);
2274 }
2275diff --git a/IGC/Compiler/VerificationPass.cpp b/IGC/Compiler/VerificationPass.cpp
2276index 98437d79..40d50f5a 100644
2277--- a/IGC/Compiler/VerificationPass.cpp
2278+++ b/IGC/Compiler/VerificationPass.cpp
2279@@ -302,7 +302,7 @@ bool VerificationPass::verifyType(Type* type, Value* val)
2280
2281 case IGCLLVM::VectorTyID:
2282 {
2283- auto VType = cast<VectorType>(type);
2284+ auto VType = cast<IGCLLVM::FixedVectorType>(type);
2285 unsigned typeSize = (unsigned)VType->getNumElements();
2286 if (!m_IGC_IR_spec.vectorTypeSizes.count(typeSize))
2287 {
2288diff --git a/IGC/DebugInfo/DebugInfoUtils.hpp b/IGC/DebugInfo/DebugInfoUtils.hpp
2289index 7f2e288a..b77a550d 100644
2290--- a/IGC/DebugInfo/DebugInfoUtils.hpp
2291+++ b/IGC/DebugInfo/DebugInfoUtils.hpp
2292@@ -108,7 +108,11 @@ namespace IGC
2293 IGCLLVM::DIBuilder Builder(M);
2294 llvm::DIGlobalVariable* GV = GVs[j]->getVariable();
2295 llvm::DIScope* scopeToUse = GV->getScope();
2296+#if LLVM_VERSION_MAJOR >= 12
2297+ llvm::DILocation* locToUse = llvm::DILocation::get(scopeToUse->getContext(), GV->getLine(), 0, scopeToUse, loc);
2298+#else
2299 llvm::DILocation* locToUse = llvm::DebugLoc::get(GV->getLine(), 0, scopeToUse, loc);
2300+#endif
2301 if (llvm::isa<llvm::DICompileUnit>(GV->getScope()))
2302 {
2303 // Function has no DebugLoc so it is either internal
2304diff --git a/IGC/DebugInfo/DwarfDebug.cpp b/IGC/DebugInfo/DwarfDebug.cpp
2305index 683b83f7..bd9f17b7 100644
2306--- a/IGC/DebugInfo/DwarfDebug.cpp
2307+++ b/IGC/DebugInfo/DwarfDebug.cpp
2308@@ -2102,9 +2102,17 @@ static DebugLoc getFnDebugLoc(DebugLoc DL, const LLVMContext& Ctx)
2309 // Check for number of operands since the compatibility is cheap here.
2310 if (SP->getNumOperands() > 19)
2311 {
2312+#if LLVM_VERSION_MAJOR >= 12
2313+ return DILocation::get(SP->getContext(), SP->getScopeLine(), 0, SP);
2314+#else
2315 return DebugLoc::get(SP->getScopeLine(), 0, SP);
2316+#endif
2317 }
2318+#if LLVM_VERSION_MAJOR >= 12
2319+ return DILocation::get(SP->getContext(), SP->getLine(), 0, SP);
2320+#else
2321 return DebugLoc::get(SP->getLine(), 0, SP);
2322+#endif
2323 }
2324
2325 return DebugLoc();
2326diff --git a/IGC/GenISAIntrinsics/GenIntrinsics.cpp b/IGC/GenISAIntrinsics/GenIntrinsics.cpp
2327index 708cfdaa..772155b2 100644
2328--- a/IGC/GenISAIntrinsics/GenIntrinsics.cpp
2329+++ b/IGC/GenISAIntrinsics/GenIntrinsics.cpp
2330@@ -204,7 +204,7 @@ static Type *DecodeFixedType(ArrayRef<GenISAIntrinsic::IITDescriptor> &Infos,
2331 case IITDescriptor::SameVecWidthArgument: {
2332 Type *EltTy = DecodeFixedType(Infos, Tys, Context);
2333 Type *Ty = Tys[D.getArgumentNumber()];
2334- if (VectorType *VTy = dyn_cast<VectorType>(Ty)) {
2335+ if (IGCLLVM::FixedVectorType *VTy = dyn_cast<IGCLLVM::FixedVectorType>(Ty)) {
2336 return IGCLLVM::FixedVectorType::get(EltTy, int_cast<unsigned int>(VTy->getNumElements()));
2337 }
2338 IGC_ASSERT_EXIT_MESSAGE(0, "unhandled");
2339@@ -215,7 +215,7 @@ static Type *DecodeFixedType(ArrayRef<GenISAIntrinsic::IITDescriptor> &Infos,
2340 }
2341 case IITDescriptor::VecOfPtrsToElt: {
2342 Type *Ty = Tys[D.getArgumentNumber()];
2343- VectorType *VTy = dyn_cast<VectorType>(Ty);
2344+ IGCLLVM::FixedVectorType *VTy = dyn_cast<IGCLLVM::FixedVectorType>(Ty);
2345 if (!VTy)
2346 IGC_ASSERT_EXIT_MESSAGE(0, "Expected an argument of Vector Type");
2347 Type *EltTy = cast<VectorType>(VTy)->getElementType();
2348@@ -434,7 +434,7 @@ static std::string getMangledTypeStr(Type* Ty) {
2349 Result += "f";
2350 }
2351 else if (isa<VectorType>(Ty))
2352- Result += "v" + utostr(cast<VectorType>(Ty)->getNumElements()) +
2353+ Result += "v" + utostr(cast<IGCLLVM::FixedVectorType>(Ty)->getNumElements()) +
2354 getMangledTypeStr(cast<VectorType>(Ty)->getElementType());
2355 else if (Ty)
2356 Result += EVT::getEVT(Ty).getEVTString();
2357diff --git a/IGC/LLVM3DBuilder/BuiltinsFrontendDefinitions.hpp b/IGC/LLVM3DBuilder/BuiltinsFrontendDefinitions.hpp
2358index a89d63b9..a1bc5d2c 100644
2359--- a/IGC/LLVM3DBuilder/BuiltinsFrontendDefinitions.hpp
2360+++ b/IGC/LLVM3DBuilder/BuiltinsFrontendDefinitions.hpp
2361@@ -4929,7 +4929,7 @@ void LLVM3DBuilder<preserveNames, T, Inserter>::VectorToScalars(
2362 IGC_ASSERT(nullptr != vector->getType());
2363 IGC_ASSERT(vector->getType()->isVectorTy());
2364
2365- const unsigned count = (unsigned)llvm::cast<llvm::VectorType>(vector->getType())->getNumElements();
2366+ const unsigned count = (unsigned)llvm::cast<IGCLLVM::FixedVectorType>(vector->getType())->getNumElements();
2367 IGC_ASSERT(1 < count);
2368 IGC_ASSERT(count <= 4);
2369 IGC_ASSERT(count <= maxSize);
2370diff --git a/IGC/WrapperLLVM/include/llvmWrapper/Support/TypeSize.h b/IGC/WrapperLLVM/include/llvmWrapper/Support/TypeSize.h
2371index 08e5d6cf..30e29720 100644
2372--- a/IGC/WrapperLLVM/include/llvmWrapper/Support/TypeSize.h
2373+++ b/IGC/WrapperLLVM/include/llvmWrapper/Support/TypeSize.h
2374@@ -35,10 +35,16 @@ using namespace llvm;
2375 namespace IGCLLVM {
2376 #if LLVM_VERSION_MAJOR < 11
2377 inline unsigned getElementCount(unsigned EC) { return EC; }
2378-#else
2379+#elif LLVM_VERSION_MAJOR == 11
2380 inline ElementCount getElementCount(unsigned EC) {
2381 return ElementCount(EC, false);
2382 }
2383+#elif LLVM_VERSION_MAJOR == 12
2384+inline ElementCount getElementCount(unsigned EC) {
2385+ return ElementCount::get(EC, false);
2386+}
2387+#else
2388+#error "unsupported LLVM version"
2389 #endif
2390 } // namespace IGCLLVM
2391
2392diff --git a/IGC/WrapperLLVM/include/llvmWrapper/Transforms/Scalar.h b/IGC/WrapperLLVM/include/llvmWrapper/Transforms/Scalar.h
2393index f6e54fb1..5266ee87 100644
2394--- a/IGC/WrapperLLVM/include/llvmWrapper/Transforms/Scalar.h
2395+++ b/IGC/WrapperLLVM/include/llvmWrapper/Transforms/Scalar.h
2396@@ -44,7 +44,7 @@ namespace IGCLLVM
2397 {
2398 return llvm::createLoopUnrollPass(OptLevel, false, Threshold, Count, AllowPartial, Runtime, UpperBound, AllowPeeling);
2399 }
2400-#elif LLVM_VERSION_MAJOR == 9 || LLVM_VERSION_MAJOR == 10 || LLVM_VERSION_MAJOR == 11
2401+#elif LLVM_VERSION_MAJOR >= 9 && LLVM_VERSION_MAJOR <= 12
2402 inline static llvm::Pass * createLoopUnrollPass(
2403 int OptLevel = 2, int Threshold = -1, int Count = -1,
2404 int AllowPartial = -1, int Runtime = -1,
2405@@ -52,7 +52,7 @@ namespace IGCLLVM
2406 {
2407 return llvm::createLoopUnrollPass(OptLevel, false, false, Threshold, Count, AllowPartial, Runtime, UpperBound, AllowPeeling);
2408 }
2409-#elif LLVM_VERSION_MAJOR >= 12
2410+#else
2411 //DO NOT assume same function signature for all incoming llvm versions! Double check to upgrade!
2412 #error Not supported llvm version.
2413 #endif
2414diff --git a/IGC/common/igc_resourceDimTypes.h b/IGC/common/igc_resourceDimTypes.h
2415index 6831b06c..d790330f 100644
2416--- a/IGC/common/igc_resourceDimTypes.h
2417+++ b/IGC/common/igc_resourceDimTypes.h
2418@@ -66,6 +66,11 @@ namespace IGC
2419 resourceDimTypeId == DIM_2D_TYPE || resourceDimTypeId == DIM_2D_ARRAY_TYPE ||
2420 resourceDimTypeId == DIM_3D_TYPE || resourceDimTypeId == DIM_CUBE_TYPE || resourceDimTypeId == DIM_CUBE_ARRAY_TYPE));
2421
2422+#if LLVM_VERSION_MAJOR >= 12
2423+ llvm::LLVMContext& llvmCtx = module.getContext();
2424+ return llvm::StructType::getTypeByName(llvmCtx, ResourceDimensionTypeName[resourceDimTypeId]);
2425+#else
2426 return module.getTypeByName(ResourceDimensionTypeName[resourceDimTypeId]);
2427+#endif
2428 }
2429 }
2430\ No newline at end of file
2431--
24322.17.1
2433
diff --git a/dynamic-layers/clang-layer/recipes-opencl/igc/files/0002-Review-fixes-for-LLVM-12-phase-1.patch b/dynamic-layers/clang-layer/recipes-opencl/igc/files/0002-Review-fixes-for-LLVM-12-phase-1.patch
new file mode 100644
index 00000000..6580df75
--- /dev/null
+++ b/dynamic-layers/clang-layer/recipes-opencl/igc/files/0002-Review-fixes-for-LLVM-12-phase-1.patch
@@ -0,0 +1,318 @@
1From 60136b453bb3a109bfc88c4040b871af9d522ed5 Mon Sep 17 00:00:00 2001
2From: =?UTF-8?q?Zolt=C3=A1n=20B=C3=B6sz=C3=B6rm=C3=A9nyi?= <zboszor@pr.hu>
3Date: Thu, 25 Feb 2021 19:40:21 +0100
4Subject: [PATCH 2/3] Review fixes for LLVM 12 phase 1
5MIME-Version: 1.0
6Content-Type: text/plain; charset=UTF-8
7Content-Transfer-Encoding: 8bit
8
9Upstream-Status: Pending
10
11Signed-off-by: Zoltán Böszörményi <zboszor@gmail.com>
12Signed-off-by: Naveen Saini <naveen.kumar.saini@intel.com>
13---
14 IGC/AdaptorOCL/SPIRV/SPIRVReader.cpp | 6 +-----
15 IGC/AdaptorOCL/SPIRV/SPIRVUtil.cpp | 6 +-----
16 IGC/Compiler/CISACodeGen/AdvMemOpt.cpp | 7 ++-----
17 IGC/Compiler/CISACodeGen/Simd32Profitability.cpp | 7 ++-----
18 IGC/Compiler/ConvertMSAAPayloadTo16Bit.cpp | 11 +----------
19 IGC/Compiler/GenTTI.cpp | 9 ++-------
20 IGC/Compiler/Legalizer/InstPromoter.cpp | 8 +-------
21 .../DeviceEnqueueFuncs/TransformBlocks.cpp | 6 +-----
22 .../OpenCLPasses/WIFuncs/WIFuncResolution.cpp | 4 ----
23 IGC/Compiler/Optimizer/Scalarizer.cpp | 2 +-
24 IGC/WrapperLLVM/include/llvmWrapper/IR/DerivedTypes.h | 10 ++++++++++
25 .../include/llvmWrapper/Support/TypeSize.h | 4 +---
26 .../include/llvmWrapper/Transforms/Utils/LoopUtils.h | 8 ++++++++
27 IGC/common/igc_resourceDimTypes.h | 5 ++---
28 14 files changed, 33 insertions(+), 60 deletions(-)
29
30diff --git a/IGC/AdaptorOCL/SPIRV/SPIRVReader.cpp b/IGC/AdaptorOCL/SPIRV/SPIRVReader.cpp
31index 725a1512..12f42be8 100644
32--- a/IGC/AdaptorOCL/SPIRV/SPIRVReader.cpp
33+++ b/IGC/AdaptorOCL/SPIRV/SPIRVReader.cpp
34@@ -1929,11 +1929,7 @@ SPIRVToLLVM::transType(SPIRVType *T) {
35 auto name = isSubgroupAvcINTELTypeOpCode(OC) ?
36 OCLSubgroupINTELTypeOpCodeMap::rmap(OC) :
37 BuiltinOpaqueGenericTypeOpCodeMap::rmap(OC);
38-#if LLVM_VERSION_MAJOR >= 12
39- auto *pST = llvm::StructType::getTypeByName(M->getContext(), name);
40-#else
41- auto *pST = M->getTypeByName(name);
42-#endif
43+ auto *pST = IGCLLVM::getTypeByName(M, name);
44 pST = pST ? pST : StructType::create(*Context, name);
45
46 return mapType(T, PointerType::get(pST, getOCLOpaqueTypeAddrSpace(OC)));
47diff --git a/IGC/AdaptorOCL/SPIRV/SPIRVUtil.cpp b/IGC/AdaptorOCL/SPIRV/SPIRVUtil.cpp
48index 91b4623c..f4f0dee5 100644
49--- a/IGC/AdaptorOCL/SPIRV/SPIRVUtil.cpp
50+++ b/IGC/AdaptorOCL/SPIRV/SPIRVUtil.cpp
51@@ -93,11 +93,7 @@ saveLLVMModule(Module *M, const std::string &OutputFile) {
52 PointerType*
53 getOrCreateOpaquePtrType(Module *M, const std::string &Name,
54 unsigned AddrSpace) {
55-#if LLVM_VERSION_MAJOR >= 12
56- auto OpaqueType = llvm::StructType::getTypeByName(M->getContext(), Name);
57-#else
58- auto OpaqueType = M->getTypeByName(Name);
59-#endif
60+ auto OpaqueType = IGCLLVM::getTypeByName(M, Name);
61 if (!OpaqueType)
62 OpaqueType = StructType::create(M->getContext(), Name);
63 return PointerType::get(OpaqueType, AddrSpace);
64diff --git a/IGC/Compiler/CISACodeGen/AdvMemOpt.cpp b/IGC/Compiler/CISACodeGen/AdvMemOpt.cpp
65index fc45a510..a612a473 100644
66--- a/IGC/Compiler/CISACodeGen/AdvMemOpt.cpp
67+++ b/IGC/Compiler/CISACodeGen/AdvMemOpt.cpp
68@@ -33,6 +33,7 @@ IN THE SOFTWARE.
69 #include <llvm/Support/Debug.h>
70 #include <llvm/Support/raw_ostream.h>
71 #include <llvm/Transforms/Utils/Local.h>
72+#include "llvmWrapper/Transforms/Utils/LoopUtils.h"
73 #include "common/LLVMWarningsPop.hpp"
74 #include "GenISAIntrinsics/GenIntrinsics.h"
75 #include "Compiler/CISACodeGen/ShaderCodeGen.hpp"
76@@ -134,11 +135,7 @@ bool AdvMemOpt::runOnFunction(Function& F) {
77 for (auto I = LI->begin(), E = LI->end(); I != E; ++I)
78 for (auto DFI = df_begin(*I), DFE = df_end(*I); DFI != DFE; ++DFI) {
79 Loop* L = *DFI;
80-#if LLVM_VERSION_MAJOR >= 12
81- if (L->isInnermost())
82-#else
83- if (L->empty())
84-#endif
85+ if (IGCLLVM::isInnermost(L))
86 InnermostLoops.push_back(L);
87 }
88
89diff --git a/IGC/Compiler/CISACodeGen/Simd32Profitability.cpp b/IGC/Compiler/CISACodeGen/Simd32Profitability.cpp
90index c1f4a419..5393d4e8 100644
91--- a/IGC/Compiler/CISACodeGen/Simd32Profitability.cpp
92+++ b/IGC/Compiler/CISACodeGen/Simd32Profitability.cpp
93@@ -28,6 +28,7 @@ IN THE SOFTWARE.
94 #include "Compiler/CISACodeGen/Platform.hpp"
95 #include "common/LLVMWarningsPush.hpp"
96 #include <llvmWrapper/IR/DerivedTypes.h>
97+#include <llvmWrapper/Transforms/Utils/LoopUtils.h>
98 #include <llvm/IR/InstIterator.h>
99 #include <llvm/IR/Operator.h>
100 #include <llvmWrapper/IR/DerivedTypes.h>
101@@ -995,11 +996,7 @@ static bool hasLongStridedLdStInLoop(Function* F, LoopInfo* LI, WIAnalysis* WI)
102 // Collect innermost simple loop.
103 for (auto I = LI->begin(), E = LI->end(); I != E; ++I) {
104 auto L = *I;
105-#if LLVM_VERSION_MAJOR >= 12
106- if (!L->isInnermost())
107-#else
108- if (!L->empty())
109-#endif
110+ if (!IGCLLVM::isInnermost(L))
111 continue;
112 if (L->getNumBlocks() != 2)
113 continue;
114diff --git a/IGC/Compiler/ConvertMSAAPayloadTo16Bit.cpp b/IGC/Compiler/ConvertMSAAPayloadTo16Bit.cpp
115index adf992cb..33473c23 100644
116--- a/IGC/Compiler/ConvertMSAAPayloadTo16Bit.cpp
117+++ b/IGC/Compiler/ConvertMSAAPayloadTo16Bit.cpp
118@@ -153,21 +153,12 @@ void ConvertMSAAPayloadTo16Bit::visitCallInst(CallInst& I)
119 // In OGL there are uses of ldmcs other then ldms, using vec4float type.
120 // Fix them to use newly created 16bit ldmcs.
121 if (ldmcs->getType()->isVectorTy() &&
122-#if LLVM_VERSION_MAJOR >= 12
123- ldmcs->getType()->getScalarType()->isFloatTy())
124-#else
125- ldmcs->getType()->getVectorElementType()->isFloatTy())
126-#endif
127+ cast<IGCLLVM::FixedVectorType>(ldmcs->getType())->getElementType()->isFloatTy())
128 {
129 m_builder->SetInsertPoint(ldmcs);
130
131-#if LLVM_VERSION_MAJOR >= 12
132 uint ldmcsNumOfElements = cast<IGCLLVM::FixedVectorType>(ldmcs->getType())->getNumElements();
133 uint new_mcs_callNumOfElements = cast<IGCLLVM::FixedVectorType>(new_mcs_call->getType())->getNumElements();
134-#else
135- uint ldmcsNumOfElements = ldmcs->getType()->getVectorNumElements();
136- uint new_mcs_callNumOfElements = new_mcs_call->getType()->getVectorNumElements();
137-#endif
138
139 // vec of 16bit ints to vec of 32bit ints
140 Type* new_mcs_callVecType = IGCLLVM::FixedVectorType::get(m_builder->getInt32Ty(), new_mcs_callNumOfElements);
141diff --git a/IGC/Compiler/GenTTI.cpp b/IGC/Compiler/GenTTI.cpp
142index 9e4d2f26..53e3ec9e 100644
143--- a/IGC/Compiler/GenTTI.cpp
144+++ b/IGC/Compiler/GenTTI.cpp
145@@ -37,6 +37,7 @@ IN THE SOFTWARE.
146 #include "llvm/Analysis/LoopInfo.h"
147 #include "llvm/Analysis/ScalarEvolution.h"
148 #include "llvm/Support/raw_ostream.h"
149+#include "llvmWrapper/Transforms/Utils/LoopUtils.h"
150 #include "common/LLVMWarningsPop.hpp"
151
152 using namespace llvm;
153@@ -216,13 +217,7 @@ namespace llvm {
154
155 // Skip non-simple loop.
156 if (L->getNumBlocks() != 1) {
157- if (IGC_IS_FLAG_ENABLED(EnableAdvRuntimeUnroll) &&
158-#if LLVM_VERSION_MAJOR >= 12
159- L->isInnermost()
160-#else
161- L->empty()
162-#endif
163- ) {
164+ if (IGC_IS_FLAG_ENABLED(EnableAdvRuntimeUnroll) && IGCLLVM::isInnermost(L)) {
165 auto countNonPHI = [](BasicBlock* BB) {
166 unsigned Total = BB->size();
167 unsigned PHIs = 0;
168diff --git a/IGC/Compiler/Legalizer/InstPromoter.cpp b/IGC/Compiler/Legalizer/InstPromoter.cpp
169index 8fadf89f..63cbccb5 100644
170--- a/IGC/Compiler/Legalizer/InstPromoter.cpp
171+++ b/IGC/Compiler/Legalizer/InstPromoter.cpp
172@@ -398,13 +398,7 @@ bool InstPromoter::visitBitCastInst(BitCastInst& I) {
173 IRB->CreateBitCast(Val, IGCLLVM::FixedVectorType::get(DestTy->getScalarType(), N));
174
175 std::vector<Constant*> Vals;
176- for (unsigned i = 0;
177-#if LLVM_VERSION_MAJOR >= 12
178- i < cast<IGCLLVM::FixedVectorType>(DestTy)->getNumElements();
179-#else
180- i < DestTy->getVectorNumElements();
181-#endif
182- i++)
183+ for (unsigned i = 0; i < cast<IGCLLVM::FixedVectorType>(DestTy)->getNumElements(); i++)
184 Vals.push_back(IRB->getInt32(i));
185
186 Value* Mask = ConstantVector::get(Vals);
187diff --git a/IGC/Compiler/Optimizer/OpenCLPasses/DeviceEnqueueFuncs/TransformBlocks.cpp b/IGC/Compiler/Optimizer/OpenCLPasses/DeviceEnqueueFuncs/TransformBlocks.cpp
188index 119520ed..a3681b79 100644
189--- a/IGC/Compiler/Optimizer/OpenCLPasses/DeviceEnqueueFuncs/TransformBlocks.cpp
190+++ b/IGC/Compiler/Optimizer/OpenCLPasses/DeviceEnqueueFuncs/TransformBlocks.cpp
191@@ -952,11 +952,7 @@ namespace //Anonymous
192 {
193 auto ndrangeStructName = "struct.ndrange_t";
194 auto module = _deviceExecCall->getModule();
195-#if LLVM_VERSION_MAJOR >= 12
196- auto ndrangeTy = llvm::StructType::getTypeByName(module->getContext(), ndrangeStructName);
197-#else
198- auto ndrangeTy = module->getTypeByName(ndrangeStructName);
199-#endif
200+ auto ndrangeTy = IGCLLVM::getTypeByName(module, ndrangeStructName);
201 if (ndrangeTy == nullptr)
202 {
203 //create struct type
204diff --git a/IGC/Compiler/Optimizer/OpenCLPasses/WIFuncs/WIFuncResolution.cpp b/IGC/Compiler/Optimizer/OpenCLPasses/WIFuncs/WIFuncResolution.cpp
205index 535d6268..c23c661d 100644
206--- a/IGC/Compiler/Optimizer/OpenCLPasses/WIFuncs/WIFuncResolution.cpp
207+++ b/IGC/Compiler/Optimizer/OpenCLPasses/WIFuncs/WIFuncResolution.cpp
208@@ -303,11 +303,7 @@ static Value* BuildLoadInst(CallInst& CI, unsigned int Offset, Type* DataType)
209 auto Size = ElemByteSize;
210 if (DataType->isVectorTy())
211 {
212-#if LLVM_VERSION_MAJOR >= 12
213 Size *= cast<IGCLLVM::FixedVectorType>(DataType)->getNumElements();
214-#else
215- Size *= DataType->getVectorNumElements();
216-#endif
217 }
218 unsigned int AlignedOffset = (Offset / ElemByteSize) * ElemByteSize;
219 unsigned int LoadByteSize = (Offset == AlignedOffset) ? Size : Size * 2;
220diff --git a/IGC/Compiler/Optimizer/Scalarizer.cpp b/IGC/Compiler/Optimizer/Scalarizer.cpp
221index a4e73a6d..38627553 100644
222--- a/IGC/Compiler/Optimizer/Scalarizer.cpp
223+++ b/IGC/Compiler/Optimizer/Scalarizer.cpp
224@@ -778,7 +778,7 @@ void ScalarizeFunction::scalarizeInstruction(ShuffleVectorInst* SI)
225
226 // Generate array for shuffled scalar values
227 SmallVector<Value*, MAX_INPUT_VECTOR_WIDTH>newVector;
228- unsigned width = int_cast<unsigned>(dyn_cast<IGCLLVM::FixedVectorType>(SI->getType())->getNumElements());
229+ unsigned width = int_cast<unsigned>(cast<IGCLLVM::FixedVectorType>(SI->getType())->getNumElements());
230
231 // Generate undef value, which may be needed as some scalar elements
232 UndefValue* undef = UndefValue::get(inputType->getElementType());
233diff --git a/IGC/WrapperLLVM/include/llvmWrapper/IR/DerivedTypes.h b/IGC/WrapperLLVM/include/llvmWrapper/IR/DerivedTypes.h
234index a3f5a0b8..6a5407bb 100644
235--- a/IGC/WrapperLLVM/include/llvmWrapper/IR/DerivedTypes.h
236+++ b/IGC/WrapperLLVM/include/llvmWrapper/IR/DerivedTypes.h
237@@ -29,6 +29,7 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
238
239 #include "llvm/Config/llvm-config.h"
240 #include "llvm/IR/DerivedTypes.h"
241+#include "llvm/IR/Module.h"
242
243 namespace IGCLLVM
244 {
245@@ -62,6 +63,15 @@ namespace IGCLLVM
246 return false;
247 #endif
248 }
249+
250+ inline llvm::StructType *getTypeByName(llvm::Module *M, llvm::StringRef Name) {
251+#if LLVM_VERSION_MAJOR >= 12
252+ return llvm::StructType::getTypeByName(M->getContext(), Name);
253+#else
254+ return M->getTypeByName(Name);
255+#endif
256+ }
257+
258 }
259
260 #endif
261diff --git a/IGC/WrapperLLVM/include/llvmWrapper/Support/TypeSize.h b/IGC/WrapperLLVM/include/llvmWrapper/Support/TypeSize.h
262index 30e29720..7021820c 100644
263--- a/IGC/WrapperLLVM/include/llvmWrapper/Support/TypeSize.h
264+++ b/IGC/WrapperLLVM/include/llvmWrapper/Support/TypeSize.h
265@@ -39,12 +39,10 @@ inline unsigned getElementCount(unsigned EC) { return EC; }
266 inline ElementCount getElementCount(unsigned EC) {
267 return ElementCount(EC, false);
268 }
269-#elif LLVM_VERSION_MAJOR == 12
270+#else
271 inline ElementCount getElementCount(unsigned EC) {
272 return ElementCount::get(EC, false);
273 }
274-#else
275-#error "unsupported LLVM version"
276 #endif
277 } // namespace IGCLLVM
278
279diff --git a/IGC/WrapperLLVM/include/llvmWrapper/Transforms/Utils/LoopUtils.h b/IGC/WrapperLLVM/include/llvmWrapper/Transforms/Utils/LoopUtils.h
280index db47b00b..bce9cfc1 100644
281--- a/IGC/WrapperLLVM/include/llvmWrapper/Transforms/Utils/LoopUtils.h
282+++ b/IGC/WrapperLLVM/include/llvmWrapper/Transforms/Utils/LoopUtils.h
283@@ -41,6 +41,14 @@ namespace IGCLLVM
284 return llvm::InsertPreheaderForLoop(L, DT, LI, nullptr, PreserveLCSSA);
285 }
286 #endif
287+
288+ inline bool isInnermost(llvm::Loop *L) {
289+#if LLVM_VERSION_MAJOR >= 12
290+ return L->isInnermost();
291+#else
292+ return L->empty();
293+#endif
294+ }
295 }
296
297 #endif
298diff --git a/IGC/common/igc_resourceDimTypes.h b/IGC/common/igc_resourceDimTypes.h
299index d790330f..2d675969 100644
300--- a/IGC/common/igc_resourceDimTypes.h
301+++ b/IGC/common/igc_resourceDimTypes.h
302@@ -67,10 +67,9 @@ namespace IGC
303 resourceDimTypeId == DIM_3D_TYPE || resourceDimTypeId == DIM_CUBE_TYPE || resourceDimTypeId == DIM_CUBE_ARRAY_TYPE));
304
305 #if LLVM_VERSION_MAJOR >= 12
306- llvm::LLVMContext& llvmCtx = module.getContext();
307- return llvm::StructType::getTypeByName(llvmCtx, ResourceDimensionTypeName[resourceDimTypeId]);
308+ return llvm::StructType::getTypeByName(module.getContext(), ResourceDimensionTypeName[resourceDimTypeId]);
309 #else
310 return module.getTypeByName(ResourceDimensionTypeName[resourceDimTypeId]);
311 #endif
312 }
313-}
314\ No newline at end of file
315+}
316--
3172.17.1
318
diff --git a/dynamic-layers/clang-layer/recipes-opencl/igc/files/0003-Review-fixes-for-LLVM-12-phase-2.patch b/dynamic-layers/clang-layer/recipes-opencl/igc/files/0003-Review-fixes-for-LLVM-12-phase-2.patch
new file mode 100644
index 00000000..189c2b3f
--- /dev/null
+++ b/dynamic-layers/clang-layer/recipes-opencl/igc/files/0003-Review-fixes-for-LLVM-12-phase-2.patch
@@ -0,0 +1,123 @@
1From c6d333637537263930acb1b6c5dadb0467d745f6 Mon Sep 17 00:00:00 2001
2From: =?UTF-8?q?Zolt=C3=A1n=20B=C3=B6sz=C3=B6rm=C3=A9nyi?= <zboszor@pr.hu>
3Date: Fri, 26 Feb 2021 06:39:35 +0100
4Subject: [PATCH 3/3] Review fixes for LLVM 12 phase 2
5MIME-Version: 1.0
6Content-Type: text/plain; charset=UTF-8
7Content-Transfer-Encoding: 8bit
8
9Upstream-Status: Pending
10
11Signed-off-by: Zoltán Böszörményi <zboszor@gmail.com>
12Signed-off-by: Naveen Saini <naveen.kumar.saini@intel.com>
13---
14 IGC/AdaptorOCL/SPIRV/SPIRVReader.cpp | 4 ----
15 .../AddressSpaceAliasAnalysis.cpp | 10 +++++-----
16 .../PrivateMemory/PrivateMemoryResolution.cpp | 4 ----
17 IGC/DebugInfo/DebugInfoUtils.hpp | 4 ----
18 IGC/DebugInfo/DwarfDebug.cpp | 8 --------
19 5 files changed, 5 insertions(+), 25 deletions(-)
20
21diff --git a/IGC/AdaptorOCL/SPIRV/SPIRVReader.cpp b/IGC/AdaptorOCL/SPIRV/SPIRVReader.cpp
22index 12f42be8..c4f9d1ea 100644
23--- a/IGC/AdaptorOCL/SPIRV/SPIRVReader.cpp
24+++ b/IGC/AdaptorOCL/SPIRV/SPIRVReader.cpp
25@@ -1576,11 +1576,7 @@ void SPIRVToLLVMDbgTran::transDbgInfo(SPIRVValue *SV, Value *V) {
26 Line->getColumn(), scope, iat);
27
28 if(scope && !isa<DIFile>(scope))
29-#if LLVM_VERSION_MAJOR >= 12
30 I->setDebugLoc(DILocation::get(scope->getContext(), Line->getLine(), Line->getColumn(),
31-#else
32- I->setDebugLoc(DebugLoc::get(Line->getLine(), Line->getColumn(),
33-#endif
34 scope, iat));
35 }
36 }
37diff --git a/IGC/Compiler/Optimizer/OpenCLPasses/AddressSpaceAliasAnalysis/AddressSpaceAliasAnalysis.cpp b/IGC/Compiler/Optimizer/OpenCLPasses/AddressSpaceAliasAnalysis/AddressSpaceAliasAnalysis.cpp
38index e9c07b34..b6b779da 100644
39--- a/IGC/Compiler/Optimizer/OpenCLPasses/AddressSpaceAliasAnalysis/AddressSpaceAliasAnalysis.cpp
40+++ b/IGC/Compiler/Optimizer/OpenCLPasses/AddressSpaceAliasAnalysis/AddressSpaceAliasAnalysis.cpp
41@@ -23,8 +23,7 @@ IN THE SOFTWARE.
42 ============================= end_copyright_notice ===========================*/
43
44 #include "llvm/Config/llvm-config.h"
45-#include "llvmWrapper/IR/DerivedTypes.h"
46-#include "llvmWrapper/Analysis/TargetLibraryInfo.h"
47+#include <llvm/Analysis/TargetLibraryInfo.h>
48 #include "Compiler/Optimizer/OpenCLPasses/AddressSpaceAliasAnalysis/AddressSpaceAliasAnalysis.h"
49 #include "Compiler/CodeGenPublic.h"
50 #include "Compiler/IGCPassSupport.h"
51@@ -180,11 +179,12 @@ namespace {
52 bool doInitialization(Module& M) override {
53 if(M.size() > 0)
54 {
55+ Result.reset(new AddressSpaceAAResult(
56+ getAnalysis<TargetLibraryInfoWrapperPass>().getTLI(
57 #if LLVM_VERSION_MAJOR >= 10
58- Function &F = *M.begin();
59+ *M.begin()
60 #endif
61- Result.reset(new AddressSpaceAAResult(
62- getAnalysis<TargetLibraryInfoWrapperPass>().getTLI(),
63+ ),
64 *getAnalysis<CodeGenContextWrapper>().getCodeGenContext()));
65 }
66 return false;
67diff --git a/IGC/Compiler/Optimizer/OpenCLPasses/PrivateMemory/PrivateMemoryResolution.cpp b/IGC/Compiler/Optimizer/OpenCLPasses/PrivateMemory/PrivateMemoryResolution.cpp
68index 07f85f4c..98ea616f 100644
69--- a/IGC/Compiler/Optimizer/OpenCLPasses/PrivateMemory/PrivateMemoryResolution.cpp
70+++ b/IGC/Compiler/Optimizer/OpenCLPasses/PrivateMemory/PrivateMemoryResolution.cpp
71@@ -816,11 +816,7 @@ bool PrivateMemoryResolution::resolveAllocaInstructions(bool privateOnStack)
72 // Construct an empty DebugLoc.
73 IF_DEBUG_INFO(DebugLoc entryDebugLoc);
74 // Assign with the function location if available.
75-#if LLVM_VERSION_MAJOR >= 12
76 IF_DEBUG_INFO_IF(DISubprogram *subprogram = m_currFunction->getSubprogram(), entryDebugLoc = DILocation::get(subprogram->getContext(), subprogram->getLine(), 0, subprogram););
77-#else
78- IF_DEBUG_INFO_IF(DISubprogram *subprogram = m_currFunction->getSubprogram(), entryDebugLoc = DebugLoc::get(subprogram->getLine(), 0, subprogram););
79-#endif
80 IF_DEBUG_INFO(entryBuilder.SetCurrentDebugLocation(entryDebugLoc));
81
82 if (privateOnStack)
83diff --git a/IGC/DebugInfo/DebugInfoUtils.hpp b/IGC/DebugInfo/DebugInfoUtils.hpp
84index b77a550d..88b30a75 100644
85--- a/IGC/DebugInfo/DebugInfoUtils.hpp
86+++ b/IGC/DebugInfo/DebugInfoUtils.hpp
87@@ -108,11 +108,7 @@ namespace IGC
88 IGCLLVM::DIBuilder Builder(M);
89 llvm::DIGlobalVariable* GV = GVs[j]->getVariable();
90 llvm::DIScope* scopeToUse = GV->getScope();
91-#if LLVM_VERSION_MAJOR >= 12
92 llvm::DILocation* locToUse = llvm::DILocation::get(scopeToUse->getContext(), GV->getLine(), 0, scopeToUse, loc);
93-#else
94- llvm::DILocation* locToUse = llvm::DebugLoc::get(GV->getLine(), 0, scopeToUse, loc);
95-#endif
96 if (llvm::isa<llvm::DICompileUnit>(GV->getScope()))
97 {
98 // Function has no DebugLoc so it is either internal
99diff --git a/IGC/DebugInfo/DwarfDebug.cpp b/IGC/DebugInfo/DwarfDebug.cpp
100index bd9f17b7..3d9f0835 100644
101--- a/IGC/DebugInfo/DwarfDebug.cpp
102+++ b/IGC/DebugInfo/DwarfDebug.cpp
103@@ -2102,17 +2102,9 @@ static DebugLoc getFnDebugLoc(DebugLoc DL, const LLVMContext& Ctx)
104 // Check for number of operands since the compatibility is cheap here.
105 if (SP->getNumOperands() > 19)
106 {
107-#if LLVM_VERSION_MAJOR >= 12
108 return DILocation::get(SP->getContext(), SP->getScopeLine(), 0, SP);
109-#else
110- return DebugLoc::get(SP->getScopeLine(), 0, SP);
111-#endif
112 }
113-#if LLVM_VERSION_MAJOR >= 12
114 return DILocation::get(SP->getContext(), SP->getLine(), 0, SP);
115-#else
116- return DebugLoc::get(SP->getLine(), 0, SP);
117-#endif
118 }
119
120 return DebugLoc();
121--
1222.17.1
123
diff --git a/dynamic-layers/clang-layer/recipes-opencl/igc/intel-graphics-compiler_1.0.6083.bb b/dynamic-layers/clang-layer/recipes-opencl/igc/intel-graphics-compiler_1.0.6646.bb
index c92b8ea4..582db553 100644
--- a/dynamic-layers/clang-layer/recipes-opencl/igc/intel-graphics-compiler_1.0.6083.bb
+++ b/dynamic-layers/clang-layer/recipes-opencl/igc/intel-graphics-compiler_1.0.6646.bb
@@ -5,16 +5,19 @@ hardware architecture."
5 5
6LICENSE = "MIT & BSD-3-Clause" 6LICENSE = "MIT & BSD-3-Clause"
7LIC_FILES_CHKSUM = "file://IGC/BiFModule/Implementation/ExternalLibraries/libclc/LICENSE.TXT;md5=311cfc1a5b54bab8ed34a0b5fba4373e \ 7LIC_FILES_CHKSUM = "file://IGC/BiFModule/Implementation/ExternalLibraries/libclc/LICENSE.TXT;md5=311cfc1a5b54bab8ed34a0b5fba4373e \
8 file://IGC/Compiler/LegalizationPass.cpp;beginline=1;endline=25;md5=4abf1738ff96b18e34186eb763e28eeb \ 8 file://IGC/Compiler/LegalizationPass.cpp;beginline=1;endline=23;md5=8b19c5999abc484f18232b0905367f9f \
9 file://NOTICES.txt;md5=b12e73994de4fbe0f688cf0bc91512a0" 9 file://NOTICES.txt;md5=b12e73994de4fbe0f688cf0bc91512a0"
10 10
11SRC_URI = "git://github.com/intel/intel-graphics-compiler.git;protocol=https; \ 11SRC_URI = "git://github.com/intel/intel-graphics-compiler.git;protocol=https; \
12 file://0001-skip-execution-of-ElfPackager.patch \ 12 file://0001-skip-execution-of-ElfPackager.patch \
13 file://link-to-LLVMGenXIntrinsics.patch \ 13 file://link-to-LLVMGenXIntrinsics.patch \
14 file://improve_src_package_reproducibility.patch \ 14 file://improve_src_package_reproducibility.patch \
15 file://0001-Fix-build-with-LLVM-12.patch \
16 file://0002-Review-fixes-for-LLVM-12-phase-1.patch \
17 file://0003-Review-fixes-for-LLVM-12-phase-2.patch \
15 " 18 "
16 19
17SRCREV = "f6ec355e7e275f87e0756576cd7a390d2365ed48" 20SRCREV = "535aaaef03ce338e05e6162118082e6e007e8c10"
18 21
19# Used to replace with relative path in reproducibility patch 22# Used to replace with relative path in reproducibility patch
20export B 23export B
@@ -31,8 +34,7 @@ DEPENDS_append_class-target = " clang-cross-x86_64"
31 34
32RDEPENDS_${PN} += "opencl-clang" 35RDEPENDS_${PN} += "opencl-clang"
33 36
34LLVM_COMPAT_VERSION = "${@bb.utils.contains('LLVMVERSION', '10.0.1', '10.0.0', '11.1.0', d)}" 37EXTRA_OECMAKE = "-DIGC_OPTION__LLVM_PREFERRED_VERSION=${LLVMVERSION} -DPYTHON_EXECUTABLE=${HOSTTOOLS_DIR}/python3 -DIGC_BUILD__VC_ENABLED=OFF -DIGC_BUILD__USE_KHRONOS_SPIRV_TRANSLATOR=ON"
35EXTRA_OECMAKE = "-DIGC_PREFERRED_LLVM_VERSION=${LLVM_COMPAT_VERSION} -DPYTHON_EXECUTABLE=${HOSTTOOLS_DIR}/python3 -DINSTALL_SPIRVDLL=0 -DIGC_BUILD__VC_ENABLED=OFF"
36 38
37BBCLASSEXTEND = "native nativesdk" 39BBCLASSEXTEND = "native nativesdk"
38 40