diff --git a/llvm/lib/Target/SPIRV/SPIRVEmitIntrinsics.cpp b/llvm/lib/Target/SPIRV/SPIRVEmitIntrinsics.cpp index 1c1acd29ee0e6..51e7f9fffff03 100644 --- a/llvm/lib/Target/SPIRV/SPIRVEmitIntrinsics.cpp +++ b/llvm/lib/Target/SPIRV/SPIRVEmitIntrinsics.cpp @@ -74,7 +74,6 @@ class SPIRVEmitIntrinsics DenseMap AggrConsts; DenseMap AggrConstTypes; DenseSet AggrStores; - SPIRV::InstructionSet::InstructionSet InstrSet; // map of function declarations to element type> DenseMap>> FDeclPtrTys; @@ -896,8 +895,10 @@ bool SPIRVEmitIntrinsics::deduceOperandElementTypeCalledFunction( getOclOrSpirvBuiltinDemangledName(CalledF->getName()); if (DemangledName.length() > 0 && !StringRef(DemangledName).starts_with("llvm.")) { - auto [Grp, Opcode, ExtNo] = - SPIRV::mapBuiltinToOpcode(DemangledName, InstrSet); + auto [Grp, Opcode, ExtNo] = SPIRV::mapBuiltinToOpcode( + DemangledName, TM->getSubtarget(*CalledF).isOpenCLEnv() + ? SPIRV::InstructionSet::OpenCL_std + : SPIRV::InstructionSet::GLSL_std_450); if (Opcode == SPIRV::OpGroupAsyncCopy) { for (unsigned i = 0, PtrCnt = 0; i < CI->arg_size() && PtrCnt < 2; ++i) { Value *Op = CI->getArgOperand(i); @@ -2316,10 +2317,6 @@ bool SPIRVEmitIntrinsics::runOnFunction(Function &Func) { return false; const SPIRVSubtarget &ST = TM->getSubtarget(Func); - GR = ST.getSPIRVGlobalRegistry(); - InstrSet = ST.isOpenCLEnv() ? SPIRV::InstructionSet::OpenCL_std - : SPIRV::InstructionSet::GLSL_std_450; - if (!CurrF) HaveFunPtrs = ST.canUseExtension(SPIRV::Extension::SPV_INTEL_function_pointers); @@ -2475,8 +2472,10 @@ void SPIRVEmitIntrinsics::parseFunDeclarations(Module &M) { if (DemangledName.empty()) continue; // allow only OpGroupAsyncCopy use case at the moment - auto [Grp, Opcode, ExtNo] = - SPIRV::mapBuiltinToOpcode(DemangledName, InstrSet); + auto [Grp, Opcode, ExtNo] = SPIRV::mapBuiltinToOpcode( + DemangledName, TM->getSubtarget(F).isOpenCLEnv() + ? SPIRV::InstructionSet::OpenCL_std + : SPIRV::InstructionSet::GLSL_std_450); if (Opcode != SPIRV::OpGroupAsyncCopy) continue; // find pointer arguments