Skip to content

Commit

Permalink
Revert "[SPIR-V] W/A for builtin vars translation (#7632)" (#14495)
Browse files Browse the repository at this point in the history
This reverts commit ead8404.

The commit was W/A which should be removed to align with Khronos
translator code base.
It resolves p.2 of #7592 "adds extra code" section.
  • Loading branch information
vmaksimo authored Jul 10, 2024
1 parent 510965a commit 7273aa3
Showing 1 changed file with 0 additions and 49 deletions.
49 changes: 0 additions & 49 deletions llvm-spirv/lib/SPIRV/SPIRVWriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<Instruction *> GEPs;
std::vector<Instruction *> Loads;
auto *GVTy = GV->getType();
auto *VecTy = GVTy->isOpaquePointerTy()
? nullptr
: dyn_cast<FixedVectorType>(
GVTy->getNonOpaquePointerElementType());
auto ReplaceIfLoad = [&](User *I, ConstantInt *Idx) -> void {
auto *LD = dyn_cast<LoadInst>(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<Instruction>(Load));
LD->replaceAllUsesWith(Extract);
};
for (auto *UI : GV->users()) {
if (!VecTy)
break;
if (auto *GEP = dyn_cast<GetElementPtrInst>(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<ConstantInt>(GEP->getOperand(2));
ReplaceIfLoad(GEPUser, Idx);
}
}
}
auto Erase = [](std::vector<Instruction *> &ToErase) {
for (Instruction *I : ToErase) {
assert(I->user_empty());
I->eraseFromParent();
}
};
Erase(Loads);
Erase(GEPs);
}
// to remove: end

BVar->setBuiltin(Builtin);
return BVar;
}
Expand Down

0 comments on commit 7273aa3

Please sign in to comment.