@@ -2700,9 +2700,7 @@ 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 (
2704
- IGCLLVM::getNonOpaquePtrEltTy (Alloca->getType ()),
2705
- Alloca," " ,CI);
2703
+ auto Load = new LoadInst (Alloca->getAllocatedType (), Alloca, " " , CI);
2706
2704
CI->replaceAllUsesWith (Load);
2707
2705
CI->eraseFromParent ();
2708
2706
}
@@ -3483,7 +3481,9 @@ SPIRVToLLVM::transValueWithoutDecoration(SPIRVValue *BV, Function *F,
3483
3481
for (unsigned I = 0 , E = CS->getNumOperands (); I != E; I++)
3484
3482
{
3485
3483
auto *op = CS->getOperand (I);
3486
- auto *pGEP = IRB.CreateConstInBoundsGEP2_32 (IGCLLVM::getNonOpaquePtrEltTy (pointer->getType ()), pointer, 0 , I);
3484
+ Type* elTy = isa<AllocaInst>(pointer) ? cast<AllocaInst>(pointer)->getAllocatedType ()
3485
+ : cast<GetElementPtrInst>(pointer)->getResultElementType ();
3486
+ auto * pGEP = IRB.CreateConstInBoundsGEP2_32 (elTy, pointer, 0 , I);
3487
3487
if (auto *InnerCS = dyn_cast<ConstantStruct>(op))
3488
3488
LowerConstantStructStore (InnerCS, pGEP);
3489
3489
else
@@ -3520,7 +3520,7 @@ SPIRVToLLVM::transValueWithoutDecoration(SPIRVValue *BV, Function *F,
3520
3520
IGC_ASSERT_MESSAGE (BB, " Invalid BB" );
3521
3521
auto val = transValue (BL->getSrc (), F, BB);
3522
3522
LoadInst* LI = new LoadInst (
3523
- IGCLLVM::getNonOpaquePtrEltTy (val ->getType ()),
3523
+ transType (BL ->getType ()),
3524
3524
val,
3525
3525
BV->getName (),
3526
3526
BL->hasDecorate (DecorationVolatile) || BL->SPIRVMemoryAccess ::isVolatile () != 0 ,
@@ -3555,11 +3555,13 @@ SPIRVToLLVM::transValueWithoutDecoration(SPIRVValue *BV, Function *F,
3555
3555
Type* Int8Ty = Type::getInt8Ty (Dst->getContext ());
3556
3556
llvm::Value* Src = ConstantInt::get (Int8Ty, 0 );
3557
3557
llvm::Value* newDst = Dst;
3558
- if (!IGCLLVM::getNonOpaquePtrEltTy (Dst->getType ())->isIntegerTy (8 )) {
3559
- Type* Int8PointerTy = Type::getInt8PtrTy (Dst->getContext (),
3560
- Dst->getType ()->getPointerAddressSpace ());
3561
- newDst = llvm::BitCastInst::CreatePointerCast (Dst,
3562
- Int8PointerTy, " " , BB);
3558
+ if (!IGCLLVM::isOpaquePointerTy (Dst->getType ())) {
3559
+ if (!IGCLLVM::getNonOpaquePtrEltTy (Dst->getType ())->isIntegerTy (8 )) { // Legacy code: getNonOpaquePtrEltTy
3560
+ Type* Int8PointerTy = Type::getInt8PtrTy (Dst->getContext (),
3561
+ Dst->getType ()->getPointerAddressSpace ());
3562
+ newDst = llvm::BitCastInst::CreatePointerCast (Dst,
3563
+ Int8PointerTy, " " , BB);
3564
+ }
3563
3565
}
3564
3566
CI = Builder.CreateMemSet (newDst, Src, Size, IGCLLVM::getCorrectAlign (Align), IsVolatile);
3565
3567
}
@@ -3640,7 +3642,7 @@ SPIRVToLLVM::transValueWithoutDecoration(SPIRVValue *BV, Function *F,
3640
3642
case OpInBoundsPtrAccessChain: {
3641
3643
auto AC = static_cast <SPIRVAccessChainBase *>(BV);
3642
3644
auto Base = transValue (AC->getBase (), F, BB);
3643
- Type * BaseTy = IGCLLVM::getNonOpaquePtrEltTy (Base-> getType ());
3645
+ Type* BaseTy = transType (AC-> getBase ()-> getType ()-> getPointerElementType ());
3644
3646
auto Index = transValue (AC->getIndices (), F, BB);
3645
3647
if (!AC->hasPtrIndex ())
3646
3648
Index.insert (Index.begin (), getInt32 (M, 0 ));
@@ -3841,7 +3843,7 @@ SPIRVToLLVM::transValueWithoutDecoration(SPIRVValue *BV, Function *F,
3841
3843
auto func = transValue (BC->getCalledValue (), F, BB);
3842
3844
auto Call = CallInst::Create (
3843
3845
llvm::cast<llvm::FunctionType>(
3844
- IGCLLVM::getNonOpaquePtrEltTy (func-> getType ())),
3846
+ transType (BC-> getCalledValue ()-> getType ()-> getPointerElementType ())),
3845
3847
func,
3846
3848
transValue (BC->getArgumentValues (), F, BB),
3847
3849
BC->getName (),
@@ -4243,8 +4245,10 @@ SPIRVToLLVM::transFunction(SPIRVFunction *BF) {
4243
4245
#if LLVM_VERSION_MAJOR >= 12
4244
4246
Attribute::AttrKind LLVMKind = SPIRSPIRVFuncParamAttrMap::rmap (Kind);
4245
4247
Type *AttrTy = nullptr ;
4246
- if (LLVMKind == Attribute::AttrKind::ByVal || LLVMKind == Attribute::AttrKind::StructRet)
4247
- AttrTy = IGCLLVM::getNonOpaquePtrEltTy (I->getType ());
4248
+ if (LLVMKind == Attribute::AttrKind::ByVal)
4249
+ AttrTy = I->getParamByValType ();
4250
+ else if (LLVMKind == Attribute::AttrKind::StructRet)
4251
+ AttrTy = I->getParamStructRetType ();
4248
4252
4249
4253
// Make sure to use a correct constructor for a typed/typeless attribute
4250
4254
auto A = AttrTy ? Attribute::get (*Context, LLVMKind, AttrTy)
0 commit comments