Skip to content

Commit ec7b002

Browse files
svenvhvmaksimo
authored andcommitted
Update for LLVM GEP API change
Update for LLVM commit b00cff5 ("Reapply [IR] Don't accept nullptr as GEP element type", 2021-07-09). Original commit: KhronosGroup/SPIRV-LLVM-Translator@c8aaa5f
1 parent b93c154 commit ec7b002

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

llvm-spirv/lib/SPIRV/SPIRVReader.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2379,18 +2379,19 @@ Value *SPIRVToLLVM::transValueWithoutDecoration(SPIRVValue *BV, Function *F,
23792379
case OpInBoundsPtrAccessChain: {
23802380
auto AC = static_cast<SPIRVAccessChainBase *>(BV);
23812381
auto Base = transValue(AC->getBase(), F, BB);
2382+
Type *BaseTy = cast<PointerType>(Base->getType())->getPointerElementType();
23822383
auto Index = transValue(AC->getIndices(), F, BB);
23832384
if (!AC->hasPtrIndex())
23842385
Index.insert(Index.begin(), getInt32(M, 0));
23852386
auto IsInbound = AC->isInBounds();
23862387
Value *V = nullptr;
23872388
if (BB) {
23882389
auto GEP =
2389-
GetElementPtrInst::Create(nullptr, Base, Index, BV->getName(), BB);
2390+
GetElementPtrInst::Create(BaseTy, Base, Index, BV->getName(), BB);
23902391
GEP->setIsInBounds(IsInbound);
23912392
V = GEP;
23922393
} else {
2393-
V = ConstantExpr::getGetElementPtr(nullptr, dyn_cast<Constant>(Base),
2394+
V = ConstantExpr::getGetElementPtr(BaseTy, dyn_cast<Constant>(Base),
23942395
Index, IsInbound);
23952396
}
23962397
return mapValue(BV, V);

0 commit comments

Comments
 (0)