[llvm] [SPIR-V] Allow intrinsics with aggregate return type to reach GlobalISel (PR #108893)
Vyacheslav Levytskyy via llvm-commits
llvm-commits at lists.llvm.org
Fri Sep 20 03:46:13 PDT 2024
================
@@ -462,6 +468,25 @@ generateAssignInstrs(MachineFunction &MF, SPIRVGlobalRegistry *GR,
Def->getOpcode() != SPIRV::ASSIGN_TYPE)
insertAssignInstr(Reg, Ty, nullptr, GR, MIB, MF.getRegInfo());
ToErase.push_back(&MI);
+ } else if (MIOp == TargetOpcode::FAKE_USE && MI.getNumOperands() > 0) {
+ MachineInstr *MdMI = MI.getPrevNode();
+ if (MdMI && isSpvIntrinsic(*MdMI, Intrinsic::spv_value_md)) {
+ // It's an internal service info from before IRTranslator passes.
+ MachineInstr *Def = getVRegDef(MRI, MI.getOperand(0).getReg());
+ for (unsigned I = 1, E = MI.getNumOperands(); I != E && Def; ++I)
+ if (getVRegDef(MRI, MI.getOperand(I).getReg()) != Def)
+ Def = nullptr;
+ if (Def) {
+ const MDNode *MD = MdMI->getOperand(1).getMetadata();
+ StringRef ValueName =
+ cast<MDString>(MD->getOperand(1))->getString();
+ const MDNode *TypeMD = cast<MDNode>(MD->getOperand(0));
+ Type *ValueTy = getMDOperandAsType(TypeMD, 0);
+ GR->addValueAttrs(Def, std::make_pair(ValueTy, ValueName));
----------------
VyacheslavLevytskyy wrote:
I recalled my reasoning why StringRef is a safe choice here, and actually it looks like a safe choice, but I agree that `std:string` makes it independent on implementation details and allows to reason about lifetime and safety in simpler terms (the last thing I'd wish to doubt in this code base is about lifetimes).
https://github.com/llvm/llvm-project/pull/108893
More information about the llvm-commits
mailing list