@@ -2700,7 +2700,9 @@ SPIRVToLLVM::postProcessFunctionsReturnStruct(Function *F) {
2700
2700
Args.insert (Args.begin (), Alloca);
2701
2701
auto NewCI = CallInst::Create (NewF, Args, " " , CI);
2702
2702
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);
2704
2706
CI->replaceAllUsesWith (Load);
2705
2707
CI->eraseFromParent ();
2706
2708
}
@@ -3281,17 +3283,14 @@ SPIRVToLLVM::transValueWithoutDecoration(SPIRVValue *BV, Function *F,
3281
3283
SPIRVStorageClassKind BS = BVar->getStorageClass ();
3282
3284
SPIRVValue *Init = BVar->getInitializer ();
3283
3285
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 ;
3291
3291
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);
3295
3294
}
3296
3295
3297
3296
if (Init)
@@ -3484,9 +3483,7 @@ SPIRVToLLVM::transValueWithoutDecoration(SPIRVValue *BV, Function *F,
3484
3483
for (unsigned I = 0 , E = CS->getNumOperands (); I != E; I++)
3485
3484
{
3486
3485
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);
3490
3487
if (auto *InnerCS = dyn_cast<ConstantStruct>(op))
3491
3488
LowerConstantStructStore (InnerCS, pGEP);
3492
3489
else
@@ -3523,7 +3520,7 @@ SPIRVToLLVM::transValueWithoutDecoration(SPIRVValue *BV, Function *F,
3523
3520
IGC_ASSERT_MESSAGE (BB, " Invalid BB" );
3524
3521
auto val = transValue (BL->getSrc (), F, BB);
3525
3522
LoadInst* LI = new LoadInst (
3526
- transType (BL ->getType ()),
3523
+ IGCLLVM::getNonOpaquePtrEltTy (val ->getType ()),
3527
3524
val,
3528
3525
BV->getName (),
3529
3526
BL->hasDecorate (DecorationVolatile) || BL->SPIRVMemoryAccess ::isVolatile () != 0 ,
@@ -3643,7 +3640,7 @@ SPIRVToLLVM::transValueWithoutDecoration(SPIRVValue *BV, Function *F,
3643
3640
case OpInBoundsPtrAccessChain: {
3644
3641
auto AC = static_cast <SPIRVAccessChainBase *>(BV);
3645
3642
auto Base = transValue (AC->getBase (), F, BB);
3646
- Type* BaseTy = transType (AC-> getBase ()-> getType ()-> getPointerElementType ());
3643
+ Type * BaseTy = IGCLLVM::getNonOpaquePtrEltTy (Base-> getType ());
3647
3644
auto Index = transValue (AC->getIndices (), F, BB);
3648
3645
if (!AC->hasPtrIndex ())
3649
3646
Index.insert (Index.begin (), getInt32 (M, 0 ));
0 commit comments