[llvm] [SPIR-V] Do not use OpenCL metadata for ptr element type resolution (PR #82678)
Michal Paszkowski via llvm-commits
llvm-commits at lists.llvm.org
Mon Mar 4 12:03:29 PST 2024
================
@@ -567,22 +608,20 @@ void SPIRVEmitIntrinsics::processGlobalValue(GlobalVariable &GV) {
void SPIRVEmitIntrinsics::insertAssignPtrTypeIntrs(Instruction *I) {
reportFatalOnTokenType(I);
- if (I->getType()->isVoidTy() || !requireAssignPtrType(I))
+ if (!I->getType()->isPointerTy() || !requireAssignType(I) ||
+ isa<BitCastInst>(I))
return;
setInsertPointSkippingPhis(*IRB, I->getNextNode());
Constant *EltTyConst;
- unsigned AddressSpace = 0;
- if (auto *AI = dyn_cast<AllocaInst>(I)) {
+ unsigned AddressSpace = I->getType()->getPointerAddressSpace();
+ if (auto *AI = dyn_cast<AllocaInst>(I))
EltTyConst = UndefValue::get(AI->getAllocatedType());
- AddressSpace = AI->getAddressSpace();
- } else if (auto *GEP = dyn_cast<GetElementPtrInst>(I)) {
+ else if (auto *GEP = dyn_cast<GetElementPtrInst>(I))
EltTyConst = UndefValue::get(GEP->getResultElementType());
- AddressSpace = GEP->getPointerAddressSpace();
- } else {
- llvm_unreachable("Unexpected instruction!");
- }
+ else if (I->getType()->isPointerTy())
+ EltTyConst = UndefValue::get(IntegerType::getInt8Ty(I->getContext()));
----------------
michalpaszkowski wrote:
@bogner Thank you for catching this! Yes, this should be in an else clause. Here is a pull request fixing this: https://github.com/llvm/llvm-project/pull/83901
https://github.com/llvm/llvm-project/pull/82678
More information about the llvm-commits
mailing list