1 # This patch is needed for ISPC for Xe only
2 # It disables using of DIArgList for dbg.val if SPIR-V target is used.
3 # It is needed till DIArgList is supported in SPIR-V Translator.
4 diff --git a/llvm/lib/Transforms/Utils/Local.cpp b/llvm/lib/Transforms/Utils/Local.cpp
5 index d03d76f57ca1..0b86e454df57 100644
6 --- a/llvm/lib/Transforms/Utils/Local.cpp
7 +++ b/llvm/lib/Transforms/Utils/Local.cpp
8 @@ -1771,7 +1771,14 @@ void llvm::salvageDebugInfoForDbgValues(
9 } else if (isa<DbgValueInst>(DII) &&
10 DII->getNumVariableLocationOps() + AdditionalValues.size() <=
12 - DII->addVariableLocationOps(AdditionalValues, SalvagedExpr);
13 + if (!Triple(I.getModule()->getTargetTriple()).isSPIR()) {
14 + DII->addVariableLocationOps(AdditionalValues, SalvagedExpr);
16 + // Do not salvage using DIArgList for dbg.val fpr SPIR-V target, as it is
17 + // not currently supported by SPIR-V Translator.
18 + Value *Undef = UndefValue::get(I.getOperand(0)->getType());
19 + DII->replaceVariableLocationOp(I.getOperand(0), Undef);
22 // Do not salvage using DIArgList for dbg.addr/dbg.declare, as it is
23 // currently only valid for stack value expressions.