From 63f2b1b07e0e26a05ba781a0d4abd3961ce99c5b Mon Sep 17 00:00:00 2001 From: "Maksimova, Viktoria" Date: Tue, 9 Jul 2024 04:16:15 -0700 Subject: [PATCH] Revert "[SPIR-V] W/A for builtin vars translation (#7632)" This reverts commit ead840494a6ecbd534f9161190217c02d3c6189a. --- llvm-spirv/lib/SPIRV/SPIRVWriter.cpp | 49 ---------------------------- 1 file changed, 49 deletions(-) diff --git a/llvm-spirv/lib/SPIRV/SPIRVWriter.cpp b/llvm-spirv/lib/SPIRV/SPIRVWriter.cpp index f14fb34912696..fe793e49a656c 100644 --- a/llvm-spirv/lib/SPIRV/SPIRVWriter.cpp +++ b/llvm-spirv/lib/SPIRV/SPIRVWriter.cpp @@ -2113,55 +2113,6 @@ LLVMToSPIRVBase::transValueWithoutDecoration(Value *V, SPIRVBasicBlock *BB, BM->addExtension(ExtensionID::SPV_INTEL_hw_thread_queries); } - // TODO: it's W/A for intel/llvm to prevent not fixed SPIR-V consumers - // see https://github.com/intel/llvm/issues/7592 - // from crashing. Need to remove, when we have the fixed drivers - // to remove: begin - { - std::vector GEPs; - std::vector Loads; - auto *GVTy = GV->getType(); - auto *VecTy = GVTy->isOpaquePointerTy() - ? nullptr - : dyn_cast( - GVTy->getNonOpaquePointerElementType()); - auto ReplaceIfLoad = [&](User *I, ConstantInt *Idx) -> void { - auto *LD = dyn_cast(I); - if (!LD) - return; - Loads.push_back(LD); - const DebugLoc &DLoc = LD->getDebugLoc(); - LoadInst *Load = new LoadInst(VecTy, GV, "", LD); - ExtractElementInst *Extract = ExtractElementInst::Create(Load, Idx); - if (DLoc) - Extract->setDebugLoc(DLoc); - Extract->insertAfter(cast(Load)); - LD->replaceAllUsesWith(Extract); - }; - for (auto *UI : GV->users()) { - if (!VecTy) - break; - if (auto *GEP = dyn_cast(UI)) { - GEPs.push_back(GEP); - for (auto *GEPUser : GEP->users()) { - assert(GEP->getNumIndices() == 2 && - "GEP to ID vector is expected to have exactly 2 indices"); - auto *Idx = cast(GEP->getOperand(2)); - ReplaceIfLoad(GEPUser, Idx); - } - } - } - auto Erase = [](std::vector &ToErase) { - for (Instruction *I : ToErase) { - assert(I->user_empty()); - I->eraseFromParent(); - } - }; - Erase(Loads); - Erase(GEPs); - } - // to remove: end - BVar->setBuiltin(Builtin); return BVar; }