Skip to content

Commit 4827fbb

Browse files
sys-igcigcbot
authored andcommitted
[Autobackout][FunctionalRegression]Revert of change: 83d1a04: Reduce usage of pointer element types (19).
This change replaces calls to getNonOpaquePtrEltTy with element type information got through other means. This change is part of the effort to support opaque pointers in newer LLVM versions.
1 parent 167f3e8 commit 4827fbb

File tree

2 files changed

+15
-17
lines changed

2 files changed

+15
-17
lines changed

IGC/AdaptorOCL/SPIRV/SPIRVReader.cpp

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2700,7 +2700,9 @@ SPIRVToLLVM::postProcessFunctionsReturnStruct(Function *F) {
27002700
Args.insert(Args.begin(), Alloca);
27012701
auto NewCI = CallInst::Create(NewF, Args, "", CI);
27022702
NewCI->setCallingConv(CI->getCallingConv());
2703-
auto Load = new LoadInst(Alloca->getAllocatedType(), Alloca,"",CI);
2703+
auto Load = new LoadInst(
2704+
IGCLLVM::getNonOpaquePtrEltTy(Alloca->getType()),
2705+
Alloca,"",CI);
27042706
CI->replaceAllUsesWith(Load);
27052707
CI->eraseFromParent();
27062708
}
@@ -3281,17 +3283,14 @@ SPIRVToLLVM::transValueWithoutDecoration(SPIRVValue *BV, Function *F,
32813283
SPIRVStorageClassKind BS = BVar->getStorageClass();
32823284
SPIRVValue *Init = BVar->getInitializer();
32833285

3284-
if (isa<PointerType>(Ty)) {
3285-
auto elTy = transType(BVar->getType()->getPointerElementType()->getPointerElementType());
3286-
if (isSPIRVSamplerType(elTy) && BS == StorageClassUniformConstant) {
3287-
// Skip generating llvm code during translation of a variable definition,
3288-
// generate code only for its uses
3289-
if (!BB)
3290-
return nullptr;
3286+
if (isSPIRVSamplerType(Ty) && BS == StorageClassUniformConstant) {
3287+
// Skip generating llvm code during translation of a variable definition,
3288+
// generate code only for its uses
3289+
if (!BB)
3290+
return nullptr;
32913291

3292-
IGC_ASSERT_MESSAGE(Init, "UniformConstant OpVariable with sampler type must have an initializer!");
3293-
return transValue(Init, F, BB);
3294-
}
3292+
IGC_ASSERT_MESSAGE(Init, "UniformConstant OpVariable with sampler type must have an initializer!");
3293+
return transValue(Init, F, BB);
32953294
}
32963295

32973296
if (Init)
@@ -3484,9 +3483,7 @@ SPIRVToLLVM::transValueWithoutDecoration(SPIRVValue *BV, Function *F,
34843483
for (unsigned I = 0, E = CS->getNumOperands(); I != E; I++)
34853484
{
34863485
auto *op = CS->getOperand(I);
3487-
Type* elTy = isa<AllocaInst>(pointer) ? cast<AllocaInst>(pointer)->getAllocatedType()
3488-
: cast<GetElementPtrInst>(pointer)->getResultElementType();
3489-
auto *pGEP = IRB.CreateConstInBoundsGEP2_32(elTy, pointer, 0, I);
3486+
auto *pGEP = IRB.CreateConstInBoundsGEP2_32(IGCLLVM::getNonOpaquePtrEltTy(pointer->getType()), pointer, 0, I);
34903487
if (auto *InnerCS = dyn_cast<ConstantStruct>(op))
34913488
LowerConstantStructStore(InnerCS, pGEP);
34923489
else
@@ -3523,7 +3520,7 @@ SPIRVToLLVM::transValueWithoutDecoration(SPIRVValue *BV, Function *F,
35233520
IGC_ASSERT_MESSAGE(BB, "Invalid BB");
35243521
auto val = transValue(BL->getSrc(), F, BB);
35253522
LoadInst* LI = new LoadInst(
3526-
transType(BL->getType()),
3523+
IGCLLVM::getNonOpaquePtrEltTy(val->getType()),
35273524
val,
35283525
BV->getName(),
35293526
BL->hasDecorate(DecorationVolatile) || BL->SPIRVMemoryAccess::isVolatile() != 0,
@@ -3643,7 +3640,7 @@ SPIRVToLLVM::transValueWithoutDecoration(SPIRVValue *BV, Function *F,
36433640
case OpInBoundsPtrAccessChain: {
36443641
auto AC = static_cast<SPIRVAccessChainBase *>(BV);
36453642
auto Base = transValue(AC->getBase(), F, BB);
3646-
Type* BaseTy = transType(AC->getBase()->getType()->getPointerElementType());
3643+
Type *BaseTy = IGCLLVM::getNonOpaquePtrEltTy(Base->getType());
36473644
auto Index = transValue(AC->getIndices(), F, BB);
36483645
if (!AC->hasPtrIndex())
36493646
Index.insert(Index.begin(), getInt32(M, 0));

IGC/AdaptorOCL/SPIRV/SPIRVUtil.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -439,7 +439,8 @@ std::string getSPIRVImageSampledTypeName(SPIRVType* Ty) {
439439
}
440440

441441
bool isSPIRVSamplerType(llvm::Type* Ty) {
442-
if (auto ST = dyn_cast<StructType>(Ty))
442+
if (auto PT = dyn_cast<PointerType>(Ty))
443+
if (auto ST = dyn_cast<StructType>(IGCLLVM::getNonOpaquePtrEltTy(PT)))
443444
if (ST->isOpaque()) {
444445
auto Name = ST->getName();
445446
if (Name.startswith(std::string(kSPIRVTypeName::PrefixAndDelim) + kSPIRVTypeName::Sampler)) {

0 commit comments

Comments
 (0)