Skip to content

Commit

Permalink
IGCLLVM::getNonOpaquePtrEltTy usage elimination
Browse files Browse the repository at this point in the history
This change is a part of the effort to support opaque pointers in newer
LLVM versions
  • Loading branch information
mshelego authored and igcbot committed Aug 28, 2024
1 parent 0fb8663 commit 9f18c6e
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 11 deletions.
10 changes: 6 additions & 4 deletions IGC/VectorCompiler/lib/GenXCodeGen/GenXCisaBuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2612,8 +2612,8 @@ static unsigned getResultedTypeSize(Type *Ty, const DataLayout &DL) {
TySz += getResultedTypeSize(Ty, DL);
} else if (Ty->isPointerTy())
// FIXME: fix data layout description.
TySz = IGCLLVM::getNonOpaquePtrEltTy(Ty)->isFunctionTy() ? genx::DWordBytes
: DL.getPointerSize();
TySz =
vc::isFunctionPointerType(Ty) ? genx::DWordBytes : DL.getPointerSize();
else {
TySz = Ty->getPrimitiveSizeInBits() / CHAR_BIT;
IGC_ASSERT_MESSAGE(TySz, "Ty is not primitive?");
Expand Down Expand Up @@ -4824,8 +4824,10 @@ void GenXKernelBuilder::buildConvertAddr(CallInst *CI, genx::BaleInfo BI,
// we need a different type.
Type *OverrideTy = nullptr;
Type *BaseTy = Base->getType();
if (BaseTy->isPointerTy())
BaseTy = IGCLLVM::getNonOpaquePtrEltTy(BaseTy);
if (BaseTy->isPointerTy()) {
auto *GV = cast<GlobalVariable>(Base);
BaseTy = GV->getValueType();
}
unsigned ElementBytes =
BaseTy->getScalarType()->getPrimitiveSizeInBits() >> 3;
int Offset = cast<ConstantInt>(CI->getArgOperand(1))->getSExtValue();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*========================== begin_copyright_notice ============================
Copyright (C) 2022-2023 Intel Corporation
Copyright (C) 2022-2024 Intel Corporation
SPDX-License-Identifier: MIT
Expand Down Expand Up @@ -400,8 +400,9 @@ void GenXGASDynamicResolution::resolveOnLoadStore(Instruction &I,
Builder.SetInsertPoint(BB);
auto NewPtrOp = createASCast(Builder, PtrOp, AS);
if (LoadInst *LI = dyn_cast<LoadInst>(&I))
Load = Builder.CreateAlignedLoad(IGCLLVM::getNonOpaquePtrEltTy(NewPtrOp->getType()),
NewPtrOp, IGCLLVM::getAlign(*LI), LI->isVolatile(), LoadName);
Load = Builder.CreateAlignedLoad(LI->getType(), NewPtrOp,
IGCLLVM::getAlign(*LI), LI->isVolatile(),
LoadName);
else if (StoreInst *SI = dyn_cast<StoreInst>(&I))
Builder.CreateAlignedStore(I.getOperand(0), NewPtrOp,
IGCLLVM::getAlign(*SI), SI->isVolatile());
Expand Down
7 changes: 3 additions & 4 deletions IGC/VectorCompiler/lib/GenXCodeGen/GenXVisaRegAlloc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -670,7 +670,7 @@ void GenXVisaRegAlloc::allocReg(LiveRange *LR) {
return;

if (GV->hasAttribute(genx::FunctionMD::GenXVolatile))
Ty = IGCLLVM::getNonOpaquePtrEltTy(Ty);
Ty = GV->getValueType();
}
IGC_ASSERT(!Ty->isVoidTy());
if (LR->Category == vc::RegCategory::Predicate) {
Expand Down Expand Up @@ -707,7 +707,7 @@ static Type *calcOverrideType(Type *OverrideType, const SimpleValue &V,
if (OverrideType->isPointerTy()) {
auto GV = dyn_cast<GlobalVariable>(V.getValue());
if (GV && GV->hasAttribute(genx::FunctionMD::GenXVolatile))
OverrideType = IGCLLVM::getNonOpaquePtrEltTy(OverrideType);
OverrideType = GV->getValueType();
}
OverrideType = &vc::fixDegenerateVectorType(*OverrideType);
if (R->Num < VISA_NUM_RESERVED_REGS)
Expand Down Expand Up @@ -917,8 +917,7 @@ TypeDetails::TypeDetails(const DataLayout &DL, Type *Ty, Signedness Signed,
VisaType = ISA_TYPE_DF;
} else if (auto *PtrTy = dyn_cast<PointerType>(ElementTy)) {
BytesPerElement = DL.getPointerTypeSize(PtrTy);
if (BytesPerElement == DWordBytes ||
IGCLLVM::getNonOpaquePtrEltTy(PtrTy)->isFunctionTy())
if (BytesPerElement == DWordBytes || vc::isFunctionPointerType(PtrTy))
VisaType = ISA_TYPE_UD;
else if (BytesPerElement == QWordBytes)
VisaType = ISA_TYPE_UQ;
Expand Down

0 comments on commit 9f18c6e

Please sign in to comment.