summaryrefslogtreecommitdiffstats
path: root/dynamic-layers
diff options
context:
space:
mode:
authorAnuj Mittal <anuj.mittal@intel.com>2022-05-19 09:25:59 +0800
committerAnuj Mittal <anuj.mittal@intel.com>2022-05-19 12:02:58 +0800
commit3403a5813748065877552f8c220ba5e9b726cbd4 (patch)
tree888bcf5d9ffafab73449684fc464bfeb0a93e573 /dynamic-layers
parentc4222554c750749ce324482236cac138b467f3c6 (diff)
downloadmeta-intel-3403a5813748065877552f8c220ba5e9b726cbd4.tar.gz
intel-graphics-compiler: LLVM 13 fixes
Backport LLVM 13 fixes from upstream. This fixes the crashes when invoking ocloc after enabling built-ins in compute-runtime. Also see: https://github.com/intel/intel-graphics-compiler/issues/204 Signed-off-by: Anuj Mittal <anuj.mittal@intel.com>
Diffstat (limited to 'dynamic-layers')
-rw-r--r--dynamic-layers/clang-layer/recipes-opencl/igc/files/0001-Don-t-accept-nullptr-as-GEP-element-type.patch182
-rw-r--r--dynamic-layers/clang-layer/recipes-opencl/igc/files/0002-LLVM13-changed-MCContext-constructor.patch41
-rw-r--r--dynamic-layers/clang-layer/recipes-opencl/igc/intel-graphics-compiler_1.0.8744.bb2
3 files changed, 225 insertions, 0 deletions
diff --git a/dynamic-layers/clang-layer/recipes-opencl/igc/files/0001-Don-t-accept-nullptr-as-GEP-element-type.patch b/dynamic-layers/clang-layer/recipes-opencl/igc/files/0001-Don-t-accept-nullptr-as-GEP-element-type.patch
new file mode 100644
index 00000000..0e90023f
--- /dev/null
+++ b/dynamic-layers/clang-layer/recipes-opencl/igc/files/0001-Don-t-accept-nullptr-as-GEP-element-type.patch
@@ -0,0 +1,182 @@
1From 9c68deb3f913a3d055112a28103ec2933ca7b09c Mon Sep 17 00:00:00 2001
2From: Marcin Naczk <marcin.naczk@intel.com>
3Date: Tue, 17 May 2022 10:36:56 +0000
4Subject: [PATCH 1/2] Don't accept nullptr as GEP element type
5
6LLVM13 IR don't accept nullptr as GEP element type
7https://reviews.llvm.org/D105653
8
9Upstream-Status: Backport
10Signed-off-by: Anuj Mittal <anuj.mittal@intel.com>
11---
12 IGC/AdaptorOCL/SPIRV/SPIRVReader.cpp | 5 +++--
13 IGC/Compiler/CustomSafeOptPass.cpp | 8 +++++---
14 IGC/Compiler/LegalizationPass.cpp | 3 ++-
15 .../IGCInstCombiner/7.0/InstructionCombining.cpp | 3 ++-
16 .../OpenCLPasses/LocalBuffers/InlineLocalsResolution.cpp | 5 +++--
17 .../ProgramScopeConstantResolution.cpp | 3 ++-
18 IGC/Compiler/Optimizer/Scalarizer.cpp | 3 ++-
19 IGC/Compiler/PromoteResourceToDirectAS.cpp | 6 +++---
20 8 files changed, 22 insertions(+), 14 deletions(-)
21
22diff --git a/IGC/AdaptorOCL/SPIRV/SPIRVReader.cpp b/IGC/AdaptorOCL/SPIRV/SPIRVReader.cpp
23index ae5510c6a..0f4fca87c 100644
24--- a/IGC/AdaptorOCL/SPIRV/SPIRVReader.cpp
25+++ b/IGC/AdaptorOCL/SPIRV/SPIRVReader.cpp
26@@ -3368,17 +3368,18 @@ SPIRVToLLVM::transValueWithoutDecoration(SPIRVValue *BV, Function *F,
27 case OpInBoundsPtrAccessChain: {
28 auto AC = static_cast<SPIRVAccessChainBase *>(BV);
29 auto Base = transValue(AC->getBase(), F, BB);
30+ Type *BaseTy = cast<PointerType>(Base->getType())->getPointerElementType();
31 auto Index = transValue(AC->getIndices(), F, BB);
32 if (!AC->hasPtrIndex())
33 Index.insert(Index.begin(), getInt32(M, 0));
34 auto IsInbound = AC->isInBounds();
35 Value *V = nullptr;
36 if (BB) {
37- auto GEP = GetElementPtrInst::Create(nullptr, Base, Index, BV->getName(), BB);
38+ auto GEP = GetElementPtrInst::Create(BaseTy, Base, Index, BV->getName(), BB);
39 GEP->setIsInBounds(IsInbound);
40 V = GEP;
41 } else {
42- V = ConstantExpr::getGetElementPtr(nullptr, dyn_cast<Constant>(Base), Index, IsInbound);
43+ V = ConstantExpr::getGetElementPtr(BaseTy, dyn_cast<Constant>(Base), Index, IsInbound);
44 }
45 return mapValue(BV, V);
46 }
47diff --git a/IGC/Compiler/CustomSafeOptPass.cpp b/IGC/Compiler/CustomSafeOptPass.cpp
48index 83223b3cb..33547077e 100644
49--- a/IGC/Compiler/CustomSafeOptPass.cpp
50+++ b/IGC/Compiler/CustomSafeOptPass.cpp
51@@ -410,7 +410,8 @@ void CustomSafeOptPass::visitAllocaInst(AllocaInst& I)
52 gepArg1 = BinaryOperator::CreateSub(pGEP->getOperand(2), IRB.getInt32(index_lb), "reducedIndex", pGEP);
53 }
54 llvm::Value* gepArg[] = { pGEP->getOperand(1), gepArg1 };
55- llvm::Value* pGEPnew = GetElementPtrInst::Create(nullptr, newAlloca, gepArg, "", pGEP);
56+ Type *BaseTy = cast<PointerType>(newAlloca->getType())->getPointerElementType();
57+ llvm::Value* pGEPnew = GetElementPtrInst::Create(BaseTy, newAlloca, gepArg, "", pGEP);
58 pGEP->replaceAllUsesWith(pGEPnew);
59 }
60 }
61@@ -478,10 +479,11 @@ void CustomSafeOptPass::visitLoadInst(LoadInst& load)
62 SmallVector<Value*, 8> indices;
63 indices.append(gep->idx_begin(), gep->idx_end());
64 indices[selIdx] = sel->getOperand(1);
65- GetElementPtrInst* gep1 = GetElementPtrInst::Create(nullptr, gep->getPointerOperand(), indices, gep->getName(), gep);
66+ Type *BaseTy = cast<PointerType>(gep->getPointerOperand()->getType())->getPointerElementType();
67+ GetElementPtrInst* gep1 = GetElementPtrInst::Create(BaseTy, gep->getPointerOperand(), indices, gep->getName(), gep);
68 gep1->setDebugLoc(gep->getDebugLoc());
69 indices[selIdx] = sel->getOperand(2);
70- GetElementPtrInst* gep2 = GetElementPtrInst::Create(nullptr, gep->getPointerOperand(), indices, gep->getName(), gep);
71+ GetElementPtrInst* gep2 = GetElementPtrInst::Create(BaseTy, gep->getPointerOperand(), indices, gep->getName(), gep);
72 gep2->setDebugLoc(gep->getDebugLoc());
73 LoadInst* load1 = cast<LoadInst>(load.clone());
74 load1->insertBefore(&load);
75diff --git a/IGC/Compiler/LegalizationPass.cpp b/IGC/Compiler/LegalizationPass.cpp
76index 0586e1b40..fbb3fe894 100644
77--- a/IGC/Compiler/LegalizationPass.cpp
78+++ b/IGC/Compiler/LegalizationPass.cpp
79@@ -1568,7 +1568,8 @@ void Legalization::RecursivelyChangePointerType(Instruction* oldPtr, Instruction
80 if (GetElementPtrInst * gep = dyn_cast<GetElementPtrInst>(*II))
81 {
82 SmallVector<Value*, 8> Idx(gep->idx_begin(), gep->idx_end());
83- GetElementPtrInst* newGep = GetElementPtrInst::Create(nullptr, newPtr, Idx, "", gep);
84+ Type *BaseTy = cast<PointerType>(newPtr->getType())->getPointerElementType();
85+ GetElementPtrInst* newGep = GetElementPtrInst::Create(BaseTy, newPtr, Idx, "", gep);
86 RecursivelyChangePointerType(gep, newGep);
87 }
88 else if (LoadInst * load = dyn_cast<LoadInst>(*II))
89diff --git a/IGC/Compiler/Optimizer/IGCInstCombiner/7.0/InstructionCombining.cpp b/IGC/Compiler/Optimizer/IGCInstCombiner/7.0/InstructionCombining.cpp
90index ea5c450fb..94b6bd2be 100644
91--- a/IGC/Compiler/Optimizer/IGCInstCombiner/7.0/InstructionCombining.cpp
92+++ b/IGC/Compiler/Optimizer/IGCInstCombiner/7.0/InstructionCombining.cpp
93@@ -1675,7 +1675,8 @@ Instruction* InstCombiner::visitGetElementPtrInst(GetElementPtrInst& GEP) {
94 auto* NewSrc = cast<GetElementPtrInst>(
95 Builder.CreateGEP(SO0, GO1, Src->getName()));
96 NewSrc->setIsInBounds(Src->isInBounds());
97- auto* NewGEP = GetElementPtrInst::Create(nullptr, NewSrc, { SO1 });
98+ Type *BaseTy = cast<PointerType>(NewSrc->getType())->getPointerElementType();
99+ auto* NewGEP = GetElementPtrInst::Create(BaseTy, NewSrc, { SO1 });
100 NewGEP->setIsInBounds(GEP.isInBounds());
101 return NewGEP;
102 }
103diff --git a/IGC/Compiler/Optimizer/OpenCLPasses/LocalBuffers/InlineLocalsResolution.cpp b/IGC/Compiler/Optimizer/OpenCLPasses/LocalBuffers/InlineLocalsResolution.cpp
104index be585df75..4a31ca474 100644
105--- a/IGC/Compiler/Optimizer/OpenCLPasses/LocalBuffers/InlineLocalsResolution.cpp
106+++ b/IGC/Compiler/Optimizer/OpenCLPasses/LocalBuffers/InlineLocalsResolution.cpp
107@@ -179,9 +179,10 @@ bool InlineLocalsResolution::runOnModule(Module& M)
108 Value* sizeConstant = ConstantInt::get(Type::getInt32Ty(C), Offset);
109 SmallVector<Value*, 1> idx(1, sizeConstant);
110 Instruction* pInsertBefore = &(*F.begin()->getFirstInsertionPt());
111- Type* pLocalCharPtrType = Type::getInt8Ty(C)->getPointerTo(ADDRESS_SPACE_LOCAL);
112+ Type* pCharType = Type::getInt8Ty(C);
113+ Type* pLocalCharPtrType = pCharType->getPointerTo(ADDRESS_SPACE_LOCAL);
114 Instruction* pCharPtr = BitCastInst::CreatePointerCast(arg, pLocalCharPtrType, "localToChar", pInsertBefore);
115- Value* pMovedCharPtr = GetElementPtrInst::Create(nullptr, pCharPtr, idx, "movedLocal", pInsertBefore);
116+ Value* pMovedCharPtr = GetElementPtrInst::Create(pCharType, pCharPtr, idx, "movedLocal", pInsertBefore);
117
118 Value* pMovedPtr = CastInst::CreatePointerCast(pMovedCharPtr, ptrType, "charToLocal", pInsertBefore);
119
120diff --git a/IGC/Compiler/Optimizer/OpenCLPasses/ProgramScopeConstants/ProgramScopeConstantResolution.cpp b/IGC/Compiler/Optimizer/OpenCLPasses/ProgramScopeConstants/ProgramScopeConstantResolution.cpp
121index 64e48a247..d56472191 100644
122--- a/IGC/Compiler/Optimizer/OpenCLPasses/ProgramScopeConstants/ProgramScopeConstantResolution.cpp
123+++ b/IGC/Compiler/Optimizer/OpenCLPasses/ProgramScopeConstants/ProgramScopeConstantResolution.cpp
124@@ -190,7 +190,8 @@ bool ProgramScopeConstantResolution::runOnModule(Module& M)
125 Instruction* pEntryPoint = &(*userFunc->getEntryBlock().getFirstInsertionPt());
126
127 // Create a GEP to get to the right offset in the constant buffer
128- GetElementPtrInst* gep = GetElementPtrInst::Create(nullptr, &*bufArg, pOffset, "off" + pGlobalVar->getName(), pEntryPoint);
129+ Type *BaseTy = cast<PointerType>((&*bufArg)->getType())->getPointerElementType();
130+ GetElementPtrInst* gep = GetElementPtrInst::Create(BaseTy, &*bufArg, pOffset, "off" + pGlobalVar->getName(), pEntryPoint);
131 // Cast it back to the correct type.
132 CastInst* pNewVal = CastInst::CreatePointerCast(gep, pGlobalVar->getType(), "cast" + pGlobalVar->getName(), pEntryPoint);
133
134diff --git a/IGC/Compiler/Optimizer/Scalarizer.cpp b/IGC/Compiler/Optimizer/Scalarizer.cpp
135index 768cb6da2..75ec2ff0d 100644
136--- a/IGC/Compiler/Optimizer/Scalarizer.cpp
137+++ b/IGC/Compiler/Optimizer/Scalarizer.cpp
138@@ -994,7 +994,8 @@ void ScalarizeFunction::scalarizeInstruction(GetElementPtrInst* GI)
139 auto op1 = baseValue->getType()->isVectorTy() ? operand1[i] : baseValue;
140 auto op2 = indexValue->getType()->isVectorTy() ? operand2[i] : indexValue;
141
142- Value* newGEP = GetElementPtrInst::Create(nullptr, op1, op2, "", GI);
143+ Type *BaseTy = cast<PointerType>(op1->getType())->getPointerElementType();
144+ Value* newGEP = GetElementPtrInst::Create(BaseTy, op1, op2, "", GI);
145 Value* constIndex = ConstantInt::get(Type::getInt32Ty(context()), i);
146 Instruction* insert = InsertElementInst::Create(assembledVector,
147 newGEP, constIndex, "assembled.vect", GI);
148diff --git a/IGC/Compiler/PromoteResourceToDirectAS.cpp b/IGC/Compiler/PromoteResourceToDirectAS.cpp
149index 4d9ccf20c..555b1f9a8 100644
150--- a/IGC/Compiler/PromoteResourceToDirectAS.cpp
151+++ b/IGC/Compiler/PromoteResourceToDirectAS.cpp
152@@ -297,6 +297,7 @@ bool PatchGetElementPtr(const std::vector<Value*>& instList, Type* dstTy, unsign
153 unsigned numInstructions = instList.size();
154 Value* patchedInst = patchedSourcePtr;
155 dstPtr = nullptr;
156+ Type* patchTy = nullptr;
157
158 // Find all the instructions we need to patch, starting from the top.
159 // If there is more than one GEP instruction, we need to patch all of them, as well
160@@ -326,7 +327,6 @@ bool PatchGetElementPtr(const std::vector<Value*>& instList, Type* dstTy, unsign
161
162 if (!patchedInst)
163 {
164- Type* patchTy = nullptr;
165 if (patchInstructions.size() > 0)
166 {
167 // Get the original pointer type before any GEPs or bitcasts modifies it
168@@ -349,9 +349,9 @@ bool PatchGetElementPtr(const std::vector<Value*>& instList, Type* dstTy, unsign
169 llvm::SmallVector<llvm::Value*, 4> gepArgs(gepInst->idx_begin(), gepInst->idx_end());
170 // Create the new GEP instruction
171 if (gepInst->isInBounds())
172- patchedInst = GetElementPtrInst::CreateInBounds(nullptr, patchedInst, gepArgs, "", gepInst);
173+ patchedInst = GetElementPtrInst::CreateInBounds(patchTy, patchedInst, gepArgs, "", gepInst);
174 else
175- patchedInst = GetElementPtrInst::Create(nullptr, patchedInst, gepArgs, "", gepInst);
176+ patchedInst = GetElementPtrInst::Create(patchTy, patchedInst, gepArgs, "", gepInst);
177
178 if (GetElementPtrInst* gepPatchedInst = dyn_cast<GetElementPtrInst>(patchedInst))
179 {
180--
1812.35.3
182
diff --git a/dynamic-layers/clang-layer/recipes-opencl/igc/files/0002-LLVM13-changed-MCContext-constructor.patch b/dynamic-layers/clang-layer/recipes-opencl/igc/files/0002-LLVM13-changed-MCContext-constructor.patch
new file mode 100644
index 00000000..df6fa613
--- /dev/null
+++ b/dynamic-layers/clang-layer/recipes-opencl/igc/files/0002-LLVM13-changed-MCContext-constructor.patch
@@ -0,0 +1,41 @@
1From 049cbc1bf259ab109160987cbd43a485069957a6 Mon Sep 17 00:00:00 2001
2From: Marcin Naczk <marcin.naczk@intel.com>
3Date: Tue, 17 May 2022 09:50:31 +0000
4Subject: [PATCH 2/2] LLVM13 changed MCContext constructor
5
6For LLVM13, MCContext constructor changed.
7In the list of arguments appeared MCSubtargetInfo which is not used by us.
8ObjectFileInfo was removed from the list of arguments, so we need to set
9it in the next command.
10
11Upstream-Status: Backport
12Signed-off-by: Anuj Mittal <anuj.mittal@intel.com>
13---
14 IGC/WrapperLLVM/include/llvmWrapper/MC/MCContext.h | 11 +++++++----
15 1 file changed, 7 insertions(+), 4 deletions(-)
16
17diff --git a/IGC/WrapperLLVM/include/llvmWrapper/MC/MCContext.h b/IGC/WrapperLLVM/include/llvmWrapper/MC/MCContext.h
18index 3725864ef..f3e7e2b4e 100644
19--- a/IGC/WrapperLLVM/include/llvmWrapper/MC/MCContext.h
20+++ b/IGC/WrapperLLVM/include/llvmWrapper/MC/MCContext.h
21@@ -24,10 +24,13 @@ namespace IGCLLVM
22 bool DoAutoReset = true)
23 {
24 #if LLVM_VERSION_MAJOR >= 13
25- std::string Err;
26- const llvm::Target *T = llvm::TargetRegistry::lookupTarget(TheTriple.str(), Err);
27- std::unique_ptr<llvm::MCSubtargetInfo> STI(T->createMCSubtargetInfo(TheTriple.str(), "", ""));
28- return new llvm::MCContext(TheTriple, MAI, MRI, STI.get(), Mgr, TargetOpts, DoAutoReset);
29+// Refactor MCObjectFileInfo initialization and allow targets to create MCObjectFileInfo
30+//
31+// Differential Revision: https://reviews.llvm.org/D101921
32+
33+ auto *Context = new llvm::MCContext(TheTriple, MAI, MRI, nullptr, Mgr, TargetOpts, DoAutoReset);
34+ Context->setObjectFileInfo(MOFI);
35+ return Context;
36 #elif LLVM_VERSION_MAJOR >= 10
37 return new llvm::MCContext(MAI, MRI, MOFI, Mgr, TargetOpts, DoAutoReset);
38 #else
39--
402.35.3
41
diff --git a/dynamic-layers/clang-layer/recipes-opencl/igc/intel-graphics-compiler_1.0.8744.bb b/dynamic-layers/clang-layer/recipes-opencl/igc/intel-graphics-compiler_1.0.8744.bb
index 9bbe08c9..51c372ca 100644
--- a/dynamic-layers/clang-layer/recipes-opencl/igc/intel-graphics-compiler_1.0.8744.bb
+++ b/dynamic-layers/clang-layer/recipes-opencl/igc/intel-graphics-compiler_1.0.8744.bb
@@ -14,6 +14,8 @@ SRC_URI = "git://github.com/intel/intel-graphics-compiler.git;protocol=https;nam
14 file://0003-Improve-Reproducibility-for-src-package.patch \ 14 file://0003-Improve-Reproducibility-for-src-package.patch \
15 file://0004-find-external-llvm-tblgen.patch \ 15 file://0004-find-external-llvm-tblgen.patch \
16 file://0001-BiF-CMakeLists.txt-remove-opt-from-DEPENDS.patch \ 16 file://0001-BiF-CMakeLists.txt-remove-opt-from-DEPENDS.patch \
17 file://0001-Don-t-accept-nullptr-as-GEP-element-type.patch \
18 file://0002-LLVM13-changed-MCContext-constructor.patch \
17 " 19 "
18 20
19SRCREV_igc = "3ba8dde8c414a0e47df58b1bba12a64f8ba2089e" 21SRCREV_igc = "3ba8dde8c414a0e47df58b1bba12a64f8ba2089e"